Validate version bumped for v tags (#10567)

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko
2026-02-28 17:17:03 +07:00
committed by GitHub
parent 7ab3c00fa5
commit c3758432bf
3 changed files with 40 additions and 37 deletions
@@ -1,22 +0,0 @@
# Reusable action: set all @hcengineering package versions from a v tag ref
# (e.g. refs/tags/v0.7.370 → 0.7.370) using common/scripts/bump.js.
# Call only when github.ref is a v* tag (e.g. if: startsWith(github.ref, 'refs/tags/v')).
name: 'Set package versions'
description: 'Set all @hcengineering package versions from a v tag ref using bump.js'
inputs:
ref:
description: 'Git ref for the tag (e.g. github.ref, e.g. refs/tags/v0.7.370)'
required: true
outputs:
version:
description: 'Semver version derived from the tag (e.g. 0.7.370)'
runs:
using: 'composite'
steps:
- id: bump
run: |
VERSION="${INPUT_REF#refs/tags/v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV
node common/scripts/bump.js "$VERSION"
shell: bash
+9 -6
View File
@@ -77,11 +77,6 @@ jobs:
- uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- name: Set package versions
if: startsWith(github.event.inputs.ref || github.ref, 'refs/tags/v')
uses: ./.github/actions/set-package-versions
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Cache node modules
uses: actions/cache@v5
env:
@@ -114,6 +109,14 @@ jobs:
- name: Model version from git tags
run: node common/scripts/install-run-rush.js model-version
- name: Verify package versions match tag
if: startsWith(github.event.inputs.ref || github.ref, 'refs/tags/v')
run: |
REF="${{ github.event.inputs.ref || github.ref }}"
VERSION="${REF#refs/tags/v}"
VERSION="${VERSION#v}"
node common/scripts/bump.js --check "$VERSION"
- name: Building...
run: node common/scripts/install-run-rush.js build
@@ -970,5 +973,5 @@ jobs:
REF="${{ github.event.inputs.ref || github.ref }}"
VERSION="${REF#refs/tags/v}"
VERSION="${VERSION#v}"
node common/scripts/bump.js "$VERSION"
node common/scripts/bump.js --check "$VERSION"
node common/scripts/safe-publish.js
+31 -9
View File
@@ -77,22 +77,25 @@ function fix (name) {
}
function main () {
const args = process.argv
const argv = process.argv.slice(2)
const doFix = args.includes('--fix')
const doPublish = args.includes('--publish')
const doFix = argv.includes('--fix')
const doPublish = argv.includes('--publish')
const doCheck = argv.includes('--check')
const positional = argv.filter((a) => !a.startsWith('--'))
const version = positional[0]
const version = args.reverse().shift()
if (version === undefined || version === '') {
console.log('usage: node bump.js [--publish] <version>')
console.log('usage: node bump.js [--check] [--fix] [--publish] <version>')
return
}
if( !/^(\d+\.)?(\d+\.)?(\*|\d+)$/.test(version)) {
if (!/^(\d+\.)?(\d+\.)?(\*|\d+)$/.test(version)) {
console.log('Invalid <version>', version, ' should be xx.xx.xx')
return
}
console.log('bump version ...', version)
console.log(doCheck ? 'check versions ...' : 'bump version ...', version)
const output = execSync('node common/scripts/install-run-rush.js list -p --json', { encoding: 'utf-8', cwd: repoRoot })
const lines = output.split('\n')
@@ -112,14 +115,33 @@ function main () {
fillPackages(config)
const packageNames = Object.keys(packages)
if (doCheck) {
let ok = true
for (const packageName of packageNames) {
const json = jsons[packageName]
if (json === undefined) continue
if (json.version !== version) {
console.error('Version mismatch:', packageName, 'expected', version, 'got', json.version)
ok = false
}
}
if (!ok) {
console.error('Some @hcengineering package versions do not match', version)
process.exit(1)
}
console.log('All @hcengineering package versions match', version)
return
}
for (const packageName of packageNames) {
bumpPackage(packageName, version)
}
for (const packageName of packageNames) {
const package = packages[packageName]
const pkg = packages[packageName]
if (jsons[packageName] === undefined) continue
const file = path.join(package.path, 'package.json')
const file = path.join(pkg.path, 'package.json')
const res = JSON.stringify(jsons[packageName], undefined, 2)
fs.writeFileSync(file, res + '\n')
}