Skip to content

Commit 76ab30c

Browse files
gregrewebclaude
authored
chore: add npm publish workflow and release script (#499)
* chore: add npm publish workflow and release script - GitHub Actions workflow publishes all packages to npm on `v*` tag push (requires NPM_TOKEN secret) - scripts/release.sh bumps versions across all packages, commits, and creates the tag Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: use npm OIDC Trusted Publisher instead of token No NPM_TOKEN secret needed — npm verifies trust via OIDC. Uses npm publish directly (Yarn 4 doesn't support OIDC) with --provenance. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: address release script issues from Copilot review - Also bump gl-react pin in devDependencies (where it actually lives) - Guard against uncommitted changes before mutating package.json files - Quote dirname path to handle spaces in repo path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: greweb <greweb@protonmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7c834d4 commit 76ab30c

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: 24
19+
registry-url: 'https://registry.npmjs.org'
20+
21+
- run: corepack enable
22+
- run: yarn install
23+
- run: yarn build
24+
25+
- name: Publish packages
26+
run: |
27+
for pkg in gl-react gl-react-dom gl-react-expo gl-react-headless gl-react-native; do
28+
cd packages/$pkg && npm publish --provenance && cd ../..
29+
done

scripts/release.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
set -e
3+
4+
VERSION=$1
5+
if [ -z "$VERSION" ]; then
6+
echo "Usage: $0 <version>"
7+
echo "Example: $0 5.3.0"
8+
exit 1
9+
fi
10+
11+
cd "$(dirname "$0")/.."
12+
13+
if ! git diff --quiet || ! git diff --cached --quiet; then
14+
echo "Error: working tree has uncommitted changes. Please commit or stash them first."
15+
exit 1
16+
fi
17+
18+
PACKAGES="packages/gl-react packages/gl-react-dom packages/gl-react-expo packages/gl-react-headless packages/gl-react-native"
19+
20+
for pkg in $PACKAGES; do
21+
node -e "
22+
const fs = require('fs');
23+
const p = '$pkg/package.json';
24+
const d = JSON.parse(fs.readFileSync(p, 'utf8'));
25+
d.version = '$VERSION';
26+
['dependencies', 'devDependencies'].forEach(section => {
27+
if (d[section]) {
28+
if (d[section]['gl-react']) d[section]['gl-react'] = '^$VERSION';
29+
if (d[section]['gl-react-expo']) d[section]['gl-react-expo'] = '^$VERSION';
30+
}
31+
});
32+
fs.writeFileSync(p, JSON.stringify(d, null, 2) + '\n');
33+
"
34+
echo "Bumped $pkg to $VERSION"
35+
done
36+
37+
git add packages/gl-react/package.json packages/gl-react-dom/package.json packages/gl-react-expo/package.json packages/gl-react-headless/package.json packages/gl-react-native/package.json
38+
git commit -m "chore: release $VERSION"
39+
git tag "v$VERSION"
40+
41+
echo ""
42+
echo "Done. Now push to trigger the publish workflow:"
43+
echo " git push && git push --tags"

0 commit comments

Comments
 (0)