Skip to content

Commit e7e63fd

Browse files
committed
chore(ci): update publish workflow for CLI package
- Modified tag pattern to allow for all version tags (v*.*.*) during publishing. - Updated Node.js version from 20 to 24 in the setup step. - Added verification steps for the release environment, ensuring Node.js and npm versions meet the required thresholds. - Implemented checks to verify that the tag commit is on the main branch and that the version is not already published. - Removed provenance flag from npm publish command for a cleaner publish process.
1 parent dcb280e commit e7e63fd

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

.github/workflows/publish-cli.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Publish CLI
33
on:
44
push:
55
tags:
6-
- "v1.0.0-rc.*"
6+
- "v*.*.*"
77

88
permissions:
99
contents: read
@@ -12,6 +12,9 @@ permissions:
1212
jobs:
1313
npm:
1414
runs-on: ubuntu-latest
15+
concurrency:
16+
group: publish-cli-${{ github.ref }}
17+
cancel-in-progress: false
1518
steps:
1619
- uses: actions/checkout@v4
1720
with:
@@ -23,10 +26,17 @@ jobs:
2326

2427
- uses: actions/setup-node@v4
2528
with:
26-
node-version: "20"
29+
node-version: "24"
2730
registry-url: "https://registry.npmjs.org"
2831
cache: "pnpm"
2932

33+
- name: Verify release environment
34+
run: |
35+
node --version
36+
npm --version
37+
node -e "const [major, minor] = process.versions.node.split('.').map(Number); if (major < 22 || (major === 22 && minor < 14)) throw new Error('npm trusted publishing requires Node 22.14.0 or newer')"
38+
node -e "const { execSync } = require('node:child_process'); const [major, minor, patch] = execSync('npm --version', { encoding: 'utf8' }).trim().split('.').map(Number); if (major < 11 || (major === 11 && (minor < 5 || (minor === 5 && patch < 1)))) throw new Error('npm trusted publishing requires npm 11.5.1 or newer')"
39+
3040
- run: pnpm install --frozen-lockfile
3141

3242
- name: Verify tag commit is on main
@@ -35,14 +45,23 @@ jobs:
3545
- name: Verify tag matches CLI package version
3646
run: |
3747
version="$(node -p "require('./apps/cli/package.json').version")"
48+
node -e "const version = process.argv[1]; if (!/^\\d+\\.\\d+\\.\\d+$/.test(version)) throw new Error('Official CLI releases must use a stable semver version')" "$version"
3849
test "v${version}" = "${GITHUB_REF_NAME}"
50+
echo "CLI_VERSION=${version}" >> "$GITHUB_ENV"
51+
52+
- name: Verify version is not already published
53+
run: |
54+
if npm view "@markdown-ai/cli@${CLI_VERSION}" version --registry https://registry.npmjs.org >/dev/null 2>&1; then
55+
echo "@markdown-ai/cli@${CLI_VERSION} is already published"
56+
exit 1
57+
fi
3958
4059
- run: pnpm cli:test
4160

61+
- run: pnpm -C apps/cli smoke:package
62+
4263
- run: npm pack --dry-run --json
4364
working-directory: apps/cli
4465

45-
- run: npm publish --provenance --access public --tag rc
66+
- run: npm publish --access public
4667
working-directory: apps/cli
47-
env:
48-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)