Workflow file for this run
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
--- | |
name: Tag major version on release | |
on: | |
release: | |
types: | |
- published | |
jobs: | |
tag-release: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Tag release with vX tag | |
shell: bash | |
run: | | |
RELEASE_NAME="${GITHUB_REF#refs/tags/}" | |
echo "Release name: ${RELEASE_NAME}" | |
if [[ "${RELEASE_NAME}" =~ ^(v[0-9]+)[.] ]]; then | |
RELEASE_TAG_SHORT="${BASH_REMATCH[1]}" | |
echo "Release tag short: ${RELEASE_TAG_SHORT}" | |
# Git config | |
git config --local user.name 10upbot | |
git config --local user.email 10upbot+github@10up.com | |
# Create tag locally | |
git tag -f -a "${RELEASE_TAG_SHORT}" -m "Automated GitHub Actions release: ${RELEASE_TAG_SHORT}" | |
# Delete remote tag | |
git push origin :refs/tags/"${RELEASE_TAG_SHORT}" | |
# Push tag to remote | |
git push origin "${RELEASE_TAG_SHORT}" | |
else | |
echo "Release name does not match vX pattern: ${RELEASE_NAME}" | |
echo "Nothing to do!" | |
fi |