Skip to content

Commit c1a42c8

Browse files
committed
feat: add platform-specific release assets for mise/ubi support
Upload platform-named copies of the bash script (linux-amd64, linux-arm64, darwin-amd64, darwin-arm64) as release assets so `mise install ubi:nsheaps/git-wt` works out of the box. Also aligns the update-homebrew job with the consistent pattern used across other repos (close stale PRs, auto-merge with retry, sha256sum). https://claude.ai/code/session_01UNAUtVFRfFTyfXXLy7dJNz
1 parent 38dcafe commit c1a42c8

1 file changed

Lines changed: 53 additions & 12 deletions

File tree

.github/workflows/release.yaml

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,29 @@ jobs:
3838

3939
- name: Run release-it
4040
id: release
41+
env:
42+
GITHUB_TOKEN: ${{ steps.auth.outputs.token }}
4143
run: |
4244
yarn release-it --ci
4345
TAG=$(git describe --tags --abbrev=0)
4446
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
4547
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
4648
49+
- name: Upload release assets
50+
env:
51+
GITHUB_TOKEN: ${{ steps.auth.outputs.token }}
52+
run: |
53+
TAG="${{ steps.release.outputs.tag }}"
54+
# git-wt is a platform-independent bash script, but ubi (used by
55+
# mise) expects assets named with OS/arch patterns. Upload copies
56+
# for each supported platform so `mise install ubi:nsheaps/git-wt`
57+
# works out of the box.
58+
for platform in linux-amd64 linux-arm64 darwin-amd64 darwin-arm64; do
59+
cp bin/git-wt "git-wt-${platform}"
60+
done
61+
gh release upload "$TAG" git-wt-linux-amd64 git-wt-linux-arm64 git-wt-darwin-amd64 git-wt-darwin-arm64
62+
rm -f git-wt-linux-amd64 git-wt-linux-arm64 git-wt-darwin-amd64 git-wt-darwin-arm64
63+
4764
update-homebrew:
4865
needs: release
4966
runs-on: ubuntu-latest
@@ -72,11 +89,10 @@ jobs:
7289
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
7390
7491
# Download archive tarball and calculate SHA256
75-
# Archive is available instantly (no CDN delay like release assets)
7692
TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${TAG}.tar.gz"
7793
echo "Downloading tarball from: $TARBALL_URL"
7894
curl -fsSL "$TARBALL_URL" -o /tmp/archive.tar.gz
79-
SHA256=$(shasum -a 256 /tmp/archive.tar.gz | cut -d' ' -f1)
95+
SHA256=$(sha256sum /tmp/archive.tar.gz | cut -d' ' -f1)
8096
echo "sha256=$SHA256" >> "$GITHUB_OUTPUT"
8197
echo "Successfully got SHA256: $SHA256"
8298
@@ -96,7 +112,17 @@ jobs:
96112
run: |
97113
gomplate -f Formula/git-wt.rb.gotmpl -o homebrew-devsetup/Formula/git-wt.rb
98114
99-
- name: Create PR to update formula with auto-merge
115+
- name: Close stale formula PRs
116+
run: |
117+
cd homebrew-devsetup
118+
# Close any open PRs from previous formula updates — they're superseded
119+
gh pr list --state open --search "chore: update git-wt to" --json number,title --jq '.[].number' | while read -r pr_num; do
120+
echo "Closing superseded PR #${pr_num}"
121+
gh pr close "$pr_num" --comment "Superseded by v${{ steps.release.outputs.version }} update."
122+
done
123+
124+
- name: Create PR to update formula
125+
id: formula-pr
100126
env:
101127
RELEASE_URL: https://github.com/${{ github.repository }}/releases/tag/${{ steps.release.outputs.tag }}
102128
JOB_URL: ${{ env.GITHUB_JOB_URL }}
@@ -105,22 +131,37 @@ jobs:
105131
run: |
106132
cd homebrew-devsetup
107133
BRANCH="bump-git-wt-${VERSION}"
134+
135+
# Delete remote branch if it exists from a previous failed run
136+
git push origin --delete "$BRANCH" 2>/dev/null || true
137+
108138
git checkout -b "$BRANCH"
109139
git add Formula/git-wt.rb
110140
git commit -m "chore: update git-wt to ${VERSION}"
111141
git push -u origin "$BRANCH"
112142
113-
# Create PR body file
114-
cat > /tmp/pr-body.md << 'BODY_EOF'
115-
Automated formula update from git-wt release
116-
BODY_EOF
117-
echo "" >> /tmp/pr-body.md
118-
echo "**Release:** ${RELEASE_URL}" >> /tmp/pr-body.md
119-
echo "**Workflow:** ${JOB_URL}" >> /tmp/pr-body.md
143+
printf 'Automated formula update from git-wt release\n\n**Release:** %s\n**Workflow:** %s\n' "$RELEASE_URL" "$JOB_URL" > /tmp/pr-body.md
120144
121145
PR_URL=$(gh pr create \
122146
--title "chore: update git-wt to ${VERSION}" \
123147
--body-file /tmp/pr-body.md \
124148
--base main)
125-
# Enable auto-merge with squash
126-
gh pr merge "$PR_URL" --auto --squash
149+
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
150+
151+
- name: Enable auto-merge with retry
152+
env:
153+
PR_URL: ${{ steps.formula-pr.outputs.pr_url }}
154+
run: |
155+
# Retry auto-merge — CI checks on the target repo need time to start,
156+
# and the GraphQL API rejects enablePullRequestAutoMerge while the PR
157+
# is in "unstable" (checks pending) status.
158+
for attempt in 1 2 3 4 5; do
159+
if gh pr merge "$PR_URL" --auto --squash; then
160+
echo "Auto-merge enabled successfully on attempt ${attempt}"
161+
exit 0
162+
fi
163+
wait=$((attempt * 10))
164+
echo "Auto-merge not ready (attempt ${attempt}/5), waiting ${wait}s..."
165+
sleep "$wait"
166+
done
167+
echo "::warning::Could not enable auto-merge after 5 attempts. PR was created successfully at ${PR_URL} — merge manually or re-run."

0 commit comments

Comments
 (0)