Skip to content

Commit aa7c70f

Browse files
feat(tooling): Add milestone check and local tag revert (#11058)
feat(tooling): Add milestone check and local tag revert Co-authored-by: bruce.bujon <bruce.bujon@datadoghq.com>
1 parent e0914eb commit aa7c70f

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

tooling/perform-release.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,35 @@ else
7171
echo "✅ All commits since the last release are merge commits."
7272
fi
7373

74-
# Get the next release version
74+
# Get the next version to release
7575
VERSION=$(echo "$LAST_RELEASE_TAG" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' || true)
7676
if [ -z "$VERSION" ]; then
7777
echo "❌ Unable to determine the next release version from the last release tag: $LAST_RELEASE_TAG"
7878
exit 1
7979
fi
8080
if [ "$MINOR_RELEASE" = true ]; then
81-
NEXT_RELEASE_VERSION=$(echo "$VERSION" | awk -F. '{printf "v%d.%d.0", $1, $2 + 1}')
81+
NEXT_VERSION=$(echo "$VERSION" | awk -F. '{printf "%d.%d.0", $1, $2 + 1}')
8282
else
83-
NEXT_RELEASE_VERSION=$(echo "$VERSION" | awk -F. '{printf "v%d.%d.%d", $1, $2, $3 + 1}')
83+
NEXT_VERSION=$(echo "$VERSION" | awk -F. '{printf "%d.%d.%d", $1, $2, $3 + 1}')
8484
fi
85-
echo "ℹ️ Next release version: $NEXT_RELEASE_VERSION"
85+
echo "ℹ️ Next version to release: $NEXT_VERSION"
86+
87+
# Check milestone exists
88+
if ! gh api "repos/{owner}/{repo}/milestones" --paginate --jq ".[].title" | grep -qx "$NEXT_VERSION"; then
89+
echo "❌ Milestone '$NEXT_VERSION' does not exist. Please reach out to the guild before performing a release."
90+
exit 1
91+
fi
92+
echo "✅ GitHub milestone for $NEXT_VERSION exists."
8693

8794
# Create and push the release tag
88-
echo "ℹ️ The release tag will be created and pushed. No abort is possible after this point."
95+
NEXT_RELEASE_TAG="v$NEXT_VERSION"
96+
echo "ℹ️ The release tag $NEXT_RELEASE_TAG will be created and pushed. No abort is possible after this point."
8997
confirmOrAbort
90-
git tag -a -s -m "Release $NEXT_RELEASE_VERSION" "$NEXT_RELEASE_VERSION"
91-
git push "$REMOTE" "$NEXT_RELEASE_VERSION" --no-verify
92-
echo "✅ Release tag $NEXT_RELEASE_VERSION created and pushed to $REMOTE."
98+
git tag -a -s -m "Release $NEXT_RELEASE_TAG" "$NEXT_RELEASE_TAG"
99+
if ! git push "$REMOTE" "$NEXT_RELEASE_TAG" --no-verify; then
100+
echo "❌ Unable to push the release tag to $REMOTE."
101+
echo "ℹ️ Deleting the created local tag."
102+
git tag -d "$NEXT_RELEASE_TAG"
103+
exit 1
104+
fi
105+
echo "✅ Release tag $NEXT_RELEASE_TAG created and pushed to $REMOTE."

0 commit comments

Comments
 (0)