Skip to content

feat: add Node.js support #1

feat: add Node.js support

feat: add Node.js support #1

Workflow file for this run

name: Publish
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-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ inputs.tag || github.ref }}
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 24
package-manager-cache: false
registry-url: https://registry.npmjs.org
- 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="$(deno eval "console.log(JSON.parse(Deno.readTextFileSync('deno.json')).version)")"
if [[ "${tag}" != "${version}" ]]; then
echo "Tag (${raw_tag}) does not match deno.json version (${version})."
exit 1
fi
- name: Check
run: deno task check
- name: Validate npm package
run: deno task check:npm
- name: Publish to JSR
run: deno publish
- name: Pack npm package
run: deno pack --ignore=deno.lock --output dhash.tgz
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish dhash.tgz --access public
- 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@v3
with:
tag_name: ${{ inputs.tag || github.ref_name }}
name: ${{ inputs.tag || github.ref_name }}
body_path: RELEASE_NOTES.md