Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: |
Expand All @@ -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
8 changes: 1 addition & 7 deletions packages/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"directory": "packages/node"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
"access": "public",
"registry": "https://registry.npmjs.org"
}
}
Loading