Skip to content

Commit d56774e

Browse files
committed
chore(ci): prerelease pack artifacts and tag-triggered npm release
CI uploads an npm pack tarball per run (PR/main) as a downloadable artifact. New release workflow publishes to npm and attaches the pack to a GitHub Release when v*.*.* tags match package.json version; document NPM_TOKEN and flows in HUMANS and AGENTS.
1 parent a995ed3 commit d56774e

File tree

4 files changed

+121
-2
lines changed

4 files changed

+121
-2
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,40 @@ jobs:
2626

2727
- name: Unit tests
2828
run: bun run test
29+
30+
prerelease-pack:
31+
needs: check
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- uses: oven-sh/setup-bun@v2
37+
with:
38+
bun-version: 1.3.11
39+
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version: "22"
43+
44+
- name: Install dependencies
45+
run: bun install --frozen-lockfile
46+
47+
- name: Build
48+
run: bun run build
49+
50+
- name: Pack npm tarball (prerelease snapshot)
51+
id: pack
52+
run: |
53+
set -euo pipefail
54+
npm pack
55+
SRC=$(ls -t rethunk-mcp-multi-root-git-*.tgz | head -1)
56+
DEST="rethunk-mcp-multi-root-git-prerelease-${{ github.sha }}.tgz"
57+
mv "$SRC" "$DEST"
58+
echo "tarball=$DEST" >> "$GITHUB_OUTPUT"
59+
60+
- uses: actions/upload-artifact@v4
61+
with:
62+
name: npm-pack-prerelease-${{ github.sha }}
63+
path: ${{ steps.pack.outputs.tarball }}
64+
if-no-files-found: error
65+
retention-days: 90

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
concurrency:
9+
group: release-${{ github.ref }}
10+
cancel-in-progress: false
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: oven-sh/setup-bun@v2
21+
with:
22+
bun-version: 1.3.11
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: "22"
27+
registry-url: "https://registry.npmjs.org"
28+
29+
- name: Install dependencies
30+
run: bun install --frozen-lockfile
31+
32+
- name: Build
33+
run: bun run build
34+
35+
- name: Lint and format check
36+
run: bun run check
37+
38+
- name: Unit tests
39+
run: bun run test
40+
41+
- name: Verify git tag matches package.json version
42+
run: |
43+
set -euo pipefail
44+
TAG="${GITHUB_REF#refs/tags/v}"
45+
PKG=$(node -p "require('./package.json').version")
46+
if [ "$TAG" != "$PKG" ]; then
47+
echo "::error::Git tag v$TAG must match package.json version $PKG (publish aborted)."
48+
exit 1
49+
fi
50+
51+
- name: Create tarball for GitHub Release
52+
id: pack
53+
run: |
54+
set -euo pipefail
55+
npm pack
56+
echo "tarball=$(ls -t rethunk-mcp-multi-root-git-*.tgz | head -1)" >> "$GITHUB_OUTPUT"
57+
58+
- name: Publish to npm
59+
run: npm publish --access public
60+
env:
61+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62+
63+
- name: Upload release asset
64+
uses: softprops/action-gh-release@v2
65+
with:
66+
files: ${{ steps.pack.outputs.tarball }}
67+
generate_release_notes: true
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
## Validation and CI
3636

37-
Local: `bun run build` (`rimraf dist && tsc`), `bun run check` (Biome), `bun run test` (`bun test` for [`src/repo-paths.test.ts`](src/repo-paths.test.ts)). CI runs the same after `bun install --frozen-lockfile` (see [`.github/workflows/ci.yml`](.github/workflows/ci.yml)).
37+
Local: `bun run build` (`rimraf dist && tsc`), `bun run check` (Biome), `bun run test` (`bun test` for [`src/repo-paths.test.ts`](src/repo-paths.test.ts)). GitHub Actions runs the same after `bun install --frozen-lockfile` on PRs and `main` ([`.github/workflows/ci.yml`](.github/workflows/ci.yml)), then uploads a **prerelease `npm pack` artifact**. Pushes of tag **`v*.*.*`** matching `package.json` `version` run [`.github/workflows/release.yml`](.github/workflows/release.yml) (npm publish + GitHub Release); see [HUMANS.md](HUMANS.md) Publishing.
3838

3939
Optional [`.githooks/`](.githooks): run **`bun run setup-hooks`** once per clone (`core.hooksPath``.githooks`). **pre-commit** = `check`; **pre-push** = frozen install + build + check. See [HUMANS.md](HUMANS.md) Development.
4040

HUMANS.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,23 @@ bun run setup-hooks # once per clone: use .githooks (pre-commit: check; pre-pu
8686

8787
**Git hooks:** after `setup-hooks`, **pre-commit** runs `bun run check`; **pre-push** runs `bun install --frozen-lockfile`, `bun run build`, `bun run check`, and `bun run test` (same order as CI). Set **`SKIP_GIT_HOOKS=1`** or use **`--no-verify`** to bypass.
8888

89-
**CI:** pull requests run `bun install --frozen-lockfile`, `bun run build`, `bun run check`, and `bun run test` (see `.github/workflows/ci.yml`). Match that locally before opening a PR.
89+
**CI:** [`.github/workflows/ci.yml`](.github/workflows/ci.yml) runs on pull requests and pushes to `main`: `bun install --frozen-lockfile`, `bun run build`, `bun run check`, and `bun run test`. A follow-up job **`prerelease-pack`** builds the same tree and runs **`npm pack`**, then uploads a **prerelease `.tgz` artifact** (named with the commit SHA) you can download from the workflow run’s **Artifacts** section (retention 90 days). Match the check job locally before opening a PR.
9090

9191
## Publishing
9292

93+
### npm (production) — version tags only
94+
95+
Releases to [npmjs](https://www.npmjs.com/package/@rethunk/mcp-multi-root-git) are automated by [`.github/workflows/release.yml`](.github/workflows/release.yml) when you push a **semver git tag** `vX.Y.Z` that **exactly matches** `version` in `package.json` (e.g. tag `v1.2.3` and `"version": "1.2.3"`).
96+
97+
1. Bump **`package.json` `version`**, commit on `main`.
98+
2. Create and push the tag: `git tag vX.Y.Z && git push origin vX.Y.Z`
99+
100+
The workflow runs build, check, and tests, publishes with **`npm publish`**, then creates a **GitHub Release** for that tag and attaches the same **`.tgz`** as a downloadable asset.
101+
102+
**Repository secret:** add **`NPM_TOKEN`** (granular npm access token with publish permission for `@rethunk/mcp-multi-root-git` or the scope). Without it, the publish step fails.
103+
104+
### Local publish (maintainers)
105+
93106
```bash
94107
bun run prepublishOnly # build + check + test
95108
bun publish

0 commit comments

Comments
 (0)