Skip to content

Open-source SEO, GEO, and marketing skills for AI agents.

ci: auto-publish notfair to npm on version bumps

Yuting Zhong6f47c4c4f8a2
diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml
new file mode 100644
index 00000000..c5a095e4
--- /dev/null
+++ b/.github/workflows/npm-publish.yml
@@ -0,0 +1,70 @@
+name: Publish notfair to npm
+
+# Publishes the app when notfair/package.json lands on main with a version
+# that isn't on the registry yet. Bump the version in a normal commit and
+# push — no tags or releases to manage. Re-runs on an already-published
+# version are a clean no-op, so this is safe on every push to notfair/**.
+on:
+ push:
+ branches: [main]
+ paths:
+ - "notfair/**"
+ workflow_dispatch:
+
+concurrency:
+ group: npm-publish
+ cancel-in-progress: false
+
+jobs:
+ publish:
+ # macOS ARM64 is load-bearing: the package declares darwin/arm64 and the
+ # standalone bundle ships native prebuilds (better-sqlite3, keytar).
+ # Building on Linux would publish binaries no supported machine can load.
+ runs-on: macos-14
+ defaults:
+ run:
+ working-directory: notfair
+ env:
+ # notfair/.npmrc reads ${NPM_TOKEN}; npm hard-errors if it's unset.
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: pnpm/action-setup@v4
+ with:
+ version: 10
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 24
+
+ - name: Skip if this version is already on npm
+ id: version
+ run: |
+ LOCAL=$(node -p "require('./package.json').version")
+ PUBLISHED=$(npm view notfair version 2>/dev/null || echo "none")
+ echo "local=$LOCAL published=$PUBLISHED"
+ echo "local=$LOCAL" >> "$GITHUB_OUTPUT"
+ if [ "$LOCAL" = "$PUBLISHED" ]; then
+ echo "skip=true" >> "$GITHUB_OUTPUT"
+ fi
+
+ - name: Install
+ if: steps.version.outputs.skip != 'true'
+ run: pnpm install --frozen-lockfile
+
+ - name: Typecheck
+ if: steps.version.outputs.skip != 'true'
+ run: pnpm typecheck
+
+ - name: Test
+ if: steps.version.outputs.skip != 'true'
+ run: pnpm test
+
+ - name: Build
+ if: steps.version.outputs.skip != 'true'
+ run: pnpm build
+
+ - name: Publish ${{ steps.version.outputs.local }}
+ if: steps.version.outputs.skip != 'true'
+ run: npm publish