fix(ci): skip publish when version already exists on npm (#1166)
Multiple CI completions on the same commit trigger duplicate Pipeline runs. The second run fails with E403 because the version was already published. Fix by checking npm registry before attempting publish, and enable cancel-in-progress to avoid redundant runs. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fb350c270d
commit
6eccae3b4b
1 changed files with 8 additions and 2 deletions
10
.github/workflows/pipeline.yml
vendored
10
.github/workflows/pipeline.yml
vendored
|
|
@ -8,7 +8,7 @@ on:
|
|||
|
||||
concurrency:
|
||||
group: pipeline-${{ github.sha }}
|
||||
cancel-in-progress: false
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
|
@ -51,7 +51,13 @@ jobs:
|
|||
echo "version=$(node -e 'process.stdout.write(require("./package.json").version)')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Publish @dev
|
||||
run: npm publish --tag dev
|
||||
run: |
|
||||
VERSION=$(node -e 'process.stdout.write(require("./package.json").version)')
|
||||
if npm view "gsd-pi@${VERSION}" version 2>/dev/null; then
|
||||
echo "Version ${VERSION} already published — skipping"
|
||||
else
|
||||
npm publish --tag dev
|
||||
fi
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue