Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
with:
node-version: 24.x
- name: Validate tag, package version, and changelog
env:
GITHUB_REF_NAME: ${{ inputs.tag }}
shell: bash
run: |
set -euo pipefail
Expand Down
2 changes: 1 addition & 1 deletion scripts/verify-release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const packageJson = JSON.parse(await readFile(resolve(root, 'package.json'), 'utf8'))
const changelog = await readFile(resolve(root, 'CHANGELOG.md'), 'utf8')
const expectedTag = `v${packageJson.version}`
const actualTag = process.env.GITHUB_REF_NAME ?? process.argv[2]
const actualTag = process.argv[2] ?? process.env.GITHUB_REF_NAME

if (!actualTag) {
throw new Error('Provide a release tag as GITHUB_REF_NAME or the first argument.')
Expand Down
16 changes: 16 additions & 0 deletions test/package-contract.test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import assert from 'node:assert/strict'
import { execFile } from 'node:child_process'
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import { promisify } from 'node:util'
import test from 'node:test'

const execFileAsync = promisify(execFile)

const packageJson = JSON.parse(
await readFile(new URL('../package.json', import.meta.url), 'utf8'),
)
Expand All @@ -20,3 +25,14 @@ test('keeps the runtime dependency-free and declares the tested Node floor', ()
assert.equal(packageJson.optionalDependencies, undefined)
assert.equal(packageJson.peerDependencies, undefined)
})

test('uses an explicit release tag instead of the workflow branch name', async () => {
const verifyScript = fileURLToPath(
new URL('../scripts/verify-release.mjs', import.meta.url),
)
const { stdout } = await execFileAsync(process.execPath, [verifyScript, 'v0.1.1'], {
env: { ...process.env, GITHUB_REF_NAME: 'main' },
})

assert.equal(stdout, 'Verified release metadata for v0.1.1.\n')
})
Loading