Update action.yml #9
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: Generate a New Tag for Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
env: | ||
BUG_OR_FEAT: | | ||
${{ endsWith(github.event.head_commit.message, '[tag-bug]') && 1 || | ||
(endsWith(github.event.head_commit.message, '[tag-feat]') && 1 || 0) }} | ||
jobs: | ||
build: | ||
name: Release to GitHub releases | ||
runs-on: ubuntu-latest | ||
if: ${{ bug_or_feat }} | ||
Check failure on line 18 in .github/workflows/release.yml GitHub Actions / Generate a New Tag for ReleaseInvalid workflow file
|
||
steps: | ||
- name: Set the Git config | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: '0' | ||
- name: Generate tag | ||
run: | | ||
VERSION_MAJOR="1" | ||
VERSION_MINOR=$(git tag --list "${VERSION_MAJOR}.[0-9]*.[0-9]*" --sort=-version:refname | head -n 1 | grep -oE '[0-9]+\.[0-9]+$' | grep -oE '^[0-9]+') | ||
VERSION_PATCH=$(git tag --list "${VERSION_MAJOR}.[0-9]*.[0-9]*" --sort=-version:refname | head -n 1 | grep -oE '[0-9]+$') | ||
if [ "$BUG_OR_FEAT" -eq 1 ]; then | ||
NEW_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.$((VERSION_PATCH + 1))" | ||
elif [ "$BUG_OR_FEAT" -eq 2 ]; then | ||
NEW_VERSION="${VERSION_MAJOR}.$((VERSION_MINOR + 1)).0" | ||
else | ||
echo "Critical error..!" | ||
fi | ||
echo "Generated new version: $NEW_VERSION" | ||
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | ||
- name: Push Git Tag | ||
run: | | ||
git tag $NEW_TAG | ||
git tag -a $NEW_VERSION -m "v$NEW_VERSION" | ||
git push origin $NEW_VERSION | ||
- name: Update the v1 tag with the latest code | ||
run: | | ||
git tag -fa v1 -m "Update the v1 tag with the latest code" | ||
git push origin v1 --force |