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
6 changes: 5 additions & 1 deletion .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 5
environment: npm # only main may use it, and npm trusts only this environment
environment: # only main may use it, and npm trusts only this environment
name: npm
url: https://www.npmjs.com/package/claude-code-mods/v/${{ steps.version.outputs.version }}
defaults:
run:
working-directory: cli
Expand All @@ -37,6 +39,8 @@ jobs:
run: |
name=$(node -p "require('./package.json').name")
version=$(node -p "require('./package.json').version")
[[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || { echo "Not a version: $version"; exit 1; }
echo "version=$version" >> "$GITHUB_OUTPUT"
if out=$(npm view "$name@$version" version 2>&1); then
echo "$name@$version is already on npm. Nothing to publish."
echo "new=false" >> "$GITHUB_OUTPUT"
Expand Down
2 changes: 1 addition & 1 deletion test/workflows.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test('only the publish and Pages workflows can mint an OIDC token', () => {

test('the publish workflow runs on main only, in the npm environment', { skip: !existsSync(join(dir, PUBLISHER)) }, () => {
const text = code(readFileSync(join(dir, PUBLISHER), 'utf8'))
assert.match(text, /^\s+environment: npm\b/m, `${PUBLISHER}: the job must use the npm environment`)
assert.match(text, /^( +)environment:[ \t]*(npm|\n\1[ \t]+name: npm)[ \t]*$/m, `${PUBLISHER}: the job must use the npm environment`)
assert.match(text, /branches: \[main\]/, `${PUBLISHER}: publish from main only`)
assert.doesNotMatch(text, /pull_request|workflow_dispatch|registry-url/, `${PUBLISHER}: no PR or manual triggers, no registry-url`)
})
Loading