Skip to content

Commit 6e1e277

Browse files
adriencacciaclaude
andcommitted
feat: add dry-run mode to release script
The release script now defaults to dry-run mode, showing a summary of all actions and release notes without making any changes. Pass --execute to actually perform the release. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent d214727 commit 6e1e277

1 file changed

Lines changed: 60 additions & 18 deletions

File tree

β€Žscripts/release.shβ€Ž

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
#!/bin/bash
2-
# Usage: ./scripts/release.sh
3-
set -ex
2+
# Usage: ./scripts/release.sh [--execute]
3+
# By default, runs in dry-run mode. Pass --execute to actually perform the release.
4+
set -e
45

5-
# Prechecks
6+
EXECUTE=false
7+
for arg in "$@"; do
8+
case "$arg" in
9+
--execute) EXECUTE=true ;;
10+
*) echo "Unknown argument: $arg"; exit 1 ;;
11+
esac
12+
done
13+
14+
if [ "$EXECUTE" = false ]; then
15+
echo "=== DRY RUN MODE (pass --execute to perform the release) ==="
16+
fi
17+
18+
# Pre-checks
619
if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
720
echo "You must be on the main branch to release"
821
exit 1
922
fi
10-
git diff --exit-code
23+
if ! git diff --quiet; then
24+
echo "Error: Working tree is not clean. The following files have uncommitted changes:"
25+
git diff --name-only | sed 's/^/ /'
26+
exit 1
27+
fi
1128

1229
# Bump version
1330
NEW_VERSION=$(cat .codspeed-runner-version)
@@ -16,27 +33,52 @@ if ! [[ "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
1633
echo "Version must be a valid semver (e.g. 1.2.3)"
1734
exit 1
1835
fi
19-
MAJOR_VERSION=$(echo $NEW_VERSION | cut -d. -f1)
36+
MAJOR_VERSION=$(echo "$NEW_VERSION" | cut -d. -f1)
37+
38+
# Determine release notes strategy
39+
RUNNER_NOTES=$(gh release view "v$NEW_VERSION" -R CodSpeedHQ/codspeed --json body | jq -r .body)
40+
RELEASE_NOTES="$RUNNER_NOTES
41+
42+
43+
**Full Runner Changelog**: https://github.com/CodSpeedHQ/codspeed/blob/main/CHANGELOG.md"
44+
45+
# Summary
46+
echo ""
47+
echo "Version: v$NEW_VERSION"
48+
echo "Major tag: v$MAJOR_VERSION"
49+
echo ""
50+
echo "The following actions will be performed:"
51+
echo " - Create an empty commit: \"Release v$NEW_VERSION πŸš€\""
52+
echo " - Create/update tag v$NEW_VERSION"
53+
echo " - Force-update tag v$MAJOR_VERSION"
54+
echo " - Push tags and commits"
55+
echo " - Create a draft GitHub release v$NEW_VERSION with runner release notes"
56+
57+
if [ "$EXECUTE" = false ]; then
58+
echo ""
59+
echo "Release notes:"
60+
echo "---"
61+
echo "$RELEASE_NOTES"
62+
echo "---"
63+
echo ""
64+
echo "=== DRY RUN: No changes were made ==="
65+
exit 0
66+
fi
67+
68+
set -x
2069

2170
# Ask for confirmation
22-
read -p "Are you sure you want to release v$NEW_VERSION? Bumping the v$MAJOR_VERSION major version ?(y/n) " -n 1 -r
71+
read -p "Are you sure you want to release v$NEW_VERSION? Bumping the v$MAJOR_VERSION major version? (y/n) " -n 1 -r
2372
echo
2473
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
2574
exit 1
2675
fi
2776

28-
# Fail if there are any unstaged changes left
29-
git diff --exit-code
3077
git commit -m "Release v$NEW_VERSION πŸš€" --allow-empty
31-
git tag -s -fa v$NEW_VERSION -m "Release v$NEW_VERSION πŸš€"
32-
git tag -s -fa v$MAJOR_VERSION -m "Release v$NEW_VERSION πŸš€"
33-
git push origin tag v$NEW_VERSION
34-
git push -f origin tag v$MAJOR_VERSION
78+
git tag -s -fa "v$NEW_VERSION" -m "Release v$NEW_VERSION πŸš€"
79+
git tag -s -fa "v$MAJOR_VERSION" -m "Release v$NEW_VERSION πŸš€"
80+
git push origin tag "v$NEW_VERSION"
81+
git push -f origin tag "v$MAJOR_VERSION"
3582
git push --follow-tags
3683

37-
RUNNER_NOTES=$(gh release view v$NEW_VERSION -R CodSpeedHQ/codspeed --json body | jq -r .body)
38-
RUNNER_NOTES="$RUNNER_NOTES
39-
40-
41-
**Full Runner Changelog**: https://github.com/CodSpeedHQ/codspeed/blob/main/CHANGELOG.md"
42-
gh release create v$NEW_VERSION --title "v$NEW_VERSION" --notes "$RUNNER_NOTES" -d
84+
gh release create "v$NEW_VERSION" --title "v$NEW_VERSION" --notes "$RELEASE_NOTES" -d

0 commit comments

Comments
Β (0)