Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion release-scripts/next-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail
# Checks the latest version of Snyk CLI on npm and decides the next version.
# Only output the next version to stdout. All other output should go to stderr.

NEXT_VERSION="$(convco version --bump)"
NEXT_VERSION="$(convco version --patch)"
CURRENT_TAG="$(git describe --tags `git rev-list --tags --max-count=1`)"
RELEASE_CHANNEL="$($(dirname "$0")/determine-release-channel.sh)"

Expand Down
31 changes: 29 additions & 2 deletions release-scripts/validate-repository.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/usr/bin/env bash
set -uo pipefail

VERSION_TAG="$(cat binary-releases/version)"
VERSION_TAG="$(cat binary-releases/version | tr -d '[:space:]')"
RELEASE_NOTES_MD="./binary-releases/RELEASE_NOTES.md"

# Check if version is a stable release (clean semver without pre-release identifiers)
IS_STABLE_RELEASE=false
if [[ "$VERSION_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
IS_STABLE_RELEASE=true
fi

echo "-----------------------------------------------------------------"
echo "| Running sanity checks on the repository before releasing"
echo "| Checking Version: ${VERSION_TAG}"
echo "| Checking Version: ${VERSION_TAG} $(if [ "$IS_STABLE_RELEASE" = true ]; then echo "(stable)"; fi)"
echo "| "

TAG_FOUND=$(git -P tag --list --contains)
Expand All @@ -30,6 +37,26 @@ if [ $retVal -ne 1 ]; then
exit 1
fi

if [ -f "$RELEASE_NOTES_MD" ]; then
header_line=$(head -n 1 "$RELEASE_NOTES_MD")
RELEASE_VERSION=$(echo "$header_line" | sed 's/.*# \[\([^]]*\)\].*/\1/')

# Check if version extraction was successful
if [ -z "$RELEASE_VERSION" ] || [ "$RELEASE_VERSION" = "$header_line" ]; then
echo "| [FAIL] Could not extract version from release notes header: $header_line"
exit 1
fi

# Use string comparison instead of regex for more reliable prefix matching
if [[ ! "$VERSION_TAG" == "$RELEASE_VERSION"* ]]; then
echo "| [FAIL] Version mismatch:"
echo "| Binary: $VERSION_TAG"
echo "| Release notes: $RELEASE_VERSION"
exit 1
fi
echo "| [PASS] Release notes version matches binary version!"
fi

echo "| [PASS] The version is new!"
echo "| "
echo "| Summary: The Version is ready to release!"
Expand Down