From 92586b77fd2d66d70435774451e4067174cb34ce Mon Sep 17 00:00:00 2001 From: Jayson Jacobs Date: Thu, 9 Jul 2026 17:12:49 -0600 Subject: [PATCH] ci: publish to npmjs and GitHub Packages; skip already-published versions The publish workflow now publishes each version to both registries so consumers can resolve @missionsquad/x402-proxy from either. Each publish step checks whether the version already exists on its registry and skips instead of failing, so pushes to main that do not bump the version stay green. Adds packages: write permission and the repository field required for GITHUB_TOKEN publishes to GitHub Packages. Co-Authored-By: Claude Fable 5 --- .github/workflows/publish.yaml | 30 +++++++++++++++++++++++++++++- package.json | 4 ++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 87a622d..9623f83 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -12,6 +12,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: read + packages: write steps: - name: Checkout Repository @@ -36,7 +37,34 @@ jobs: - name: Run Tests run: yarn test + # Skip-if-exists guards keep the workflow green when a push to main does + # not bump the version (the same version can never be published twice). - name: Publish to npm - run: npm publish --access public + run: | + VERSION=$(node -p "require('./package.json').version") + if npm view "@missionsquad/x402-proxy@${VERSION}" version >/dev/null 2>&1; then + echo "@missionsquad/x402-proxy@${VERSION} already on registry.npmjs.org — skipping" + else + npm publish --access public + fi env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + # Re-point the generated .npmrc at GitHub Packages for the second publish. + - name: Setup Node.js for GitHub Packages + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://npm.pkg.github.com' + scope: '@missionsquad' + + - name: Publish to GitHub Packages + run: | + VERSION=$(node -p "require('./package.json').version") + if npm view "@missionsquad/x402-proxy@${VERSION}" version >/dev/null 2>&1; then + echo "@missionsquad/x402-proxy@${VERSION} already on npm.pkg.github.com — skipping" + else + npm publish + fi + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 981217f..53c5d6b 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,10 @@ "name": "@missionsquad/x402-proxy", "version": "0.1.2", "description": "TypeScript SDK for x402-protected HTTP and WebSocket proxy endpoints.", + "repository": { + "type": "git", + "url": "git+https://github.com/MissionSquad/x402-proxy.git" + }, "main": "./dist/index.js", "module": "./dist/index.js", "types": "./dist/index.d.ts",