Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] npm with provenance #599

Merged
merged 2 commits into from
Oct 17, 2023
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
45 changes: 45 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: NATS.js NPM release

on:
release:
types: [created]

jobs:
test:
strategy:
matrix:
node-version: [20.x]
deno-version: [1.36.4]

derekcollison marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- name: Checkout NATS.js
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
- name: Use Deno Version ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
- run: npm install -g npm
- run: npm ci
- run: npm run prepack
- name: Set tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Test tag
run: |
npm run check-package
- run: npm publish --provenance --access public --tag=next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}


18 changes: 18 additions & 0 deletions bin/check-bundle-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,21 @@ if (m.version !== VERSION) {
`[OK] package version and transport version match ${m.version}`,
);
}

let tag = Deno.env.get("RELEASE_VERSION");
if(tag) {
if(tag.startsWith("v")) {
tag = tag.substring(1);
}

if(m.version !== tag) {
console.error(`[ERROR] expected RELEASE_VERSION and package versions to match ${tag} !== ${m.version}`);
Deno.exit(1);
}
console.log(`[OK] RELEASE_VERSION and package versions match ${tag}`);
} else {
console.log(`[SKIP] tag check`);
}


Deno.exit(0);
Loading