-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gha): edit latest auto tag, add auto major tag
- Loading branch information
1 parent
109f8aa
commit 23568f1
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
.github/workflows/move-latest-tag.yaml → ...ub/workflows/auto-tag-latest-version.yaml
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
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
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 |