Skip to content

Commit 7fcdc8b

Browse files
committed
fix: update release workflow to extract version from commit message
1 parent 76e2114 commit 7fcdc8b

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

.github/workflows/release.yml

+11-12
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ jobs:
2626
- name: Set env.COMMIT_HASH
2727
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
2828

29-
- name: Extract version from commit message
30-
id: extract_version
29+
- name: Get version from commit
3130
run: |
32-
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
33-
if [[ $COMMIT_MESSAGE =~ release:\ v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
34-
echo "VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
31+
VERSION=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=Release v)\d+\.\d+\.\d+' || echo '')
32+
if [ ! -z "$VERSION" ]; then
33+
echo "VERSION=$VERSION" >> $GITHUB_ENV
3534
else
3635
echo "No version found in commit message"
3736
exit 1
@@ -49,17 +48,17 @@ jobs:
4948
5049
- name: Rename build files
5150
run: |
52-
mv bin/transit-linux-x64 bin/transit-${{env.VERSION}}-linux-x64
53-
mv bin/transit-linux-arm64 bin/transit-${{env.VERSION}}-linux-arm64
54-
mv bin/transit-windows-x64.exe bin/transit-${{env.VERSION}}-windows-x64.exe
51+
mv bin/transit-linux-x64 bin/transit-${{ github.env.VERSION }}-linux-x64
52+
mv bin/transit-linux-arm64 bin/transit-${{ github.env.VERSION }}-linux-arm64
53+
mv bin/transit-windows-x64.exe bin/transit-${{ github.env.VERSION }}-windows-x64.exe
5554
5655
- name: Create release and upload assets
5756
uses: softprops/action-gh-release@v1
5857
with:
59-
tag_name: 'v${{env.VERSION}}'
58+
tag_name: 'v${{ github.env.VERSION }}'
6059
files: |
61-
bin/transit-${{env.VERSION}}-linux-x64
62-
bin/transit-${{env.VERSION}}-linux-arm64
63-
bin/transit-${{env.VERSION}}-windows-x64.exe
60+
bin/transit-${{ github.env.VERSION }}-linux-x64
61+
bin/transit-${{ github.env.VERSION }}-linux-arm64
62+
bin/transit-${{ github.env.VERSION }}-windows-x64.exe
6463
env:
6564
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)