From 5cc3fa337183589e3dc8bc5ff0d03a65b57011b0 Mon Sep 17 00:00:00 2001 From: Thibault Meunier Date: Tue, 29 Aug 2023 16:08:21 +0200 Subject: [PATCH] Add GitHub actions for automated NPM release Build, tests, and release via GitHub. NPM_TOKEN is stored as a secret, and scoped to @cloudflare/voprf-ts. --- .github/workflows/node.yml | 29 ------------------------- .github/workflows/release.yml | 35 ++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 41 +++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 29 deletions(-) delete mode 100644 .github/workflows/node.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml deleted file mode 100644 index a942e1b..0000000 --- a/.github/workflows/node.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: VOPRF-TS CI - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - testing: - name: Testing on Node v${{ matrix.node }} - runs-on: ubuntu-latest - strategy: - matrix: - node: [18, 16] - steps: - - name: Checking out - uses: actions/checkout@v3 - - name: Setting up Node v${{ matrix.node }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - cache: 'npm' - - run: npm ci - - run: npm run lint - - run: npm run build - - run: npm test - - run: npm run examples diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7a8a4b6 --- /dev/null +++ b/.github/workflows/release.yml @@ -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//tokens/, generate a "Granular Access Token" scoped to @cloudflare/voprf-ts, and update NPM_TOKEN GitHub secret + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..011f48d --- /dev/null +++ b/.github/workflows/tests.yml @@ -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