Skip to content

Merge pull request #4 from yepzdk/feature/auto-release-and-branch-pro… #1

Merge pull request #4 from yepzdk/feature/auto-release-and-branch-pro…

Merge pull request #4 from yepzdk/feature/auto-release-and-branch-pro… #1

Workflow file for this run

name: Auto Tag on Merge
on:
push:
branches:
- main
# Don't trigger on tag pushes
tags-ignore:
- '*'
permissions:
contents: write
jobs:
auto-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for tags
- name: Get latest tag
id: get_tag
run: |
# Get the latest tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "Latest tag: $LATEST_TAG"
- name: Calculate next version
id: next_version
run: |
LATEST_TAG="${{ steps.get_tag.outputs.latest_tag }}"
# Remove 'v' prefix and split into parts
VERSION="${LATEST_TAG#v}"
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
PATCH=$(echo $VERSION | cut -d. -f3)
# Increment patch version
NEW_PATCH=$((PATCH + 1))
NEW_TAG="v${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
echo "Next version: $NEW_TAG"
- name: Create and push tag
run: |
NEW_TAG="${{ steps.next_version.outputs.new_tag }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$NEW_TAG" -m "Release $NEW_TAG"
git push origin "$NEW_TAG"
echo "Created and pushed tag: $NEW_TAG"