Skip to content
Closed
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
60 changes: 57 additions & 3 deletions .github/workflows/staging-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ jobs:
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Get the version on staging
run: |
curl --fail -LO "$AWS_URL/latest-version.txt"
Expand All @@ -51,6 +56,58 @@ jobs:
AWS_URL: https://${{ secrets.AWS_S3_BUCKET_STAGING }}.s3.amazonaws.com
RELEASE_VERSION: ${{ github.event.inputs.version }}

- name: Verify version is newer than latest release on target branch
run: |
set -euo pipefail

if [[ ! "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Release version must be in x.y.z format, got: $RELEASE_VERSION"
exit 1
fi

RELEASE_MAJOR="${RELEASE_VERSION%%.*}"
RELEASE_MINOR="${RELEASE_VERSION#*.}"
RELEASE_MINOR="${RELEASE_MINOR%%.*}"
RELEASE_MM="${RELEASE_MAJOR}.${RELEASE_MINOR}"

TARGET_BRANCH="$RELEASE_MM"
if [[ "$RELEASE_MM" == "4.2" ]] || (( RELEASE_MAJOR >= 5 )); then
TARGET_BRANCH="master"
Comment on lines +74 to +75
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate 4.2 releases against the 4.2 branch

This branch selection forces TARGET_BRANCH="master" for every 4.2.x release, but the same workflow still publishes 4.2 releases from target_commitish: '4.2' later in the file. That mismatch means the new version gate compares 4.2 inputs against tags on master rather than the 4.2 maintenance branch; once master has higher tags (for example 5.x), legitimate 4.2 patch releases will be rejected as “not newer,” blocking the 4.2 release path.

Useful? React with 👍 / 👎.

fi

echo "Using target branch: $TARGET_BRANCH"

git fetch origin "$TARGET_BRANCH" --tags

BRANCH_TAGS=$(git tag --merged "origin/$TARGET_BRANCH" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true)

if [[ -z "$BRANCH_TAGS" ]]; then
echo "No prior release tags found on origin/$TARGET_BRANCH. Continuing."
exit 0
fi

LATEST_TAG=$(printf '%s\n' "$BRANCH_TAGS" | sed 's/^v//' | sort -V | tail -n 1)
echo "Latest release tag on origin/$TARGET_BRANCH: v$LATEST_TAG"

if [[ "$TARGET_BRANCH" != "master" ]]; then
LATEST_MM="${LATEST_TAG%.*}"
if [[ "$LATEST_MM" != "$RELEASE_MM" ]]; then
echo "Latest branch tag stream mismatch on $TARGET_BRANCH: $LATEST_MM"
exit 1
fi
fi

if [[ "$(printf '%s\n%s\n' "$LATEST_TAG" "$RELEASE_VERSION" | sort -V | tail -n 1)" != "$RELEASE_VERSION" ]] ||
[[ "$LATEST_TAG" == "$RELEASE_VERSION" ]]; then
echo "Release version must be greater than latest branch release: $RELEASE_VERSION <= $LATEST_TAG"
exit 1
fi

echo "Release version validated: $RELEASE_VERSION > $LATEST_TAG on $TARGET_BRANCH"
shell: bash
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}

# Get the major version, i.e. 1.9.3 --> 1.9, or just return the passed in version.
- name: Convert to major version format
id: get_major_version
Expand All @@ -64,9 +121,6 @@ jobs:
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}

- name: Checkout repository
uses: actions/checkout@v6

staging-release-generate-package-matrix:
name: Get package matrix
runs-on: ubuntu-latest
Expand Down
Loading