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
38 changes: 38 additions & 0 deletions .github/actions/opendrs-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: opendrs (pinned release)
description: Runs a released opendrs on this repository's own PRs. Used only by .github/workflows/opendrs.yml.

# The pin lives here, not in the workflow, so the "Finish a release" workflow can bump it: a
# workflow's token may not change files under .github/workflows/. opendrs.yml restores this file
# from the PR's base commit before using it, so a PR's edit to it never runs with the bot token.
inputs:
github-token:
description: Token opendrs comments, labels and approves with.
required: true
sample-salt:
description: Salt for the sampled-review hash.
required: false
default: ""
outputs:
score:
description: The PR's risk score.
value: ${{ steps.opendrs.outputs.score }}
tier:
description: The risk tier.
value: ${{ steps.opendrs.outputs.tier }}
decision:
description: The policy verdict, before the safety rails.
value: ${{ steps.opendrs.outputs.decision }}
captain:
description: The captain priority.
value: ${{ steps.opendrs.outputs.captain }}
approved:
description: true only when opendrs approved the head commit in this run.
value: ${{ steps.opendrs.outputs.approved }}
runs:
using: composite
steps:
- uses: error-path/opendrs@541a0cf40f50de3b6b7d25ddf280bc05f6e7dd81 # v0.7.1
id: opendrs
with:
github-token: ${{ inputs.github-token }}
sample-salt: ${{ inputs.sample-salt }}
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ updates:
- package-ecosystem: docker
directory: /
schedule: { interval: weekly }
# Digest and patch bumps only: a new Node major is chosen by hand, and only an LTS (even) one.
ignore:
- dependency-name: node
update-types: ["version-update:semver-major"]
- package-ecosystem: bundler
directory: /docs
schedule: { interval: weekly }
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ permissions:

jobs:
# The job id `check` gives the check names `check (22)` and `check (24)`, which the main
# ruleset requires: renaming it blocks every merge.
# ruleset requires: renaming it blocks every merge. `check (26)`, the newest LTS, is not required.
check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [22, 24]
node: [22, 24, 26]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/opendrs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Dogfood: score this repository's own PRs and approve the low-risk ones (.opendrs.yml), and
# auto-merge only those that are also a captain "quick confirm", once the required checks pass.
# Runs a RELEASED action, pinned to a release commit that Dependabot bumps, never the PR's own
# copy: a PR must not be able to edit the code that decides whether to approve it.
# Runs a RELEASED action, pinned to a release commit in .github/actions/opendrs-release (bumped by
# "Finish a release"), never the PR's own copy: a PR must not be able to edit the code that
# decides whether to approve it.
name: OpenDRS

on:
Expand Down Expand Up @@ -30,6 +31,12 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # required: the score reads past commits, authors and the merge-base
# Run the pinned release from the base branch, never the PR's copy: changing a file under
# .github/actions/ needs only contents write, not the workflows permission a workflow edit needs.
- name: Use the base branch's opendrs pin
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: git checkout "$BASE_SHA" -- .github/actions/opendrs-release
# opendrs comments, labels, approves and merges as the opendrs-bot GitHub App, not as
# github-actions. The token lasts one hour, covers this repository only and is revoked when
# the job ends. Fork PRs get no secrets: they fall back to GITHUB_TOKEN and are never approved.
Expand All @@ -40,7 +47,9 @@ jobs:
with:
client-id: ${{ vars.OPENDRS_APP_CLIENT_ID }}
private-key: ${{ secrets.OPENDRS_APP_PRIVATE_KEY }}
- uses: error-path/opendrs@541a0cf40f50de3b6b7d25ddf280bc05f6e7dd81 # v0.7.1
# The release pin is in this composite action, so "Finish a release" can bump it. A pins PR
# therefore still runs the previous release; the new pin applies from the next PR.
- uses: ./.github/actions/opendrs-release
id: opendrs
with:
github-token: ${{ steps.app-token.outputs.token || github.token }}
Expand Down
83 changes: 64 additions & 19 deletions .github/workflows/release-finish.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
name: Finish a release

