Skip to content

Commit 605ad94

Browse files
authored
fix(🐙): automatic publishing (#396)
1 parent ec09321 commit 605ad94

9 files changed

Lines changed: 3276 additions & 100 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ jobs:
5252
- name: Build packages
5353
run: yarn turbo run build --filter='./packages/*'
5454

55+
# Validate the semantic-release config without publishing, so a broken
56+
# .releaserc or publish script is caught on PRs rather than at release time.
57+
- name: Release dry run
58+
working-directory: packages/webgpu
59+
run: yarn semantic-release --dry-run
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
YARN_NPM_AUTH_TOKEN: ''
63+
NPM_TOKEN: ''
64+
5565
# Build the docs site the same way the Pages deploy does (GITHUB_PAGES set,
5666
# so the project base path is applied) to catch broken links / build
5767
# regressions before they reach main.

.github/workflows/publish-npm.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Create a release
2+
on: workflow_dispatch
3+
4+
concurrency:
5+
group: release-${{ github.ref }}
6+
cancel-in-progress: false
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # to push tags and create the GitHub release
13+
issues: write # to comment on released issues
14+
pull-requests: write # to comment on released pull requests
15+
id-token: write # to mint the OIDC token for npm provenance / trusted publishing
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # semantic-release needs full history and tags
21+
22+
- name: Setup
23+
uses: ./.github/actions/setup
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
# Tokenless trusted publishing requires npm >= 11.5; Node 22 ships npm 10.
28+
- name: Upgrade npm
29+
run: npm install -g npm@latest
30+
31+
- name: Build packages
32+
run: yarn turbo run build --filter='./packages/*'
33+
34+
- name: Release
35+
working-directory: packages/webgpu
36+
run: yarn release
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
# Trusted publishing authenticates via the OIDC id-token, so no npm
40+
# token is needed. These are set empty so semantic-release-yarn's
41+
# verifyConditions step does not trip on a missing token.
42+
YARN_NPM_AUTH_TOKEN: ''
43+
NPM_TOKEN: ''
44+
NPM_CONFIG_PROVENANCE: true

apps/example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3074,7 +3074,7 @@ SPEC CHECKSUMS:
30743074
React-microtasksnativemodule: 75b6604b667d297292345302cc5bfb6b6aeccc1b
30753075
react-native-safe-area-context: c00143b4823773bba23f2f19f85663ae89ceb460
30763076
react-native-skia: fc73e9bdc46ebb420a98c9c2be29fee80f565e79
3077-
react-native-webgpu: 02d51c1d86e4d653de06bdc954d2f693dcead7a5
3077+
react-native-webgpu: 7a604a7936a2e3fdc93bd48813bcba0165ada8cc
30783078
React-NativeModulesApple: 879fbdc5dcff7136abceb7880fe8a2022a1bd7c3
30793079
React-oscompat: 93b5535ea7f7dff46aaee4f78309a70979bdde9d
30803080
React-perflogger: 5536d2df3d18fe0920263466f7b46a56351c0510

apps/example/metro.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ const getWebMetroConfig = require('./getWebMetroConfig');
55
const root = path.resolve(__dirname, '../..');
66
const threePackagePath = path.resolve(root, 'node_modules/three');
77

8-
const r3fPath = path.resolve(root, "node_modules/@react-three/fiber");
8+
// @react-three/fiber may be hoisted to the monorepo root or kept in the app's
9+
// own node_modules, so resolve it instead of assuming a fixed location.
10+
const r3fPath = path.dirname(
11+
require.resolve("@react-three/fiber/package.json"),
12+
);
913
const defaultConfig = getDefaultConfig(__dirname);
1014

1115
const customConfig = {

packages/webgpu-shim/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-wgpu",
3-
"version": "0.5.15",
3+
"version": "0.0.0-development",
44
"description": "Shim that re-exports react-native-webgpu under its previous package name",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
@@ -34,7 +34,9 @@
3434
},
3535
"homepage": "https://github.com/wcandillon/react-native-webgpu#readme",
3636
"publishConfig": {
37-
"registry": "https://registry.npmjs.org/"
37+
"registry": "https://registry.npmjs.org/",
38+
"access": "public",
39+
"provenance": true
3840
},
3941
"dependencies": {
4042
"react-native-webgpu": "*"

packages/webgpu/.releaserc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
[
7+
"semantic-release-yarn",
8+
{
9+
"npmPublish": false,
10+
"tarballDir": "dist"
11+
}
12+
],
13+
[
14+
"@semantic-release/exec",
15+
{
16+
"publishCmd": "bash scripts/release/publish.sh ${nextRelease.version} ${nextRelease.channel || 'latest'}"
17+
}
18+
],
19+
[
20+
"@semantic-release/github",
21+
{
22+
"assets": [
23+
{ "path": "dist/*.tgz", "label": "Package tarball" }
24+
]
25+
}
26+
]
27+
]
28+
}

