Skip to content

Commit dd59661

Browse files
committed
feature: updated workflow
1 parent 8b9c750 commit dd59661

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

.github/workflows/tag_version_and_publish.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
name: Tag Version and Publish on Push to Master
22

33
on:
4-
push:
4+
pull_request:
5+
types:
6+
- closed
57
branches:
68
- master
79

810
jobs:
911
tag_version_and_publish:
12+
if: github.event.pull_request.merged == true
1013

1114
runs-on: self-hosted
1215

@@ -22,20 +25,24 @@ jobs:
2225
- name: Create tag
2326
id: create_tag
2427
run: |
25-
# Checks if the tag already exists in the remote repository
28+
# Check if the tag already exists in the remote repository
2629
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
27-
echo "Error: Tag v${{ env.VERSION }} already exists."
28-
exit 1
29-
fi
30-
31-
# Check if the version was found
32-
if [ -z "${{ env.VERSION }}" ]; then
33-
echo "Error: No version found in pubspec.yml"
34-
exit 1
30+
echo "Tag v${{ env.VERSION }} already exists."
31+
else
32+
# Create and push the new tag
33+
git tag "v${{ env.VERSION }}"
34+
git push origin "v${{ env.VERSION }}"
3535
fi
3636
37-
git tag "v${{ env.VERSION }}"
38-
git push origin "v${{ env.VERSION }}"
37+
- name: Create release
38+
if: ${{ steps.create_tag.outcome == 'success' }}
39+
uses: softprops/action-gh-release@v2
40+
with:
41+
tag_name: "v${{ env.VERSION }}"
42+
name: "${{ github.event.pull_request.title }}"
43+
body: "${{ github.event.pull_request.body }}"
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3946

4047
- name: Handle job completion
4148
if: always()

0 commit comments

Comments
 (0)