Skip to content

Commit

Permalink
add tag release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetb committed Apr 21, 2024
1 parent a8956f1 commit 2fb8be9
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Tag a Patch Release on Commit

on:
push:
branches:
- master # Adjust to match the name of your main branch

jobs:
tag:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Important to fetch all tags and history

# Determine the new version number
- name: Get latest tag and increment
id: versioning
run: |
# Fetch all tags
git fetch --tags
# Get the highest tag number, and add 1 to the patch
TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Current highest tag is $TAG"
# Increment the patch version
NEW_TAG="${TAG%.*}.$((${TAG##*.}+1))"
echo "New tag will be $NEW_TAG"
# Set NEW_TAG as an output variable
echo "NEW_VERSION=$NEW_TAG" >> $GITHUB_ENV
# Create a new tag
- name: Create Git tag for PR
uses: actions/github-script@v7
with:
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{env.NEW_VERSION}}",
sha: context.sha
})

0 comments on commit 2fb8be9

Please sign in to comment.