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
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Dependabot opens a pull request when a dependency or an action has a new
# version, and right away when one has a security fix.
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
# One pull request for the tools the library is built and tested with.
development:
dependency-type: development
# A change to a runtime dependency gets a pull request of its own.
open-pull-requests-limit: 5
ignore:
# Node's types follow the Node in .node-version, not the newest one.
- dependency-name: "@types/node"
update-types: ["version-update:semver-major"]
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
18 changes: 11 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .node-version
cache: pnpm
Expand All @@ -43,15 +45,17 @@ jobs:
matrix:
node: ["22.12", "24"]
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- uses: actions/setup-node@v7
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
- run: node --version
Expand Down
90 changes: 70 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,92 @@
# Publishes to npm when a version tag (v1.3.1) is pushed. npm's trusted
# Publishes to npm when a version tag (v1.0.0) is pushed. npm's trusted
# publishing authenticates this workflow through OIDC, so no token is stored,
# and the package gets a provenance statement. The package's trusted
# publisher on npmjs.com must name this repository and this file.
#
# Three jobs, each with only the permission it needs: the one that runs the
# toolchain (the build, the lint, the tests) can neither publish nor write to
# the repository, and the one that can publish runs no code of the project's.
name: Publish

on:
push:
tags: ["v*"]

permissions:
# contents: write lets the job create the GitHub release.
contents: write
id-token: write
permissions: {}

jobs:
publish:
name: Publish to npm
build:
name: Check and pack
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# The whole history, to see that the tag is on main.
fetch-depth: 0
persist-credentials: false
- name: Check the tag is a commit of main
run: git merge-base --is-ancestor "$GITHUB_SHA" origin/main
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .node-version
registry-url: https://registry.npmjs.org
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Check the tag matches the package version
run: test "v$(node -p 'require("./package.json").version')" = "$GITHUB_REF_NAME"
# prepublishOnly runs every check, the tests, the build and the
# package checks first.
- run: npm publish
- name: Create the GitHub release from the changelog
env:
GH_TOKEN: ${{ github.token }}
# Every check, the tests, the build and the package checks.
- run: pnpm run prepublishOnly
- run: pnpm pack --pack-destination release
- name: Take the release notes from the changelog
run: |
version="${GITHUB_REF_NAME#v}"
awk -v heading="## ${version}" '$0 == heading { found = 1; next } found && /^## / { exit } found { print }' CHANGELOG.md > notes.md
test -s notes.md
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file notes.md
awk -v heading="## ${version}" '$0 == heading { found = 1; next } found && /^## / { exit } found { print }' CHANGELOG.md > release/notes.md
test -s release/notes.md
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release
path: release
if-no-files-found: error

publish:
name: Publish to npm
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
# For npm's trusted publishing, and nothing else.
id-token: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release
path: release
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
registry-url: https://registry.npmjs.org
# The tarball the first job packed, as it is: no script of the
# package's runs here.
# The path starts with ./ so npm reads it as a file: "release/x.tgz"
# alone is its shorthand for a GitHub repository.
- run: npm publish ./release/*.tgz --ignore-scripts

release:
name: Create the GitHub release
needs: publish
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release
path: release
- env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file release/notes.md
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Every change reaches `main` through a pull request, merged with a squash once CI

## Releases

Bump `version` in `package.json` and add its entry to `CHANGELOG.md`, then push a `vX.Y.Z` tag that matches. `.github/workflows/publish.yml` publishes it with npm's trusted publishing and a provenance statement; no token is stored anywhere. A breaking change to what any function accepts is a major version.
Bump `version` in `package.json` and add its entry to `CHANGELOG.md`, then push a `vX.Y.Z` tag that matches. `.github/workflows/publish.yml` publishes it with npm's trusted publishing and a provenance statement; no token is stored anywhere. The workflow has three jobs with one permission each: the job that runs the toolchain can't publish, and the job that publishes runs none of the project's code. Every action in a workflow is pinned to a full commit SHA, with its version in a comment; Dependabot moves them. A breaking change to what any function accepts is a major version.
Loading