diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ebc090..e5b5a30 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,8 +45,12 @@ jobs: with: node-version: 22 cache: npm - - name: Verify release version + - name: Verify tagged release version + if: github.event_name == 'push' || inputs.publish_release run: node scripts/verify-release-version.js + - name: Verify non-publishing package version + if: github.event_name == 'workflow_dispatch' && !inputs.publish_release + run: node scripts/verify-release-version.js --allow-untagged - name: Verify Companion release identity run: node scripts/verify-companion-release.js - uses: dtolnay/rust-toolchain@stable diff --git a/scripts/verify-release-version.js b/scripts/verify-release-version.js index 8e33a6c..e228a4f 100644 --- a/scripts/verify-release-version.js +++ b/scripts/verify-release-version.js @@ -42,23 +42,11 @@ function versionFromRef(ref) { return version; } -const tag = argValue('--tag') || process.env.GITHUB_REF_NAME; -const expected = versionFromRef(tag); const versions = { 'package.json': readPackageVersion(repositoryRoot), 'src-tauri/Cargo.toml': readCargoVersion(repositoryRoot), 'src-tauri/tauri.conf.json': readTauriVersion(repositoryRoot), }; -const mismatches = Object.entries(versions) - .filter(([, version]) => version !== expected) - .map(([file, version]) => `${file}=${version}`); - -if (mismatches.length > 0) { - console.error(`Release tag ${tag} does not match the application manifests (expected ${expected}).`); - for (const mismatch of mismatches) console.error(` ${mismatch}`); - process.exit(1); -} - const uniqueVersions = new Set(Object.values(versions)); if (uniqueVersions.size !== 1) { console.error('Application version manifests do not agree:'); @@ -66,4 +54,21 @@ if (uniqueVersions.size !== 1) { process.exit(1); } -console.log(`Release version ${expected} matches ${Object.keys(versions).length} manifests.`); +const allowUntagged = process.argv.includes('--allow-untagged'); +const tag = argValue('--tag') || process.env.GITHUB_REF_NAME; +const expected = allowUntagged ? Object.values(versions)[0] : versionFromRef(tag); +const mismatches = Object.entries(versions) + .filter(([, version]) => version !== expected) + .map(([file, version]) => `${file}=${version}`); + +if (!allowUntagged && mismatches.length > 0) { + console.error(`Release tag ${tag} does not match the application manifests (expected ${expected}).`); + for (const mismatch of mismatches) console.error(` ${mismatch}`); + process.exit(1); +} + +console.log( + allowUntagged + ? `Non-publishing package version ${expected} matches ${Object.keys(versions).length} manifests.` + : `Release version ${expected} matches ${Object.keys(versions).length} manifests.` +); diff --git a/scripts/verify-release-version.node-test.js b/scripts/verify-release-version.node-test.js index d630133..a22ba1c 100644 --- a/scripts/verify-release-version.node-test.js +++ b/scripts/verify-release-version.node-test.js @@ -11,8 +11,8 @@ const currentVersion = JSON.parse( fs.readFileSync(path.join(repositoryRoot, 'package.json'), 'utf8') ).version; -function runVerifier(tag) { - return spawnSync(process.execPath, [verifier, '--tag', tag], { +function runVerifier(tag, ...extraArguments) { + return spawnSync(process.execPath, [verifier, '--tag', tag, ...extraArguments], { cwd: repositoryRoot, encoding: 'utf8', }); @@ -35,3 +35,9 @@ test('release version verifier rejects non-semver tag names', () => { assert.equal(result.status, 1); assert.match(result.stderr, /semantic version tag/); }); + +test('release version verifier accepts an untagged non-publishing package audit', () => { + const result = runVerifier('main', '--allow-untagged'); + assert.equal(result.status, 0, result.stderr); + assert.match(result.stdout, new RegExp(`Non-publishing package version ${currentVersion} matches`)); +});