Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions scripts/ci-release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,34 @@ async function dryRunMode() {
}

try {
// This prevent lerna command from throwing this error in dry-run mode:
// "Working tree has uncommitted changes, please commit or remove the following changes before continuing"
// UPDATE: we are not using lerna because Verdaccio deosnot support provenance or trusted publishers
// await execa(
// 'git',
// ['update-index', '--skip-worktree', '.npmrc']
// )
// .pipeStdout(process.stdout)
// .pipeStderr(process.stderr)

// It appears Verdaccio does not support trusted publishers and lerna
// has no option to disable it. Fall back to individually publishing them.
const root = path.join(process.cwd(), 'packages')
const dirs = ['rum-core', 'rum', 'rum-angular', 'rum-react', 'rum-vue']
const pkgs = {}

// get info of each package
for (const dir of dirs) {
// Verdaccio does not support provenance for now so we disable it
// ref: https://github.com/orgs/verdaccio/discussions/3903
const pkgPath = path.join(root, dir, 'package.json')
const pkgText = readFileSync(pkgPath, {encoding: 'utf-8'})
writeFileSync(pkgPath, pkgText.replace('"provenance": true', '"provenance": false'))
const pkgJson = JSON.parse(pkgText)
pkgs[dir] = { pkgPath, pkgJson, pkgText }
}

for (const dir of dirs) {
// Verdaccio does not support provenance for now so we disable it
// ref: https://github.com/orgs/verdaccio/discussions/3903
const { pkgPath, pkgText } = pkgs[dir]
let text = pkgText

// Disable provenence for verdaccio
text = text.replace('"provenance": true', '"provenance": false')
// Resolve the file:../ dependencies
for (const d of dirs) {
const { pkgJson } = pkgs[d]
text = text.replace(`file:../${d}`, `^${pkgJson.version}`)
}
writeFileSync(pkgPath, text)

// And publish
await execa(
Expand All @@ -115,6 +123,7 @@ async function dryRunMode() {
.pipeStderr(process.stderr)
}
} catch (err) {
console.log(err)
raiseError('Failed to publish npm packages')
}

Expand Down