Skip to content

Commit

Permalink
fix release version
Browse files Browse the repository at this point in the history
  • Loading branch information
yuleib committed May 11, 2023
1 parent d52a9cb commit f1342b0
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/package-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ on:
# type: boolean
# default: true
push:
branches: [main]
tags:
- 'v*.*.*'

Expand Down Expand Up @@ -74,12 +75,29 @@ jobs:
next_version=$((version + 1))
echo "Next version: $next_version"
# - name: Set tag name
# id: set_tag_name
# run: |
# next_version=$((${{ github.event_name == 'release' }} ? $(echo "${{ github.ref }}" | awk -F'/' '{print $3}') : $(echo "${{ github.ref }}-$(date +%s)" | awk -F'/' '{print $3}')))
# tag_name=v$(echo "$next_version" | cut -d'.' -f-3)
# echo "{name}={$tag_name}" >> $GITHUB_OUTPUT
# continue-on-error: true

- name: Set tag name
id: set_tag_name
run: |
next_version=$((${{ github.event_name == 'release' }} ? $(echo "${{ github.ref }}" | awk -F'/' '{print $3}') : $(echo "${{ github.ref }}-$(date +%s)" | awk -F'/' '{print $3}')))
tag_name=v$(echo "$next_version" | cut -d'.' -f-3)
echo "::set-output name=tag_name::$tag_name"
# Get the latest tag name in the repository
last_tag=$(git describe --tags --abbrev=0)
# Extract the major, minor, and patch version numbers from the latest tag
major=$(echo "$last_tag" | cut -d'.' -f1 | sed 's/v//')
minor=$(echo "$last_tag" | cut -d'.' -f2)
patch=$(echo "$last_tag" | cut -d'.' -f3)
# Increment the patch version number
next_patch=$(($patch + 1))
# Set the new tag name with the incremented patch version number
tag_name="v$major.$minor.$next_patch"
# Set the tag_name output variable
echo "{name}={$tag_name}" >> $GITHUB_OUTPUT
continue-on-error: true

- name: Create release
Expand Down

0 comments on commit f1342b0

Please sign in to comment.