Skip to content

Commit 39a4d4e

Browse files
authored
fix: try building the npm package in CI (#2043)
Historically, the release process for the npm module has been: - I run `codex-rs/scripts/create_github_release.sh` to kick off a release for the native artifacts. - I wait until it is done. - I run `codex-cli/scripts/stage_rust_release.py` to build the npm release locally - I run `npm publish` from my laptop It has been a longstanding issue to move the npm build to CI. I may still have to do the `npm publish` manually because it requires 2fac with `npm`, though I assume we can work that out later. Note I asked Codex to make these updates, and while they look pretty good to me, I'm not 100% certain, but let's just merge this and I'll kick off another alpha build and we'll see what happens?
1 parent 33f266d commit 39a4d4e

File tree

2 files changed

+59
-9
lines changed

2 files changed

+59
-9
lines changed

.github/workflows/rust-release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ jobs:
154154
runs-on: ubuntu-latest
155155

156156
steps:
157+
- name: Checkout repository
158+
uses: actions/checkout@v4
159+
157160
- uses: actions/download-artifact@v4
158161
with:
159162
path: dist
@@ -169,6 +172,44 @@ jobs:
169172
version="${GITHUB_REF_NAME#rust-v}"
170173
echo "name=${version}" >> $GITHUB_OUTPUT
171174
175+
# Setup Node + pnpm similar to ci.yml so we can build the npm package
176+
- name: Setup Node.js
177+
uses: actions/setup-node@v4
178+
with:
179+
node-version: 22
180+
181+
- name: Setup pnpm
182+
uses: pnpm/action-setup@v4
183+
with:
184+
version: 10.8.1
185+
run_install: false
186+
187+
- name: Get pnpm store directory
188+
id: pnpm-cache
189+
shell: bash
190+
run: |
191+
echo "store_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
192+
193+
- name: Setup pnpm cache
194+
uses: actions/cache@v4
195+
with:
196+
path: ${{ steps.pnpm-cache.outputs.store_path }}
197+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
198+
restore-keys: |
199+
${{ runner.os }}-pnpm-store-
200+
201+
- name: Stage npm package
202+
env:
203+
GH_TOKEN: ${{ github.token }}
204+
run: |
205+
set -euo pipefail
206+
TMP_DIR="${RUNNER_TEMP}/npm-stage"
207+
python3 codex-cli/scripts/stage_rust_release.py \
208+
--release-version "${{ steps.release_name.outputs.name }}" \
209+
--tmp "${TMP_DIR}"
210+
mkdir -p dist/npm
211+
(cd "$TMP_DIR" && zip -r "${GITHUB_WORKSPACE}/dist/npm/codex-npm-${{ steps.release_name.outputs.name }}.zip" .)
212+
172213
- name: Create GitHub Release
173214
uses: softprops/action-gh-release@v2
174215
with:

codex-cli/scripts/stage_rust_release.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ def main() -> int:
1313
1414
Run this after the GitHub Release has been created and use
1515
`--release-version` to specify the version to release.
16+
17+
Optionally pass `--tmp` to control the temporary staging directory that will be
18+
forwarded to stage_release.sh.
1619
"""
1720
)
1821
parser.add_argument(
1922
"--release-version", required=True, help="Version to release, e.g., 0.3.0"
2023
)
24+
parser.add_argument(
25+
"--tmp",
26+
help="Optional path to stage the npm package; forwarded to stage_release.sh",
27+
)
2128
args = parser.parse_args()
2229
version = args.release_version
2330

@@ -43,15 +50,17 @@ def main() -> int:
4350
print(f"should `git checkout {sha}`")
4451

4552
current_dir = Path(__file__).parent.resolve()
46-
stage_release = subprocess.run(
47-
[
48-
current_dir / "stage_release.sh",
49-
"--version",
50-
version,
51-
"--workflow-url",
52-
workflow["url"],
53-
]
54-
)
53+
cmd = [
54+
str(current_dir / "stage_release.sh"),
55+
"--version",
56+
version,
57+
"--workflow-url",
58+
workflow["url"],
59+
]
60+
if args.tmp:
61+
cmd.extend(["--tmp", args.tmp])
62+
63+
stage_release = subprocess.run(cmd)
5564
stage_release.check_returncode()
5665

5766
return 0

0 commit comments

Comments
 (0)