Skip to content

Commit

Permalink
chore: add test and release to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
leggetter committed May 7, 2024
1 parent cc09ffc commit b5b3014
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- name: Update JSR version
uses: jossef/[email protected]
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
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@hookdeck/vercel",
"version": "0.1.4",
"exports": "./index.ts"
}

0 comments on commit b5b3014

Please sign in to comment.