Skip to content
Open
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
32 changes: 32 additions & 0 deletions .github/workflows/check_version_markers.sh
Original file line number Diff line number Diff line change
@@ -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
16 changes: 0 additions & 16 deletions .github/workflows/create_archive_and_notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Optional, non-blocking] It might be prudent to call check_version_markers.sh from this script.

  • Removes the extra step in the release flow (I'm not sure what the GH step overhead is)
  • There's no risk of forgetting to check for VERSION_NEXT markers (if this create_archive_and_notes.sh` script is ever called outside of CI).

# 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"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down