Skip to content

Commit 602b6f2

Browse files
committed
🤖 Add NPM publishing with OIDC trusted publishing
- Add GitHub Actions workflow for hybrid NPM publishing - Publishes to 'next' tag on main branch commits - Publishes to 'latest' tag on git tag releases - Uses OIDC trusted publishing (no long-lived tokens) - Includes provenance attestations for supply chain security - Update package.json for NPM publishing - Change package name to @coder/cmux (scoped package) - Add bin field for CLI usage - Add repository and publishConfig fields - Add files array to control what gets published - Add .npmignore to exclude dev/build files from NPM package - Excludes source, tests, docs, build configs - Keeps only dist/ and essential files (README, LICENSE) - Results in smaller package size Generated with cmux
1 parent 88daab3 commit 602b6f2

File tree

3 files changed

+131
-1
lines changed

3 files changed

+131
-1
lines changed

.github/workflows/publish-npm.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish to NPM
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
id-token: write # Required for OIDC trusted publishing
14+
15+
jobs:
16+
publish:
17+
name: Publish to NPM
18+
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0 # Required for git describe to find tags
24+
25+
- uses: ./.github/actions/setup-cmux
26+
27+
- name: Generate version file
28+
run: ./scripts/generate-version.sh
29+
30+
- name: Build application
31+
run: make build
32+
33+
- name: Determine NPM tag
34+
id: npm-tag
35+
run: |
36+
if [[ $GITHUB_REF == refs/tags/* ]]; then
37+
echo "tag=latest" >> $GITHUB_OUTPUT
38+
echo "Publishing as 'latest' tag (stable release)"
39+
else
40+
echo "tag=next" >> $GITHUB_OUTPUT
41+
echo "Publishing as 'next' tag (pre-release from main)"
42+
fi
43+
44+
- name: Publish to NPM
45+
run: npm publish --tag ${{ steps.npm-tag.outputs.tag }} --provenance
46+
env:
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48+

.npmignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Source files
2+
src/
3+
tests/
4+
benchmarks/
5+
6+
# Documentation (use README.md only)
7+
docs/
8+
9+
# Build configs
10+
.github/
11+
.storybook/
12+
*.config.js
13+
*.config.ts
14+
*.config.mjs
15+
Makefile
16+
fmt.mk
17+
tsconfig.json
18+
vite.config.ts
19+
electron-builder.yml
20+
21+
# Development files
22+
.claude/
23+
.vscode/
24+
*.test.ts
25+
*.test.js
26+
*.spec.ts
27+
*.spec.js
28+
.git/
29+
.gitignore
30+
31+
# CI/CD
32+
.circleci/
33+
.travis.yml
34+
.gitlab-ci.yml
35+
36+
# Build outputs (keep only dist/)
37+
build/
38+
release/
39+
coverage/
40+
storybook-static/
41+
*.tsbuildinfo
42+
43+
# OS files
44+
.DS_Store
45+
Thumbs.db
46+
47+
# IDE
48+
.idea/
49+
*.swp
50+
*.swo
51+
*~
52+
53+
# Misc
54+
*.log
55+
npm-debug.log*
56+
yarn-debug.log*
57+
yarn-error.log*
58+
.env
59+
.env.local
60+
.env.*.local
61+
62+
# Keep only dist/ and essential files
63+
# Files to include are controlled by package.json "files" field
64+

package.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
{
2-
"name": "cmux",
2+
"name": "@coder/cmux",
33
"version": "0.3.0",
44
"description": "cmux - coder multiplexer",
55
"main": "dist/main.js",
6+
"bin": {
7+
"cmux": "dist/main.js"
8+
},
69
"license": "AGPL-3.0-only",
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/coder/cmux.git"
13+
},
14+
"publishConfig": {
15+
"access": "public",
16+
"provenance": true
17+
},
718
"scripts": {
819
"dev": "make dev",
920
"prebuild:main": "./scripts/generate-version.sh",
@@ -124,6 +135,13 @@
124135
"vite-plugin-top-level-await": "^1.6.0",
125136
"ws": "^8.18.3"
126137
},
138+
"files": [
139+
"dist/**/*.js",
140+
"dist/**/*.js.map",
141+
"dist/**/*.wasm",
142+
"README.md",
143+
"LICENSE"
144+
],
127145
"build": {
128146
"appId": "com.cmux.app",
129147
"productName": "cmux",

0 commit comments

Comments
 (0)