Skip to content

Commit 4185582

Browse files
committed
Update release.yml
1 parent 6b9e995 commit 4185582

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@ name: Build & Release Executable
33
on:
44
push:
55
branches:
6-
- main # Runs on each push to main
6+
- main # Runs only on push to main
77
workflow_dispatch: # Allow manual trigger
88

99
jobs:
1010
build:
11-
# if: github.event.pull_request.merged == true # Ensures it's a merge
12-
runs-on: windows-2019
11+
runs-on: windows-latest
1312

1413
steps:
1514
- name: Checkout Repository
1615
uses: actions/checkout@v4
1716

17+
- name: Check if Commit is from Merged PR
18+
id: check_merge
19+
run: |
20+
gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls > pulls.json
21+
if jq 'length == 0' pulls.json; then
22+
echo "This commit is not from a merged PR. Skipping workflow."
23+
exit 1
24+
fi
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
1828
- name: Set up Python
1929
uses: actions/setup-python@v4
2030
with:
@@ -38,15 +48,21 @@ jobs:
3848
3949
- name: Get Last Commit Hash
4050
id: get_commit
51+
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
52+
53+
- name: Create Tag
4154
run: |
42-
echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
55+
git tag ${{ env.COMMIT_HASH }}
56+
git push origin ${{ env.COMMIT_HASH }}
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4359

4460
- name: Create GitHub Release
4561
uses: softprops/action-gh-release@v2
4662
with:
4763
token: ${{ secrets.GITHUB_TOKEN }}
48-
tag_name: ${{ env.commit_hash }}
49-
release_name: ${{ env.commit_hash }}
64+
tag_name: ${{ env.COMMIT_HASH }}
65+
name: Release ${{ env.COMMIT_HASH }} # Corrected 'release_name' to 'name'
5066
draft: false
5167
prerelease: false
5268
files: |

0 commit comments

Comments
 (0)