Skip to content

Commit d66f0ac

Browse files
label based release
1 parent 916dec2 commit d66f0ac

File tree

1 file changed

+51
-14
lines changed

1 file changed

+51
-14
lines changed

.github/workflows/release.yml

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
name: Release
22

33
on:
4-
workflow_run:
5-
workflows: ["Swift"]
6-
types:
7-
- completed
4+
pull_request:
5+
types: [closed]
86
branches: [ "main" ]
97

108
jobs:
119
release:
1210
runs-on: ubuntu-latest
13-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
11+
# Only run when PR is merged (not just closed) and has 'release' label
12+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
1413
permissions:
1514
contents: write
1615
steps:
@@ -41,8 +40,21 @@ jobs:
4140
MINOR=${VERSION_PARTS[1]:-0}
4241
PATCH=${VERSION_PARTS[2]:-0}
4342
44-
# Increment patch version
45-
PATCH=$((PATCH + 1))
43+
# Check PR labels for version bump type
44+
if ${{ contains(github.event.pull_request.labels.*.name, 'major') }}; then
45+
MAJOR=$((MAJOR + 1))
46+
MINOR=0
47+
PATCH=0
48+
echo "Major version bump"
49+
elif ${{ contains(github.event.pull_request.labels.*.name, 'minor') }}; then
50+
MINOR=$((MINOR + 1))
51+
PATCH=0
52+
echo "Minor version bump"
53+
else
54+
# Default to patch bump
55+
PATCH=$((PATCH + 1))
56+
echo "Patch version bump"
57+
fi
4658
4759
# Create new version
4860
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
@@ -57,19 +69,44 @@ jobs:
5769
git tag -a "$NEW_VERSION" -m "Release version $NEW_VERSION"
5870
git push origin "$NEW_VERSION"
5971
72+
- name: Generate release notes
73+
id: release_notes
74+
run: |
75+
# Extract PR body for release notes
76+
PR_BODY=$(cat << 'EOF'
77+
${{ github.event.pull_request.body }}
78+
EOF
79+
)
80+
81+
# Create release notes
82+
cat << EOF > release_notes.md
83+
## Release ${{ steps.next_version.outputs.new_version }}
84+
85+
### Pull Request
86+
#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}
87+
88+
### Description
89+
${PR_BODY}
90+
91+
### Changes
92+
See the [full changelog](https://github.com/${{ github.repository }}/compare/${{ steps.get_tag.outputs.latest_tag }}...${{ steps.next_version.outputs.new_version }})
93+
94+
### Contributors
95+
- @${{ github.event.pull_request.user.login }}
96+
EOF
97+
98+
# Output the release notes
99+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
100+
cat release_notes.md >> $GITHUB_OUTPUT
101+
echo "EOF" >> $GITHUB_OUTPUT
102+
60103
- name: Create Release
61104
uses: actions/create-release@v1
62105
env:
63106
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64107
with:
65108
tag_name: ${{ steps.next_version.outputs.new_version }}
66109
release_name: Release ${{ steps.next_version.outputs.new_version }}
67-
body: |
68-
## Changes in this release
69-
70-
Auto-generated release for version ${{ steps.next_version.outputs.new_version }}
71-
72-
### What's Changed
73-
See the [commit history](https://github.com/${{ github.repository }}/compare/${{ steps.get_tag.outputs.latest_tag }}...${{ steps.next_version.outputs.new_version }}) for a full list of changes.
110+
body: ${{ steps.release_notes.outputs.release_notes }}
74111
draft: false
75112
prerelease: false

0 commit comments

Comments
 (0)