Skip to content

Commit 99c9fda

Browse files
committed
Push release tags atomically
1 parent 165ef8e commit 99c9fda

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

docs/npm-publishing.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ Infrastructure-only PRs can add an empty changeset: `bunx changeset add --empty`
7373
```bash
7474
TAG_CORE="core-v$(bun -e 'console.log(require("./packages/core/package.json").version)')"
7575
TAG_SDK="sdk-v$(bun -e 'console.log(require("./packages/sdk/package.json").version)')"
76-
git tag "$TAG_CORE"
77-
git tag "$TAG_SDK"
78-
git push origin "$TAG_CORE" "$TAG_SDK"
76+
git tag -a "$TAG_CORE" -m "Release $TAG_CORE (@razroo/ray-core)"
77+
git tag -a "$TAG_SDK" -m "Release $TAG_SDK (@razroo/ray-sdk)"
78+
git push --atomic origin "$TAG_CORE" "$TAG_SDK"
7979
```
8080

81-
Only push the tag(s) you are releasing in this pass.
81+
Push linked package tags atomically so a failed push cannot publish only one side of the release pair.
8282

8383
3. Create GitHub Releases (fires the npm workflows):
8484

@@ -101,7 +101,7 @@ After **`bun run version`** is committed on **`main`** and pushed (`git push ori
101101

102102
```bash
103103
bun run release:github -- --dry-run # plan only
104-
bun run release:github -- --yes # tag, git push tags, gh release create ×2
104+
bun run release:github -- --yes # tag, git push --atomic tags, gh release create ×2
105105
```
106106

107107
Requires [**GitHub CLI**](https://cli.github.com/) (`gh`) authenticated (`gh auth login`). NPM publish still runs in Actions when each release is **published**.

scripts/release/gh-release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Usage: bash scripts/release/gh-release.sh [--dry-run | --yes]
129129
130130
Reads versions from packages/core and packages/sdk (must match), then:
131131
1) creates annotated tags core-v<ver> and sdk-v<ver> on HEAD
132-
2) git push origin <tags>
132+
2) git push --atomic origin <tags>
133133
3) gh release create for each tag (triggers npm publish Actions)
134134
135135
Prereqs: gh auth, clean working tree, main is what you intend to release.
@@ -217,7 +217,7 @@ done
217217

218218
git tag -a "$TAG_CORE" -m "Release $TAG_CORE (@razroo/ray-core v$VER)"
219219
git tag -a "$TAG_SDK" -m "Release $TAG_SDK (@razroo/ray-sdk v$VER)"
220-
run_required_bounded "pushing release tags" 120 git push origin "$TAG_CORE" "$TAG_SDK"
220+
run_required_bounded "pushing release tags atomically" 120 git push --atomic origin "$TAG_CORE" "$TAG_SDK"
221221
run_required_bounded \
222222
"creating GitHub release $TAG_CORE" \
223223
120 \

scripts/release/gh-release.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ async function createReleaseHelperFixture(
105105
'if [ "${1:-}" = "ls-remote" ]; then',
106106
" exit 2",
107107
"fi",
108+
'if [ "${1:-}" = "push" ] && [ "${2:-}" != "--atomic" ]; then',
109+
' echo "release tag push must be atomic" >&2',
110+
" exit 97",
111+
"fi",
108112
'if [ "${1:-}" = "tag" ] || [ "${1:-}" = "push" ]; then',
109113
" exit 0",
110114
"fi",
@@ -224,7 +228,10 @@ test("gh release helper bounds network release operations", async () => {
224228
contents,
225229
/run_required_bounded "checking GitHub CLI authentication" 60 gh auth status/,
226230
);
227-
assert.match(contents, /run_required_bounded "pushing release tags" 120 git push origin/);
231+
assert.match(
232+
contents,
233+
/run_required_bounded "pushing release tags atomically" 120 git push --atomic origin/,
234+
);
228235
assert.match(contents, /"creating GitHub release \$TAG_CORE"/);
229236
assert.match(contents, /"creating GitHub release \$TAG_SDK"/);
230237
});
@@ -267,7 +274,7 @@ test("gh release helper continues when GitHub reports releases are missing", asy
267274
assert.match(commandLog, /^gh auth status$/m);
268275
assert.match(commandLog, /^git tag -a core-v1\.2\.3 /m);
269276
assert.match(commandLog, /^git tag -a sdk-v1\.2\.3 /m);
270-
assert.match(commandLog, /^git push origin core-v1\.2\.3 sdk-v1\.2\.3$/m);
277+
assert.match(commandLog, /^git push --atomic origin core-v1\.2\.3 sdk-v1\.2\.3$/m);
271278
assert.match(
272279
commandLog,
273280
/^gh release create core-v1\.2\.3 --generate-notes --title core-v1\.2\.3$/m,

0 commit comments

Comments
 (0)