99 build :
1010 runs-on : ubuntu-latest
1111 steps :
12- - uses : actions/checkout@v3
13- - name : Create a Release
14- uses : elgohr/Github-Release-Action@v5
15- env :
16- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
17- with :
18- title : MyReleaseMessage
12+ - uses : actions/checkout@v3
13+
14+ - name : Get latest version tag
15+ id : get_version
16+ run : |
17+ # Fetch tags from the repository
18+ git fetch --tags
19+ # Get the latest tag, if exists, otherwise default to v0.0.0
20+ latest_tag=$(git describe --tags --abbrev=0 || echo "v0.0.0")
21+ echo "Latest tag: $latest_tag"
22+
23+ # Split the version into its components
24+ major=$(echo $latest_tag | cut -d. -f1 | tr -d 'v')
25+ minor=$(echo $latest_tag | cut -d. -f2)
26+ patch=$(echo $latest_tag | cut -d. -f3)
27+
28+ # Increment the patch version
29+ patch=$((patch + 1))
30+
31+ # Create the new version tag
32+ new_version="v$major.$minor.$patch"
33+ echo "New version: $new_version"
34+
35+ # Set the new version as an output
36+ echo "::set-output name=version::$new_version"
37+
38+ - name : Create a Release
39+ uses : elgohr/Github-Release-Action@v5
40+ env :
41+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
42+ with :
43+ title : Release ${{ steps.get_version.outputs.version }}
44+ tag_name : ${{ steps.get_version.outputs.version }}
0 commit comments