Merge branch 'main' into staging #32
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: Create Staging Tag | |
on: | |
push: | |
branches: | |
- staging | |
jobs: | |
increment-tag: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: 0 | |
- name: Set up Git | |
run: | | |
git config user.name "github-actions" | |
git config user.email "github-actions@github.com" | |
- name: Get the latest staging tag | |
id: get_latest_tag | |
run: | | |
latest_tag=$(git tag --list --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-staging$' | head -n 1) | |
echo "Latest Tag: $latest_tag" | |
echo "::set-output name=latest_tag::$latest_tag" | |
- name: Increment the tag | |
id: increment_tag | |
run: | | |
latest_tag=${{ steps.get_latest_tag.outputs.latest_tag }} | |
if [ -z "$latest_tag" ]; then | |
echo "No matching tags found." | |
exit 1 | |
fi | |
# Extract the major, minor, patch versions | |
IFS='.-' read -r major minor patch _ <<< "$latest_tag" | |
# Increment the patch version | |
patch=$((patch + 1)) | |
# Construct the new tag | |
new_tag="$major.$minor.$patch-staging" | |
echo "New Tag: $new_tag" | |
echo "::set-output name=new_tag::$new_tag" | |
- name: Create and push new tag | |
run: | | |
new_tag=${{ steps.increment_tag.outputs.new_tag }} | |
git tag "$new_tag" | |
git push origin "$new_tag" |