Skip to content
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
64 changes: 64 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI
run-name: CI run for ${{ github.head_ref }}

on:
pull_request:
branches:
- main
paths-ignore:
- '**/*.md'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linting
run: npm run lint

tsc:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Check TypeScript syntax
run: npx tsc --noEmit

test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test
23 changes: 6 additions & 17 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Publish to npm
run-name: ${{ github.ref_name }} ${{ inputs.dry_run == true && ' (dry-run)' || '' }}
run-name: ${{ github.ref_name }}

on:
workflow_dispatch:
inputs:
dry_run:
type: boolean
description: Run as a dry-run (no publish)
default: true
environment:
type: environment
description: Environment
required: true

permissions:
id-token: write # Required for --provenancepermissions:
id-token: write # Required for --provenance
contents: read
packages: write

Expand All @@ -19,12 +19,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- run: |
if [[ "${{ github.ref }}" != refs/tags/* ]]; then
echo "This workflow can only be run from a tag."
exit 1
fi

- name: Checkout repository
uses: actions/checkout@v4

Expand All @@ -44,12 +38,7 @@ jobs:
id: dist_tag
run: echo "value=$(cat package.json | jq -r '.version | split("-") | .[1] // "latest" | split(".") | .[0]')" >> $GITHUB_OUTPUT

- name: Dry run publish (${{ steps.dist_tag.outputs.value }})
run: npm publish --dry-run --provenance --tag ${{ steps.dist_tag.outputs.value }} --access=public
if: inputs.dry_run == true

- name: Publish to npm
run: npm publish --provenance --tag ${{ steps.dist_tag.outputs.value }} --access=public
if: inputs.dry_run == false
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/publish_dry_run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish to npm dry-run
run-name: Dry-run ${{ github.ref_name }}

on:
workflow_dispatch:

permissions:
id-token: write
contents: read
packages: write

jobs:
publish:
runs-on: ubuntu-latest

steps:
- run: |
if [[ "${{ github.ref }}" != refs/tags/* ]]; then
echo "This workflow can only be run from a tag."
exit 1
fi

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Extract dist tag from version
id: dist_tag
run: echo "value=$(cat package.json | jq -r '.version | split("-") | .[1] // "latest" | split(".") | .[0]')" >> $GITHUB_OUTPUT

- name: Dry run publish (${{ steps.dist_tag.outputs.value }})
run: npm publish --dry-run --provenance --tag ${{ steps.dist_tag.outputs.value }} --access=public