update build-and-publish workflow to use official actions #6
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
# Copyright (c) 2024 MobileCoin Inc. | |
name: tag | |
on: | |
push: | |
branches: | |
- main | |
# when the gh publishes a new ghcr.io/actions/actions-runner image renovate should PR and add in a message like `[tag/2.310.0]` | |
# capture this output and tag the repo triggering the other build actions. | |
jobs: | |
tag: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_PAT }} | |
- env: | |
MESSAGE: ${{ github.event.head_commit.message }} | |
shell: bash | |
run: | | |
# look for sting like "[tag/v2.312.0]" in commit message. | |
regex=".*\[tag/(.*)\].*" | |
if [[ "${MESSAGE}" =~ $regex ]] | |
then | |
tag="${BASH_REMATCH[1]}" | |
# remove v prefix if it exists. | |
tag="${tag/#v/}" | |
echo "Found tag: ${tag}" | |
git tag --force "${tag}" | |
git push --tags --force | |
else | |
echo "Could not find tag in commit message" | |
echo "${MESSAGE}" | |
exit 0 | |
fi |