Skip to content

Commit 3af4de8

Browse files
authored
fix(release): restore create-package.sh and set the core package version (#1429)
Publishing from `main` is currently broken in two ways. Found while updating RELEASE.md (#1428). 1. `.github/workflows/npm-publish.yml` runs `./scripts/create-package.sh` from `packages/react-native-executorch`, but the rewrite scaffold (#1256) deleted that script. The workflow is byte-identical to the one on `release/0.9`, so it was never updated for the rewrite. 2. The core `package.json` still says `version: 0.0.0`, and that is the exact field the workflow reads to decide what it publishes. Set to `0.10.0`, matching the two adapter packages and `nativeLibsVersion`. ### Three deliberate changes from the release/0.9 copy | change | why | | --- | --- | | `yarn prepare` instead of `yarn bob build` | `files` ships both `lib/` and `legacy/`; prepare is `bob build && tsc -p legacy/tsconfig.json`. Bob alone leaves `legacy/` out of the tarball. | | version edited by pattern, not line 3 | `nativeLibsVersion` now sits directly below `version`, so a positional edit is one inserted line away from rewriting the wrong field. | | `build.log` written with the packed file list | The workflow greps it to assert no `node_modules` were packed, but nothing ever wrote the file, so grep failed on a missing file and the check passed vacuously. | The `build.log` content is the tarball listing rather than the pack output on purpose: `npm pack` runs the `prepare` lifecycle, and bob logs the path of the `tsc` binary it falls back to, which lives under `node_modules` and fails the grep on a package that is perfectly clean. That false positive showed up on the first test run. ### Verified by running the script - builds `react-native-executorch-0.10.0.tgz`, 1020 files - packed `package.json` says `0.10.0` - zero `node_modules` entries in the tarball, and the workflow's grep now returns 0 - `lib/` 496 files, `legacy/` 294 files Not covered: the workflow itself is unchanged here, so the first real publish is still the first end-to-end exercise of the CI path.
1 parent 18c34cd commit 3af4de8

4 files changed

Lines changed: 85 additions & 2 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ on:
1919
required: false
2020
type: string
2121
default: ''
22+
dry-run:
23+
description: 'Build and pack, but do not publish to npm. Everything up to the publish step runs unchanged.'
24+
required: false
25+
type: boolean
26+
default: false
2227

2328
permissions:
2429
id-token: write
@@ -43,6 +48,7 @@ jobs:
4348
TAG: PLACEHOLDER
4449
# `inputs` is empty on the scheduled run, which is always a nightly.
4550
RELEASE_TYPE: ${{ inputs.release-type || 'nightly' }}
51+
DRY_RUN: ${{ inputs.dry-run || false }}
4652
DIST_TAG_OVERRIDE: ${{ inputs.dist-tag || '' }}
4753
steps:
4854
- name: Checkout
@@ -144,4 +150,12 @@ jobs:
144150
run: mv ${{ env.EXECUTORCH_DIR }}/${{ env.PACKAGE_NAME }} .
145151

146152
- name: Publish package to npm
153+
if: ${{ env.DRY_RUN != 'true' }}
147154
run: npm publish $PACKAGE_NAME --tag ${{ env.TAG }} --provenance
155+
156+
# --provenance is omitted here on purpose: it needs the OIDC exchange,
157+
# which a dry run should not perform. Everything before this point,
158+
# including the build and the packed tarball, has already run unchanged.
159+
- name: Publish package to npm (dry run)
160+
if: ${{ env.DRY_RUN == 'true' }}
161+
run: npm publish $PACKAGE_NAME --tag ${{ env.TAG }} --dry-run

packages/react-native-executorch-webrtc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-executorch-webrtc",
3-
"version": "0.9.0",
3+
"version": "0.10.0",
44
"description": "ExecuTorch WebRTC frame processor integration for react-native-webrtc",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

packages/react-native-executorch/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-executorch",
3-
"version": "0.0.0",
3+
"version": "0.10.0",
44
"nativeLibsVersion": "0.10.0",
55
"description": "An easy way to run AI models in React Native with ExecuTorch",
66
"main": "./lib/module/index.js",
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Builds the core package and produces the .tgz the npm publish workflow
5+
# uploads. Invoked as `./scripts/create-package.sh [generate_nightly_version]`
6+
# from packages/react-native-executorch.
7+
8+
# Phonemis is a git submodule whose sources the podspec compiles directly
9+
# (see third-party/common/phonemis/src in react-native-executorch.podspec).
10+
# Init it explicitly so the files are present in the packed tarball.
11+
# Run from repo root so the submodule path resolves regardless of cwd.
12+
git -C "$(git rev-parse --show-toplevel)" submodule update --init --recursive \
13+
packages/react-native-executorch/third-party/common/phonemis
14+
15+
# Trim phonemis to what consumers need at build time. Done here (not via
16+
# package.json "files") because the submodule's own .gitignore has
17+
# `!scripts/build*` which npm-packlist honors and re-includes those files
18+
# despite our exclusion rules. Restore on exit so the working tree stays clean.
19+
PHONEMIS_DIR="third-party/common/phonemis"
20+
restore_phonemis() {
21+
git -C "$PHONEMIS_DIR" checkout -- data test scripts requirements.txt 2>/dev/null || true
22+
}
23+
trap restore_phonemis EXIT
24+
rm -rf "$PHONEMIS_DIR/data" "$PHONEMIS_DIR/test" "$PHONEMIS_DIR/scripts"
25+
rm -f "$PHONEMIS_DIR/requirements.txt"
26+
27+
yarn install --immutable
28+
29+
# Match the version line by pattern, not by line number: `nativeLibsVersion`
30+
# sits next to it, so a positional edit rewrites the wrong field if either
31+
# moves.
32+
set_version() {
33+
if [[ "$OSTYPE" == "darwin"* ]]; then
34+
sed -i '' -E "s/^( \"version\": \")[^\"]*(\",)$/\1$1\2/" package.json
35+
else
36+
sed -i -E "s/^( \"version\": \")[^\"]*(\",)$/\1$1\2/" package.json
37+
fi
38+
}
39+
40+
NIGHTLY=0
41+
if [ $# -ge 1 ] && [ "$1" = "generate_nightly_version" ]; then
42+
NIGHTLY=1
43+
VERSION=$(jq -r '.version' package.json)
44+
GIT_COMMIT=$(git rev-parse HEAD)
45+
DATE=$(date +%Y%m%d)
46+
set_version "$VERSION-nightly-${GIT_COMMIT:0:7}-$DATE"
47+
fi
48+
49+
# `prepare` builds both outputs the "files" list ships: lib/ via bob and the
50+
# legacy entry points via tsc. `bob build` alone leaves legacy/ unbuilt.
51+
yarn prepare
52+
53+
npm pack
54+
55+
# The workflow asserts no node_modules were packed by grepping build.log for
56+
# `node_modules/`, but nothing ever wrote that file, so the check silently
57+
# passed on a missing file. Write the packed file list into it so the assertion
58+
# is real. It has to be the tarball listing rather than the pack output: npm
59+
# pack runs the `prepare` lifecycle, and bob logs the path of the tsc binary it
60+
# falls back to, which lives under node_modules and trips the grep on a package
61+
# that is perfectly clean.
62+
TARBALL=$(ls -t ./*.tgz | head -1)
63+
tar -tzf "$TARBALL" > build.log
64+
65+
if [ "$NIGHTLY" = "1" ]; then
66+
set_version "$VERSION"
67+
fi
68+
69+
echo "Done!"

0 commit comments

Comments
 (0)