Skip to content

Commit a52a7ef

Browse files
committed
more ci improvements
1 parent 819597e commit a52a7ef

4 files changed

Lines changed: 78 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ on:
1717
- ".github/workflows/release.yml"
1818
workflow_dispatch:
1919
inputs:
20+
release_intent:
21+
description: "What should this manual run do?"
22+
required: true
23+
type: choice
24+
options:
25+
- version-pr
26+
- publish
27+
default: version-pr
28+
force_publish:
29+
description: "Allow manual publish even when version-bump detection is false (use for reruns/recovery)"
30+
required: false
31+
type: boolean
32+
default: false
2033
version_type:
2134
description: 'Version bump type (major/minor/patch)'
2235
required: false
@@ -100,18 +113,39 @@ jobs:
100113
101114
echo "has_version_bumps=${has_version_bumps}" >> "$GITHUB_OUTPUT"
102115
116+
- name: Validate manual release intent prerequisites
117+
if: github.event_name == 'workflow_dispatch'
118+
shell: bash
119+
run: |
120+
set -euo pipefail
121+
intent="${{ inputs.release_intent }}"
122+
has_changesets="${{ steps.detect.outputs.has_changesets }}"
123+
has_version_bumps="${{ steps.detect.outputs.has_version_bumps }}"
124+
force_publish="${{ inputs.force_publish }}"
125+
126+
if [ "$intent" = "version-pr" ] && [ "$has_changesets" != "true" ]; then
127+
echo "Manual intent 'version-pr' requires at least one .changeset/*.md file in this commit."
128+
exit 1
129+
fi
130+
131+
if [ "$intent" = "publish" ] && [ "$has_version_bumps" != "true" ] && [ "$force_publish" != "true" ]; then
132+
echo "Manual intent 'publish' requires package.json/CHANGELOG.md version bump changes."
133+
echo "If you are rerunning/recovering a failed publish from master, re-run with force_publish=true."
134+
exit 1
135+
fi
136+
103137
- name: Stop early (no changesets / no version bumps)
104138
if: github.event_name != 'workflow_dispatch' && steps.detect.outputs.has_changesets != 'true' && steps.detect.outputs.has_version_bumps != 'true'
105139
run: |
106140
echo "No .changeset files and no package version/changelog updates in this push. Skipping release."
107141
exit 0
108142
109143
- name: Build packages (publish runs only)
110-
if: github.event_name == 'workflow_dispatch' || steps.detect.outputs.has_version_bumps == 'true'
144+
if: (github.event_name == 'workflow_dispatch' && inputs.release_intent == 'publish') || (github.event_name != 'workflow_dispatch' && steps.detect.outputs.has_version_bumps == 'true')
111145
run: bun run build
112146

113147
- name: Run tests (publish runs only)
114-
if: github.event_name == 'workflow_dispatch' || steps.detect.outputs.has_version_bumps == 'true'
148+
if: (github.event_name == 'workflow_dispatch' && inputs.release_intent == 'publish') || (github.event_name != 'workflow_dispatch' && steps.detect.outputs.has_version_bumps == 'true')
115149
run: bun run test
116150

117151
- name: Create Release Pull Request or Publish to NPM

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ Use release labels to tag a coordinated release wave across packages while keepi
104104

105105
`bun run release:label:push` - Create and push the release tag to origin
106106

107+
### Manual Publish Recovery (GitHub Actions)
108+
109+
If a publish fails after the version PR was already merged, rerun the Release workflow manually:
110+
111+
1. Actions → **Release****Run workflow**
112+
2. Branch: `master`
113+
3. `release_intent`: `publish`
114+
4. `force_publish`: `true`
115+
116+
This is intended for recovery/rerun scenarios only.
117+
107118
### Maintainer Commands
108119

109120
`bun cli upstream:sync` - (Maintainers only) Syncs packages from the upstream pie-elements project. Requires pie-elements and pie-lib checked out as sibling directories. Analyzes the current state of those projects and copies over what is ready for ESM packaging, including rewrites and restructuring to fit the new project layout.

docs/ARCHITECTURE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,10 @@ Note: `'unsafe-inline'` for styles is required for Svelte scoped styles.
11801180
4. Maintainer merges Version PR
11811181
5. Packages automatically published to npm
11821182

1183+
If a publish fails after merge, maintainers can manually rerun the Release workflow
1184+
with `release_intent=publish` and `force_publish=true` to recover without creating a
1185+
new version-bump commit.
1186+
11831187
See [PUBLISHING.md](./PUBLISHING.md) for details (when available).
11841188

11851189
### Versioning

scripts/changeset-publish-resolved-workspaces.mjs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ const restoreWorkspaceRanges = () => {
114114
}
115115
};
116116

117-
const runChangesetPublish = () =>
117+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
118+
119+
const runChangesetPublishOnce = () =>
118120
new Promise((resolve, reject) => {
119121
const child = spawn('bunx', ['changeset', 'publish'], {
120122
cwd: repoRoot,
@@ -129,6 +131,30 @@ const runChangesetPublish = () =>
129131
child.on('error', reject);
130132
});
131133

134+
const runChangesetPublish = async () => {
135+
// Retry once to recover from transient npm issues or partial publishes.
136+
// On retry, Changesets skips versions that are already published.
137+
const maxAttempts = 2;
138+
let lastError;
139+
140+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
141+
try {
142+
console.log(`[release] Running changeset publish (attempt ${attempt}/${maxAttempts})`);
143+
await runChangesetPublishOnce();
144+
return;
145+
} catch (error) {
146+
lastError = error;
147+
if (attempt === maxAttempts) break;
148+
console.warn(
149+
`[release] changeset publish failed on attempt ${attempt}; retrying once in 5s...`
150+
);
151+
await sleep(5000);
152+
}
153+
}
154+
155+
throw lastError;
156+
};
157+
132158
try {
133159
rewriteWorkspaceRanges();
134160
if (changedFiles.length > 0) {

0 commit comments

Comments
 (0)