-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-tag whenever version in MODULE.bazel changes
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,3 +236,42 @@ jobs: | |
with: | ||
name: ${{ env.OUT }} | ||
path: ${{ env.OUT }}.tar.gz | ||
|
||
release-tagging: | ||
name: Version Tagging | ||
runs-on: ubuntu-24.04 | ||
#if: ${{github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/main')}} | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Tag with MODULES.bazel version if not already. | ||
run: | | ||
version_from_module_bazel() { | ||
git annotate -l MODULE.bazel \ | ||
| awk '/module/ { in_module=1; } | ||
/version/ { if (in_module) { print $0; nextfile; } }' \ | ||
| sed 's/\(^[0-9a-f]*\).*version[ ]*=[ ]*"\([0-9.]*\)".*/\1 \2/p;d' | ||
} | ||
git config --local user.name "Development Bot" | ||
git config --local user.email "[email protected]" | ||
# We want to tag whenever the version in MODULE.bazel changes. | ||
# So extract the hash of when the current version was entered. | ||
read TAG_HASH TAG_VERSION <<<$(version_from_module_bazel) | ||
echo "Bant Version v${TAG_VERSION} at hash ${TAG_HASH}" | ||
# If this is the first time we see this tag: apply. | ||
if [ -z "$(git tag -l "v${TAG_VERSION}")" ]; then | ||
git tag -a "v${TAG_VERSION}" ${TAG_HASH} -m "Update to v${TAG_VERSION}" | ||
git push origin "v${TAG_VERSION}" | ||
else | ||
echo "Tag already applied" | ||
fi |