mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-16 14:28:21 +00:00
fix(release): allow non-publishing branch audits
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.`
|
||||
);
|
||||
|
||||
@@ -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`));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user