Skip to content

Commit 880e07e

Browse files
committed
feat(release): add sklt npm publish flow
1 parent df45f08 commit 880e07e

9 files changed

Lines changed: 122 additions & 15 deletions

File tree

‎.github/workflows/npm-publish.yaml‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: npm Publish
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch:
8+
inputs:
9+
ref:
10+
description: Git ref to publish, usually a release tag like v1.0.0
11+
required: true
12+
type: string
13+
npm_tag:
14+
description: npm dist-tag to publish under
15+
required: false
16+
default: latest
17+
type: string
18+
dry_run:
19+
description: Run npm publish in dry-run mode without uploading
20+
required: false
21+
default: false
22+
type: boolean
23+
24+
permissions:
25+
contents: read
26+
27+
concurrency:
28+
group: npm-publish-${{ github.event_name == 'release' && github.event.release.tag_name || inputs.ref }}
29+
cancel-in-progress: false
30+
31+
jobs:
32+
publish:
33+
runs-on: ubuntu-latest
34+
environment: npm-publish
35+
36+
env:
37+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
42+
with:
43+
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || inputs.ref }}
44+
45+
- name: Setup Node.js
46+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
47+
with:
48+
node-version: 20
49+
registry-url: https://registry.npmjs.org
50+
51+
- name: Setup mise
52+
uses: jdx/mise-action@c37c93293d6b742fc901e1406b8f764f6fb19dac
53+
54+
- name: Install dependencies
55+
run: mise run install
56+
57+
- name: Validate npm package
58+
run: mise run npm-smoke
59+
60+
- name: Check published version
61+
id: package
62+
shell: bash
63+
run: |
64+
set -euo pipefail
65+
PACKAGE_NAME=$(node --print "require('./package.json').name")
66+
PACKAGE_VERSION=$(node --print "require('./package.json').version")
67+
if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version --registry=https://registry.npmjs.org >/dev/null 2>&1; then
68+
echo "published=true" >> "$GITHUB_OUTPUT"
69+
echo "${PACKAGE_NAME}@${PACKAGE_VERSION} is already published; skipping."
70+
else
71+
echo "published=false" >> "$GITHUB_OUTPUT"
72+
fi
73+
74+
- name: Dry run publish
75+
if: github.event_name == 'workflow_dispatch' && inputs.dry_run
76+
env:
77+
NPM_DIST_TAG: ${{ inputs.npm_tag == 'latest' && 'dry-run' || inputs.npm_tag }}
78+
run: mise run npm-publish-dry-run
79+
80+
- name: Publish package
81+
if: steps.package.outputs.published != 'true' && !(github.event_name == 'workflow_dispatch' && inputs.dry_run)
82+
run: npm publish --access public --tag "${{ github.event_name == 'workflow_dispatch' && inputs.npm_tag || 'latest' }}"

‎.github/workflows/release-please.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ jobs:
2020
uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38
2121
with:
2222
token: ${{ secrets.RELEASE_PLEASE_TOKEN || github.token }}
23-
command: manifest
2423
config-file: release-please-config.json
2524
manifest-file: .release-please-manifest.json

‎.mise.toml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ run = "bun install"
1111
run = "mise run install && bunx vitest run"
1212

1313
[tasks.ci]
14-
run = "mise run test"
14+
run = "mise run test && mise run npm-publish-dry-run"
1515

1616
[tasks.build]
1717
run = "mise run install && bun scripts/build-release.ts"
@@ -32,4 +32,7 @@ run = "mise run build -- --targets=linux-x64-musl,linux-arm64-musl && docker bui
3232
run = "mise run install && bun scripts/build-npm-cli.ts"
3333

3434
[tasks.npm-smoke]
35-
run = "mise run build-npm && npm pack >/tmp/skillet-npm-pack.log && PACKAGE=$(tail -n 1 /tmp/skillet-npm-pack.log) && npx --yes --package \"./$PACKAGE\" skillet --help && REPO_DIR=\"$PWD\" && TMP_DIR=$(mktemp -d) && (cd \"$TMP_DIR\" && bun init -y >/dev/null 2>&1 && bun add \"$REPO_DIR/$PACKAGE\" >/dev/null && bunx --bun skillet --help) && rm -rf \"$TMP_DIR\" \"$PACKAGE\""
35+
run = "mise run build-npm && npm pack >/tmp/skillet-npm-pack.log && PACKAGE=$(tail -n 1 /tmp/skillet-npm-pack.log) && npx --yes --package \"./$PACKAGE\" sklt --help && REPO_DIR=\"$PWD\" && TMP_DIR=$(mktemp -d) && (cd \"$TMP_DIR\" && bun init -y >/dev/null 2>&1 && bun add \"$REPO_DIR/$PACKAGE\" >/dev/null && bunx --bun sklt --help) && rm -rf \"$TMP_DIR\" \"$PACKAGE\""
36+
37+
[tasks.npm-publish-dry-run]
38+
run = "mise run build-npm && DIST_TAG=${NPM_DIST_TAG:-dry-run} && npm publish --dry-run --access public --tag \"$DIST_TAG\""

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Skillet installs, discovers, and updates `SKILL.md`-based skills across supporte
1212
| Homebrew | `brew install skillet` | Configured |
1313
| Chocolatey | `choco install skillet` | Configured |
1414
| winget | `winget install skillet` | Configured |
15-
| npm / npx | `npx skillet ...` | Configured |
15+
| npm / npx | `npx sklt ...` | Configured |
1616
| Docker | `docker run ... skillet ...` | Configured |
1717
| Local dev | `mise run dev -- --help` | Available |
1818

