Skip to content

tag-release

tag-release #2

Workflow file for this run

name: Tag Release
on:
workflow_dispatch:
jobs:
tag_release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read versions.yaml
id: read-version
run: |
VERSION=$(awk '/version:/ {print $2}' versions.yaml)
echo "Version to tag: $VERSION"
echo "tag-name=$(echo "${VERSION}")" >> "$GITHUB_OUTPUT"
- name: Find next tag version
id: find-tag
run: |
VERSION=${{ steps.read-version.outputs.tag-name }}
while git rev-parse "refs/tags/$VERSION" >/dev/null 2>&1; do
echo "Tag $VERSION already exists, incrementing..."
IFS='.' read -r -a VERSION_PARTS <<< "$VERSION"
LAST_PART=${VERSION_PARTS[-1]}
NEXT_PART=$((LAST_PART + 1))
VERSION_PARTS[-1]=$NEXT_PART
VERSION=$(IFS='.'; echo "${VERSION_PARTS[*]}")
done
echo "next-version=$(echo "${VERSION}")" >> "$GITHUB_OUTPUT"
- name: Tag the release
if: steps.find-tag.outputs.next-version
run: |
NEXT_VERSION=${{ steps.find-tag.outputs.next-version }}
echo "Creating tag $NEXT_VERSION"
git tag "$NEXT_VERSION"
git push origin "$NEXT_VERSION"