Skip to content

Commit

Permalink
Add GitHub actions for automated NPM release
Browse files Browse the repository at this point in the history
Build, tests, and release via GitHub.
NPM_TOKEN is stored as a secret, and scoped to @cloudflare/voprf-ts.
  • Loading branch information
thibmeu committed Aug 29, 2023
1 parent 96485c4 commit 5cc3fa3
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 29 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/node.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on:
release:
types:
- published

jobs:
release:
if: ${{ github.repository_owner == 'cloudflare' }}
name: Publishing to npmjs registry
runs-on: ubuntu-latest
steps:
- name: Checking out
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'

- name: Install NPM dependencies
run: npm ci

- name: Check build
run: npm run build

- name: Publish to npmjs
run: npm publish
env:
# To create a new token, go to https://www.npmjs.com/settings/<user>/tokens/, generate a "Granular Access Token" scoped to @cloudflare/voprf-ts, and update NPM_TOKEN GitHub secret
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
testing:
name: Testing on Node v${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
matrix:
node: [20, 18]
steps:
- name: Checking out
uses: actions/checkout@v3

- name: Use Node.js v${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'

- name: Install NPM dependencies
run: npm ci

- name: Check lint
run: npm run lint

- name: Check build
run: npm run build

- name: Run NPM tests
run: npm test

- name: Check examples
run: npm run examples

0 comments on commit 5cc3fa3

Please sign in to comment.