Skip to content

Commit 37a4cbc

Browse files
cpcloudclaude
andcommitted
ci(release): fix dry-run and add CI status gate
- Replace sponge with temp file in dry-run (moreutils not on CI runners) - Use git worktree add -b for proper branch creation - Make cleanup resilient to missing branch - Verify HEAD passed CI before running scheduled release - Remove moreutils from devshell (no longer needed) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b93ae2f commit 37a4cbc

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

.github/workflows/scheduled-release.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ jobs:
3434
fetch-depth: 0
3535
token: ${{ steps.app-token.outputs.token }}
3636

37+
- name: Verify HEAD passed CI
38+
env:
39+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
40+
run: |
41+
sha=$(git rev-parse HEAD)
42+
conclusion=$(gh api "repos/${{ github.repository }}/commits/$sha/check-runs" \
43+
--jq '.check_runs[] | select(.name == "CI Result") | .conclusion')
44+
if [ "$conclusion" != "success" ]; then
45+
echo "::error::HEAD ($sha) CI Result is '$conclusion', expected 'success'. Aborting release."
46+
exit 1
47+
fi
48+
3749
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
3850
with:
3951
node-version: lts/*

ci/release/dry-run.bash

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,30 @@ set -euo pipefail
99

1010
curdir="$PWD"
1111
worktree="$(mktemp -d)"
12-
branch="$(basename "$worktree")"
12+
branch="semantic-release-dry-run-$(basename "$worktree")"
1313

14-
git worktree add "$worktree"
14+
git worktree add -b "$branch" "$worktree" HEAD
1515

1616
cleanup() {
1717
cd "$curdir"
1818
git worktree remove --force "$worktree"
1919
git worktree prune
20-
git branch -D "$branch"
20+
if git show-ref --verify --quiet "refs/heads/$branch"; then
21+
git branch -D "$branch"
22+
fi
2123
}
2224
trap cleanup EXIT
2325

2426
cd "$worktree"
2527

2628
# Strip @semantic-release/github so the dry-run makes no API calls
29+
tmp=$(mktemp)
2730
jq '.plugins |= map(select(
2831
if type == "array" then .[0] != "@semantic-release/github"
2932
else . != "@semantic-release/github"
3033
end
31-
))' .releaserc.json | sponge .releaserc.json
34+
))' .releaserc.json > "$tmp"
35+
mv "$tmp" .releaserc.json
3236

3337
git add .releaserc.json
3438
git commit -m "test: semantic-release dry run" --no-verify --no-gpg-sign

flake.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@
416416
pkgs.goreleaser
417417
pkgs.nodejs
418418
pkgs.jq
419-
pkgs.moreutils
420419
pkgs.glow
421420
relnotes
422421
]

0 commit comments

Comments
 (0)