a7b42da7a0
Avoids 403 E403 "cannot publish over previously published version" error when pushing non-version-bump commits to master. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.5 KiB
YAML
51 lines
1.5 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "20"
|
|
cache: "npm"
|
|
- run: npm ci
|
|
- run: npm run typecheck
|
|
- run: npm test
|
|
|
|
publish:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
permissions:
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "20"
|
|
cache: "npm"
|
|
- run: npm ci
|
|
- run: npm run build
|
|
- name: Check if version already published
|
|
id: version-check
|
|
run: |
|
|
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
|
PUBLISHED_VERSION=$(npm view @farhoodliquor/paperclip-adapter-opencode-k8s version 2>/dev/null || echo "")
|
|
echo "Current: $CURRENT_VERSION, Published: $PUBLISHED_VERSION"
|
|
if [ "$CURRENT_VERSION" = "$PUBLISHED_VERSION" ]; then
|
|
echo "already_published=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "already_published=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
|
|
if: steps.version-check.outputs.already_published == 'false'
|
|
- run: npm publish --access public
|
|
if: steps.version-check.outputs.already_published == 'false'
|