Skip to content

Commit

Permalink
chore(gha): edit latest auto tag, add auto major tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Windemiatrix committed May 29, 2024
1 parent 109f8aa commit 23568f1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Move Latest Tag
name: Auto-Tag Latest Version

on:
release:
types: [created]
types: [published]

jobs:
move-latest-tag:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/auto-tag-major-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Auto-Tag Major Version

on:
release:
types: [published]

jobs:
tag-major-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Tag Major Version
run: |
FULL_TAG=${{ github.event.release.tag_name }}
MAJOR_VERSION=$(echo "$FULL_TAG" | sed -E 's/^v([0-9]+)\..*/v\1/')
if git rev-parse "$MAJOR_VERSION" >/dev/null 2>&1; then
echo "Tag $MAJOR_VERSION already exists. Updating the tag..."
git tag -fa "$MAJOR_VERSION" -m "Update major version tag to $MAJOR_VERSION" ${{ github.event.release.target_commitish }}
else
echo "Creating new tag $MAJOR_VERSION..."
git tag -a "$MAJOR_VERSION" -m "Create major version tag $MAJOR_VERSION" ${{ github.event.release.target_commitish }}
fi
git push origin "$MAJOR_VERSION" --force

0 comments on commit 23568f1

Please sign in to comment.