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..1b4b3eb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: Test +on: [workflow_call, push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set up node + uses: actions/setup-node@v4 + + - name: Install depedencies + run: npm install + + - name: Lint + run: npm run lint + + - name: Build + run: npm run build 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" +}