‎docs/distribution/npm.md‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,49 @@
22

33
Skillet publishes an npm package so users can run:
44

5-
- `npx skillet ...`
6-
- `bunx skillet ...`
5+
- `npx sklt ...`
6+
- `bunx sklt ...`
77

88
## Packaging Model
99

1010
- `src/cli.ts` is bundled to `dist/npm/cli.js` targeting Node.
11-
- `package.json` `bin.skillet` points to `dist/npm/cli.js`.
11+
- `package.json` exposes `sklt` pointing to `dist/npm/cli.js`.
1212
- `prepack` rebuilds the npm CLI bundle automatically.
1313

1414
## Local Validation
1515

1616
```bash
1717
mise run build-npm
1818
npm pack
19-
npx --yes --package ./skillet-<version>.tgz skillet --help
20-
bunx --bun --package ./skillet-<version>.tgz skillet --help
19+
npx --yes --package ./sklt-<version>.tgz sklt --help
20+
bunx --bun --package ./sklt-<version>.tgz sklt --help
21+
mise run npm-publish-dry-run
2122
```
2223

2324
## Publish
2425

2526
```bash
2627
npm publish --access public
2728
```
29+
30+
## GitHub Actions Publish
31+
32+
- Automatic publish runs from `.github/workflows/npm-publish.yaml` when a GitHub release is published.
33+
- Manual publish is available through `workflow_dispatch`; provide an explicit git ref, usually a release tag like `v1.0.0`.
34+
- Manual publish also supports a dry run so you can inspect the package contents without uploading to npm.
35+
- `mise run ci` now includes the npm publish dry run so package publishing is validated in CI before release.
36+
- The workflow uses the GitHub Actions environment `npm-publish`.
37+
- Add `NPM_TOKEN` as an environment secret in `npm-publish` using the value from your local `.env`.
38+
- GitHub Actions cannot read your local `.env` file directly.
39+
40+
Manual dispatch inputs:
41+
42+
- `ref`: tag, branch, or commit to publish
43+
- `npm_tag`: npm dist-tag, defaults to `latest`
44+
- `dry_run`: when true, runs `npm publish --dry-run` and skips the real publish step
45+
- When `dry_run` is true, the workflow uses the provided `npm_tag`, or falls back to `dry-run` if you leave it at `latest`.
46+
47+
Local command:
48+
49+
- `mise run npm-publish-dry-run`: builds the npm CLI bundle and runs `npm publish --dry-run --tag dry-run`
50+
- Override the dry-run tag if needed with `NPM_DIST_TAG=<tag> mise run npm-publish-dry-run`

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "skillet",
2+
"name": "sklt",
33
"version": "0.0.0",
44
"private": false,
55
"type": "module",
@@ -11,7 +11,7 @@
1111
"README.md"
1212
],
1313
"bin": {
14-
"skillet": "dist/npm/cli.js"
14+
"sklt": "dist/npm/cli.js"
1515
},
1616
"scripts": {
1717
"dev": "bun src/cli.ts",

‎src/cli.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const COMMAND_HELP: Record<CommandName, string> = {
3939
"generate-lock": "Generate skillet.lock.yaml",
4040
};
4141

42-
const cli = cac("skillet");
42+
const cli = cac("sklt");
4343
const GLOBAL_FLAGS = new Set(["-y", "--yes", "--verbose", "-v", "--version", "-h", "--help"]);
4444

4545
cli

‎tests/cli.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("cli", () => {
2525

2626
expect(result.status).toBe(0);
2727
expect(result.stdout).toContain("Usage:");
28-
expect(result.stdout).toContain("$ skillet find [...args]");
28+
expect(result.stdout).toContain("$ sklt find [...args]");
2929
});
3030

3131
test("prints version from environment override", () => {
@@ -37,7 +37,7 @@ describe("cli", () => {
3737
});
3838

3939
expect(result.status).toBe(0);
40-
expect(result.stdout).toContain("skillet/1.2.3");
40+
expect(result.stdout).toContain("sklt/1.2.3");
4141
});
4242

4343
test("returns clear error for unknown command", () => {

‎tests/distribution/npm-package.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ describe("npm package bundle", () => {
1717

1818
expect(result.status).toBe(0);
1919
expect(result.stdout).toContain("Usage:");
20-
expect(result.stdout).toContain("$ skillet <command> [options]");
20+
expect(result.stdout).toContain("$ sklt <command> [options]");
2121
});
2222
});

0 commit comments

Comments
 (0)