Merge branch 'main' into adding-additional-checks #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jobs: | |
| validate-release-branch: | |
| runs-on: ubuntu-latest | |
| env: | |
| RELEASE_BRANCH_PREFIX: release/ | |
| CURRENT_RELEASE: v2 | |
| TARGET_BRANCH: ${{ github.base_ref }} | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| PR_LABELS_JSON: ${{ toJson(github.event.pull_request.labels) }} | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Validate release branch | |
| run: | | |
| LABELS=$(echo "$PR_LABELS_JSON" | jq -r '.[].name' | tr '\n' ' ') | |
| if [[ ! "$TARGET_BRANCH" =~ ^"$RELEASE_BRANCH_PREFIX" ]]; then | |
| echo "Not a release branch — skipping release validation." | |
| exit 0 | |
| fi | |
| if [[ ! "$LABELS" =~ "release" ]]; then | |
| echo "::error::PRs targeting release branches must have the 'release' label" | |
| exit 1 | |
| fi | |
| BRANCH_VERSION=$(echo "$TARGET_BRANCH" | sed "s|$RELEASE_BRANCH_PREFIX||") | |
| if [[ "$BRANCH_VERSION" != "$CURRENT_RELEASE" ]]; then | |
| if [[ ! "$LABELS" =~ "allow-older-release" ]]; then | |
| echo "::error::Merging to older release branches (release/$BRANCH_VERSION) is not allowed. Current release is $CURRENT_RELEASE." | |
| echo "::error::If this is intentional, add the 'allow-older-release' label to the PR." | |
| exit 1 | |
| fi | |
| fi | |
| if ! [[ "$PR_TITLE" =~ ^Release\ \[[0-9]{4}-[0-9]{2}-[0-9]{2}\]$ ]]; then | |
| echo "::error::Release PR title must follow format: 'Release [YYYY-MM-DD]'" | |
| exit 1 | |
| fi | |
| if ! git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -q "CHANGELOG.md"; then | |
| echo "::error::CHANGELOG.md must be updated for releases" | |
| exit 1 | |
| fi |