# Run by hand after you approve a staged npm version: publishes server.json to the MCP registry,
# then pushes a branch that pins the Claude Code plugin to the version, for you to open as a PR
# (a PR opened by this workflow's token would not start CI). Only the repository owner can run it,
# and it signs in to the registry with the run's OIDC token, so no secret is stored. See
# docs/maintaining.md, "Releasing".
# moves the major tag (v0) to the release so `@v0` users get it, and opens one PR, as opendrs-bot
# so CI runs on it, that pins the Claude Code plugin and this repository's own opendrs step to the
# release. Only the repository owner can run it. The registry login uses the run's OIDC token; the
# only stored secret is the opendrs-bot key, used in the pins job alone. See docs/maintaining.md,
# "Releasing".
on:
workflow_dispatch:
inputs:
tag:
description: "Release tag that npm already serves, such as v0.6.0"
required: true
move-major-tag:
description: "Move the major tag (v0) to this release. Untick for a release with a breaking change: release v1 instead."
type: boolean
default: true

permissions: {}

Expand Down Expand Up @@ -112,36 +117,76 @@ jobs:
"$RUNNER_TEMP/mcp-publisher" publish
echo "### Published $VERSION to the MCP registry" >> "$GITHUB_STEP_SUMMARY"

plugin-pin:
name: Push the plugin pin branch
major-tag:
name: Move the major tag
needs: [check, registry]
# A prerelease never moves it; untick the input for a breaking change.
if: inputs.move-major-tag && !contains(inputs.tag, '-')
runs-on: ubuntu-latest
permissions:
contents: write # to push the branch; the PR is opened by the owner, so CI runs on it
contents: write # to force-push the major tag
env:
TAG: ${{ inputs.tag }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: refs/tags/${{ env.TAG }}
- name: Move the major tag to the release commit
run: |
MAJOR="${TAG%%.*}" # v0.7.1 -> v0
git tag -f "$MAJOR" "$(git rev-parse "refs/tags/$TAG^{commit}")"
git push -f origin "refs/tags/$MAJOR"
echo "### Moved $MAJOR to $TAG" >> "$GITHUB_STEP_SUMMARY"

pins:
name: Open the release pins PR
needs: [check, registry]
runs-on: ubuntu-latest
permissions:
contents: read # the push and the PR use the opendrs-bot token, so CI runs on the PR
env:
TAG: ${{ inputs.tag }}
VERSION: ${{ needs.check.outputs.version }}
BRANCH: chore/plugin-pin-${{ needs.check.outputs.version }}
BRANCH: chore/release-pins-${{ needs.check.outputs.version }}
REPOSITORY: ${{ github.repository }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: main
fetch-depth: 0 # to read the tag's commit
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
- name: Pin the plugin and push the branch
# release.mjs imports only Node's own modules, and nothing is installed in this job.
- name: Pin the plugin and the dogfood action
id: pin
run: |
node scripts/release.mjs pin-plugin "$VERSION"
node scripts/release.mjs pin-dogfood "$VERSION" "$(git rev-parse "refs/tags/$TAG^{commit}")"
if git diff --quiet; then
echo "main already pins $VERSION; no branch to push." | tee -a "$GITHUB_STEP_SUMMARY"
exit 0
echo "main already pins $VERSION; no PR to open." | tee -a "$GITHUB_STEP_SUMMARY"
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
- name: Mint an opendrs-bot token
id: app-token
if: steps.pin.outputs.skip != 'true'
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ vars.OPENDRS_APP_CLIENT_ID }}
private-key: ${{ secrets.OPENDRS_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
- name: Push the branch and open the PR
if: steps.pin.outputs.skip != 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git switch -c "$BRANCH"
git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -am "chore(plugin): pin @error-path/opendrs $VERSION"
git push origin "HEAD:refs/heads/$BRANCH"
{
echo "### Plugin pin branch pushed"
echo
echo "Open the PR: https://github.com/$REPOSITORY/compare/main...$BRANCH?expand=1"
} >> "$GITHUB_STEP_SUMMARY"
git -c user.name="opendrs-bot[bot]" -c user.email="344752653+opendrs-bot[bot]@users.noreply.github.com" \
commit -am "chore(release): pin the plugin and this repository's opendrs to $VERSION"
git push "https://x-access-token:$GH_TOKEN@github.com/$REPOSITORY.git" "HEAD:refs/heads/$BRANCH"
URL=$(gh pr create --repo "$REPOSITORY" --base main --head "$BRANCH" \
--title "chore(release): pin the plugin and this repository's opendrs to $VERSION" \
--body "Opened by **Finish a release** for $TAG: npm serves $VERSION and the MCP registry lists it. Pins the Claude Code plugin's npx calls and the dogfood action (.github/actions/opendrs-release) to the release. Merge when CI passes.")
echo "### Pins PR opened: $URL" >> "$GITHUB_STEP_SUMMARY"
121 changes: 121 additions & 0 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Prepare a release

# Run by hand with the version to release: runs `npm run release:prepare` on main and opens the
# release PR as opendrs-bot, so CI runs on it. Read the changelog section in the PR, then merge it;
# "Tag a release" takes over from there. Only the repository owner can run it. The build job has no
# secret; the bot token is minted in a job that installs and runs no dependency. See
# docs/maintaining.md, "Releasing".
on:
workflow_dispatch:
inputs:
version:
description: "Version to release, without the v, such as 0.7.2"
required: true

permissions: {}

concurrency:
group: release-prepare
cancel-in-progress: false

jobs:
build:
name: Set the version and rebuild the action
runs-on: ubuntu-latest
permissions:
contents: read
env:
VERSION: ${{ inputs.version }}
steps:
- name: Check who started the run
env:
TRIGGERING_ACTOR: ${{ github.triggering_actor }}
OWNER: ${{ github.repository_owner }}
run: |
test "$TRIGGERING_ACTOR" = "$OWNER" \
|| { echo "::error::Only $OWNER can prepare a release, not $TRIGGERING_ACTOR"; exit 1; }
- name: Check that the run is on main
env:
REF: ${{ github.ref }}
run: |
test "$REF" = "refs/heads/main" || { echo "::error::Run this from main, not $REF"; exit 1; }
- name: Check the version
run: |
# The release tag's pattern without the v; [[ =~ ]] matches the whole value.
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::'$VERSION' is not a release version like 1.2.3"
exit 1
fi
# Both jobs check out the commit the run started on, never one the build job names.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
- run: npm ci
- name: Prepare the release
run: |
node scripts/release.mjs prepare "$VERSION"
git diff --binary > "$RUNNER_TEMP/release.patch"
test -s "$RUNNER_TEMP/release.patch" || { echo "::error::release:prepare changed nothing"; exit 1; }
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-patch
path: ${{ runner.temp }}/release.patch
retention-days: 1

pull-request:
name: Open the release PR
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
env:
VERSION: ${{ inputs.version }}
BRANCH: release/${{ inputs.version }}
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-patch
path: ${{ runner.temp }}/release
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
persist-credentials: false
# Only contents and pull-requests: the patch is limited to release:prepare's files below.
- name: Mint an opendrs-bot token
id: app-token
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ vars.OPENDRS_APP_CLIENT_ID }}
private-key: ${{ secrets.OPENDRS_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
- name: Push the branch and open the PR
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
REPOSITORY: ${{ github.repository }}
run: |
git apply --index "$RUNNER_TEMP/release/release.patch"
# The build job ran npm dependencies, so accept only the files release:prepare writes.
UNEXPECTED=$(git diff --cached --name-only | grep -vxE 'package\.json|package-lock\.json|src/version\.ts|server\.json|tests/fixtures/golden-full-score\.json|CHANGELOG\.md|action/dist/.+' || true)
if [ -n "$UNEXPECTED" ]; then
echo "::error::the release patch changes files release:prepare never writes: $UNEXPECTED"; exit 1
fi
git switch -c "$BRANCH"
git -c user.name="opendrs-bot[bot]" -c user.email="344752653+opendrs-bot[bot]@users.noreply.github.com" \
commit -m "chore(release): $VERSION"
git push "https://x-access-token:$GH_TOKEN@github.com/$REPOSITORY.git" "HEAD:refs/heads/$BRANCH"
node scripts/release.mjs notes "$VERSION" > "$RUNNER_TEMP/notes.md"
{
echo "Prepared by the **Prepare a release** workflow (\`npm run release:prepare -- $VERSION\`)."
echo "Read the changelog section below, then merge: **Tag a release** tags the merge commit and drafts the GitHub release."
echo
echo "## Changelog"
echo
cat "$RUNNER_TEMP/notes.md"
} > "$RUNNER_TEMP/body.md"
URL=$(gh pr create --repo "$REPOSITORY" --base main --head "$BRANCH" --title "chore(release): $VERSION" --body-file "$RUNNER_TEMP/body.md")
echo "### Release PR opened: $URL" >> "$GITHUB_STEP_SUMMARY"
Loading
Loading