Skip to content

Commit eacc947

Browse files
committed
fix: update release script, ensure correct versions are released
1 parent cebedf1 commit eacc947

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

scripts/release.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ set -e
55
VERSION_NO_V=${1} # The version number without the 'v' prefix
66
VERSION=v$1 # The version number, prefixed with 'v'
77

8+
# Validate version format (X.Y.Z or X.Y.Z-alpha where X, Y, Z are integers)
9+
if [[ ! "$VERSION_NO_V" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-alpha)?$ ]]; then
10+
echo "Error: Invalid version format '$VERSION_NO_V'"
11+
echo "Usage: $0 <version>"
12+
echo " Version must be in format X.Y.Z or X.Y.Z-alpha (e.g., 1.2.3 or 1.2.3-alpha)"
13+
exit 1
14+
fi
15+
816
# Check is on main (unless releasing an alpha version)
917
if [[ ! "$VERSION_NO_V" =~ -alpha ]]; then
1018
if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
@@ -55,15 +63,14 @@ for entry in "${VERSION_FILES[@]}"; do
5563
done
5664

5765
# Commit version changes
58-
FILES_TO_COMMIT=$(printf "%s\n" "${VERSION_FILES[@]%%:*}" | sort -u | xargs)
59-
git add $FILES_TO_COMMIT
66+
printf "%s\n" "${VERSION_FILES[@]%%:*}" | sort -u | xargs git add
6067

61-
git cliff -o CHANGELOG.md --tag $VERSION --github-token $GITHUB_TOKEN
68+
git cliff -o CHANGELOG.md --tag "$VERSION" --github-token "$GITHUB_TOKEN"
6269
git add CHANGELOG.md
6370
git commit -m "chore: Release $VERSION"
64-
git tag $VERSION -m "Release $VERSION"
71+
git tag -s "$VERSION" -m "Release $VERSION"
6572
git push origin main
66-
git push origin $VERSION
73+
git push origin "$VERSION"
6774

6875
# Create tarball with submodules included
6976
git submodule update --init --recursive
@@ -86,9 +93,9 @@ echo "Tarball created at: $TMPDIR/$TARBALL_NAME"
8693

8794
# Create GitHub release with the tarball
8895
if [[ "$VERSION_NO_V" =~ -alpha ]]; then
89-
gh release create $VERSION -t $VERSION --generate-notes --latest=false "$TMPDIR/$TARBALL_NAME"
96+
gh release create "$VERSION" -t "$VERSION" --generate-notes --latest=false "$TMPDIR/$TARBALL_NAME"
9097
else
91-
gh release create $VERSION -t $VERSION --generate-notes --latest "$TMPDIR/$TARBALL_NAME"
98+
gh release create "$VERSION" -t "$VERSION" --generate-notes --latest "$TMPDIR/$TARBALL_NAME"
9299
fi
93100

94101
# Cleanup

0 commit comments

Comments
 (0)