Skip to content

Publish to JSR

Publish to JSR #3

Workflow file for this run

name: Publish to JSR
on:
push:
tags:
- "v*.*.*"
- "*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Tag to publish (e.g. v0.3.0)"
required: true
type: string
permissions:
contents: write
id-token: write
concurrency:
group: publish-jsr-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.tag || github.ref }}
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Verify tag matches deno.json version
shell: bash
run: |
set -euo pipefail
raw_tag="${{ inputs.tag || github.ref_name }}"
tag="${raw_tag#v}"
version="$(node -p "require('./deno.json').version")"
if [[ "${tag}" != "${version}" ]]; then
echo "Tag (${raw_tag}) does not match deno.json version (${version})."
exit 1
fi
- name: Format / Lint / Test
run: |
deno fmt --check
deno lint
deno task test
- name: Publish
run: |
# Tokenless publishing requires linking the JSR package to this GitHub repository
# in the package settings on jsr.io, and OIDC enabled via `id-token: write`.
npx jsr publish
- name: Generate release notes
shell: bash
run: |
set -euo pipefail
tag="${{ inputs.tag || github.ref_name }}"
prev_tag="$(
git tag --list "v*" --sort=-version:refname \
| grep -v "^${tag}$" \
| head -n 1 || true
)"
{
echo "# ${tag}"
echo
if [[ -n "${prev_tag}" ]]; then
echo "Changes since ${prev_tag}:"
echo
git log --no-merges --pretty=format:"- %s (%h)" "${prev_tag}..${tag}"
else
echo "Changes:"
echo
git log --no-merges --pretty=format:"- %s (%h)" "${tag}"
fi
echo
} > RELEASE_NOTES.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag || github.ref_name }}
name: ${{ inputs.tag || github.ref_name }}
body_path: RELEASE_NOTES.md