From b5b3014d4d92c435596d4d37d2677773862a0381 Mon Sep 17 00:00:00 2001 From: Phil Leggetter Date: Tue, 7 May 2024 11:42:18 +0100 Subject: [PATCH 1/3] chore: add test and release to CI --- .github/workflows/release.yml | 81 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 29 +++++++++++++ jsr.json | 5 +++ 3 files changed, 115 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 jsr.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8f34e63 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +name: Release + +on: + release: + types: [published] + + workflow_dispatch: + +jobs: + tests: + uses: ./.github/workflows/tests.yml + + publish-npm: + needs: [tests] + if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'release' && contains(github.ref, 'refs/tags/')) + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set up node + uses: actions/setup-node@v4 + + - name: Install dependencies + run: yarn install + + - name: Build + run: yarn build + + - name: Publish to npm + run: | + npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} + npm publish --access public + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + publish-jsr: + needs: [tests] + if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'release' && contains(github.ref, 'refs/tags/')) + runs-on: ubuntu-latest + + permissions: + contents: write + id-token: write + + steps: + - uses: actions/checkout@v4 + with: + ref: main + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install dependencies + run: yarn install + + - name: Build + run: yarn build + + - name: Get NPM version + id: package-version + uses: martinbeentjes/npm-get-version-action@v1.3.1 + + - name: Update JSR version + uses: jossef/action-set-json-field@v2.1 + with: + file: jsr.json + field: version + value: ${{ steps.package-version.outputs.current-version}} + + - name: Commit JSR version + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + message: 'Update JSR version to ${{ steps.package-version.outputs.current-version}}' + add: 'jsr.json' + + - name: Publish package + run: npx jsr publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e89697a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Test +on: [workflow_call, push] + +jobs: + compile: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set up node + uses: actions/setup-node@v4 + + - name: Compile + run: yarn && yarn build + + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up node + uses: actions/setup-node@v3 + + - name: Compile + run: yarn && yarn test diff --git a/jsr.json b/jsr.json new file mode 100644 index 0000000..d0958dd --- /dev/null +++ b/jsr.json @@ -0,0 +1,5 @@ +{ + "name": "@hookdeck/vercel", + "version": "0.1.4", + "exports": "./index.ts" +} From cb9098552e4e80dbcd912862544815d4f0f6bbb3 Mon Sep 17 00:00:00 2001 From: Phil Leggetter Date: Tue, 7 May 2024 11:54:32 +0100 Subject: [PATCH 2/3] chore(CI): update to NPM lint and build --- .github/workflows/test.yml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e89697a..c5ad67a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: Test on: [workflow_call, push] jobs: - compile: + build: runs-on: ubuntu-latest steps: @@ -12,18 +12,8 @@ jobs: - name: Set up node uses: actions/setup-node@v4 - - name: Compile - run: yarn && yarn build + - name: Lint + run: npm run lint - test: - runs-on: ubuntu-latest - - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Set up node - uses: actions/setup-node@v3 - - - name: Compile - run: yarn && yarn test + - name: Build + run: npm run build From 7133128dde9f52d4277134380af76a1bfc91942b Mon Sep 17 00:00:00 2001 From: Phil Leggetter Date: Tue, 7 May 2024 11:57:19 +0100 Subject: [PATCH 3/3] chore(CI): install deps in test.yml --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c5ad67a..1b4b3eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,9 @@ jobs: - name: Set up node uses: actions/setup-node@v4 + - name: Install depedencies + run: npm install + - name: Lint run: npm run lint