diff --git a/.github/workflows/check_version_markers.sh b/.github/workflows/check_version_markers.sh new file mode 100755 index 0000000000..b8d35aec9d --- /dev/null +++ b/.github/workflows/check_version_markers.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -o nounset +set -o pipefail +set -o errexit + +set -x + +TAG=${1:-} +if [ -n "$TAG" ]; then + # If the workflow checks out one commit, but is releasing another + git fetch origin tag "$TAG" + # Update our local state so the grep command below searches what we expect + git checkout "$TAG" +fi + +grep_exit_code=0 +# Exclude dot directories, specifically, this file so that we don't +# find the substring we're looking for in our own file. +# Exclude CONTRIBUTING.md, RELEASING.md because they document how to use these strings. +grep --exclude=CONTRIBUTING.md \ + --exclude=RELEASING.md \ + --exclude=release.py \ + --exclude=release_test.py \ + --exclude-dir=.* \ + VERSION_NEXT_ -r || grep_exit_code=$? + +if [[ $grep_exit_code -eq 0 ]]; then + echo + echo "Found VERSION_NEXT markers indicating version needs to be specified" + exit 1 +fi diff --git a/.github/workflows/create_archive_and_notes.sh b/.github/workflows/create_archive_and_notes.sh index a3cf8280a2..91ffe4ad32 100755 --- a/.github/workflows/create_archive_and_notes.sh +++ b/.github/workflows/create_archive_and_notes.sh @@ -29,22 +29,6 @@ git fetch origin tag "$TAG" # Update our local state so the grep command below searches what we expect git checkout "$TAG" -# Exclude dot directories, specifically, this file so that we don't -# find the substring we're looking for in our own file. -# Exclude CONTRIBUTING.md, RELEASING.md because they document how to use these strings. -grep --exclude=CONTRIBUTING.md \ - --exclude=RELEASING.md \ - --exclude=release.py \ - --exclude=release_test.py \ - --exclude-dir=.* \ - VERSION_NEXT_ -r || grep_exit_code=$? - -if [[ $grep_exit_code -eq 0 ]]; then - echo - echo "Found VERSION_NEXT markers indicating version needs to be specified" - exit 1 -fi - # A prefix is added to better match the GitHub generated archives. PREFIX="rules_python-${TAG}" ARCHIVE="rules_python-$TAG.tar.gz" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c565b03fa0..5e7c040bf1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,6 +43,8 @@ jobs: uses: actions/checkout@v6 with: ref: ${{ github.ref_name }} + - name: Check version markers + run: .github/workflows/check_version_markers.sh ${{ inputs.tag_name || github.ref_name }} - name: Create release archive and notes run: .github/workflows/create_archive_and_notes.sh ${{ inputs.tag_name || github.ref_name }} - name: Release