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

Add GitHub actions for automated NPM release #40

Merged
merged 1 commit into from
Aug 30, 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
29 changes: 0 additions & 29 deletions .github/workflows/node.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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
# registry-url is required to correctly setup authentication per https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
registry-url: 'https://registry.npmjs.org'
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