diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6fdf077..cfda70c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -203,13 +203,14 @@ jobs: RELEASE_ID: ${{ needs.create-release.outputs.release_id }} run: gh api --method PATCH "repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID" -F draft=false > /dev/null - # The Node library goes to GitHub Packages. It needs only the checkout, not the desktop builds. + # The Node library goes to the public npm registry. It needs only the checkout, not the desktop builds. publish-npm: - needs: prepare + needs: [prepare, publish] if: needs.prepare.outputs.release == 'true' runs-on: ubuntu-latest env: TAG: ${{ needs.prepare.outputs.tag }} + PUBLIC_REPO: adhil72/gitvault-website steps: - uses: actions/checkout@v4 with: @@ -219,7 +220,7 @@ jobs: with: node-version: 22 cache: pnpm - registry-url: https://npm.pkg.github.com + registry-url: https://registry.npmjs.org - run: pnpm install --frozen-lockfile - name: Check the tag matches the package version run: | @@ -230,10 +231,29 @@ jobs: - name: Publish working-directory: packages/node env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | if npm view "@adhil72/gitvault@${TAG#v}" version >/dev/null 2>&1; then echo "already published" else npm publish fi + # Mirror the library next to the desktop builds in the public repository, + # as a downloadable tarball with its checksum. Needs the release that the + # publish job creates, so this job waits for it. + - name: Attach the library tarball to the public release + working-directory: packages/node + env: + GH_TOKEN: ${{ secrets.WEBSITE_TOKEN }} + run: | + if [ -z "$GH_TOKEN" ]; then + echo "::warning::WEBSITE_TOKEN is not set; the library tarball was not sent to $PUBLIC_REPO" + exit 0 + fi + version="${TAG#v}" + tgz=$(npm pack --silent) + cp "$tgz" "gitvault-node-$version.tgz" + sha256sum "gitvault-node-$version.tgz" > gitvault-node-SHA256SUMS + cat gitvault-node-SHA256SUMS + gh release upload "$TAG" --repo "$PUBLIC_REPO" --clobber \ + "gitvault-node-$version.tgz" gitvault-node-SHA256SUMS diff --git a/packages/node/README.md b/packages/node/README.md index 7e9a5b5..08917fa 100644 --- a/packages/node/README.md +++ b/packages/node/README.md @@ -6,13 +6,7 @@ Load your GitVault secrets into `process.env` at startup. No `.env` files in the ## Install -Published on GitHub Packages. Point the scope at it and sign in with a token that has `read:packages` (and access to the repo): - -```ini -# .npmrc -@adhil72:registry=https://npm.pkg.github.com -//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN} -``` +Published on the public npm registry. No token needed: ```bash npm install @adhil72/gitvault diff --git a/packages/node/package.json b/packages/node/package.json index cfd25ca..b7f288e 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -46,6 +46,7 @@ "directory": "packages/node" }, "publishConfig": { - "registry": "https://npm.pkg.github.com" + "access": "public", + "registry": "https://registry.npmjs.org" } }