packages/webgpu/package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-webgpu",
3-
"version": "0.5.15",
3+
"version": "0.0.0-development",
44
"description": "React Native WebGPU",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
@@ -27,6 +27,7 @@
2727
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache --fix",
2828
"tsc": "tsc --noEmit",
2929
"build": "bob build",
30+
"release": "semantic-release",
3031
"build-dawn": "tsx scripts/build/dawn.ts",
3132
"clean-dawn": "rimraf ./libs && rimraf ../../externals/dawn/out",
3233
"clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common",
@@ -53,9 +54,15 @@
5354
},
5455
"homepage": "https://wcandillon.github.io/react-native-webgpu/",
5556
"publishConfig": {
56-
"registry": "https://registry.npmjs.org/"
57+
"registry": "https://registry.npmjs.org/",
58+
"access": "public",
59+
"provenance": true
5760
},
5861
"devDependencies": {
62+
"@semantic-release/commit-analyzer": "^13.0.0",
63+
"@semantic-release/exec": "^7.0.3",
64+
"@semantic-release/github": "^10.3.3",
65+
"@semantic-release/release-notes-generator": "^14.0.1",
5966
"@types/jest": "^29.5.12",
6067
"@types/lodash": "^4.17.5",
6168
"@types/node": "^20.14.7",
@@ -87,6 +94,8 @@
8794
"react-native-worklets": "0.8.3",
8895
"rimraf": "^5.0.7",
8996
"seedrandom": "^3.0.5",
97+
"semantic-release": "^24.1.0",
98+
"semantic-release-yarn": "^3.0.2",
9099
"teapot": "^1.0.0",
91100
"ts-morph": "^22.0.0",
92101
"tsx": "^4.20.5",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Invoked by @semantic-release/exec (publishCmd) with the resolved version and
4+
# dist-tag channel. semantic-release-yarn has already bumped
5+
# packages/webgpu/package.json to $VERSION and packed the tarball into dist/.
6+
#
7+
# Publishes react-native-webgpu and its react-native-wgpu shim to npm in
8+
# lockstep, both with provenance via the workflow's OIDC token (no NPM token).
9+
set -euo pipefail
10+
11+
VERSION="$1"
12+
CHANNEL="${2:-latest}"
13+
14+
PKG_DIR="$(cd "$(dirname "$0")/../.." && pwd)" # packages/webgpu
15+
SHIM_DIR="$(cd "$PKG_DIR/../webgpu-shim" && pwd)" # packages/webgpu-shim
16+
STAGING="$(mktemp -d)"
17+
trap 'rm -rf "$STAGING"' EXIT
18+
19+
# 1. react-native-webgpu: publish the tarball semantic-release-yarn produced.
20+
# Copy into a clean staging dir so only the intended tarball is present.
21+
echo "Publishing react-native-webgpu@$VERSION (tag: $CHANNEL)"
22+
cp "$PKG_DIR"/dist/*.tgz "$STAGING/"
23+
( cd "$STAGING" && npm publish ./*.tgz --provenance --access public --tag "$CHANNEL" )
24+
rm -f "$STAGING"/*.tgz
25+
26+
# 2. react-native-wgpu shim: same version, pinned to the matching release.
27+
# lib/ was built by `yarn build` earlier in the release workflow.
28+
echo "Publishing react-native-wgpu@$VERSION (tag: $CHANNEL)"
29+
( cd "$SHIM_DIR" && npm pkg set version="$VERSION" dependencies.react-native-webgpu="$VERSION" )
30+
( cd "$SHIM_DIR" && yarn pack --out "$STAGING/react-native-wgpu.tgz" )
31+
( cd "$STAGING" && npm publish ./react-native-wgpu.tgz --provenance --access public --tag "$CHANNEL" )

0 commit comments

Comments
 (0)