Skip to content

Commit 856b7d5

Browse files
committed
update workflow
1 parent c9ecaea commit 856b7d5

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

.github/workflows/update_version.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
release:
55
types: [published]
66
workflow_dispatch:
7-
push: # to be removed
7+
# push: # to be removed - Remove this entirely when done testing
88

99
permissions:
1010
contents: write
@@ -16,27 +16,49 @@ jobs:
1616
steps:
1717
- name: Checkout repository
1818
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Fetch all history for git operations
1921

2022
- name: Get version
2123
id: get_version
2224
run: |
2325
if [ "${{ github.event_name }}" = "release" ]; then
24-
echo "VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
26+
VERSION="${{ github.event.release.tag_name }}"
2527
else
26-
latest_tag=$(gh release list --limit 1 --json tagName -q '.[0].tagName')
27-
echo "VERSION=${latest_tag}" >> $GITHUB_ENV
28+
VERSION=$(gh release list --limit 1 --json tagName -q '.[0].tagName')
29+
fi
30+
31+
# Remove 'v' prefix if present
32+
VERSION="${VERSION#v}"
33+
34+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
35+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
2836
env:
2937
GH_TOKEN: ${{ github.token }}
3038

3139
- name: Write version to version.txt
32-
run: echo "${VERSION}" > version.txt
40+
run: echo "${{ env.VERSION }}" > version.txt
41+
42+
- name: Check if changes exist
43+
id: check_changes
44+
run: |
45+
if git diff --quiet version.txt; then
46+
echo "has_changes=false" >> $GITHUB_OUTPUT
47+
else
48+
echo "has_changes=true" >> $GITHUB_OUTPUT
49+
fi
3350
3451
- name: Create PR for version.txt update
35-
id: cpr
52+
if: steps.check_changes.outputs.has_changes == 'true'
3653
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
3754
with:
38-
commit-message: "Update version.txt to ${VERSION}"
55+
commit-message: "chore: update version.txt to ${{ env.VERSION }}"
3956
branch: update-version-txt-${{ github.run_id }}
40-
title: "Update version.txt to ${VERSION}"
41-
body: "This PR updates version.txt to the latest release version (${VERSION})."
42-
labels: "automation, version-update"
57+
title: "chore: update version.txt to ${{ env.VERSION }}"
58+
body: |
59+
This PR updates version.txt to the latest release version.
60+
61+
**Version**: ${{ env.VERSION }}
62+
**Triggered by**: ${{ github.event_name }}
63+
labels: automation,version-update
64+
delete-branch: true

0 commit comments

Comments
 (0)