2020 id : check_commits
2121 env :
2222 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
23- run : |
24- REPO="${{ github.repository }}"
25- TAG="$(gh api "repos/${REPO}/tags" --jq '.[0].name' 2>/dev/null || echo '')"
26- if [ -z "$TAG" ]; then
27- echo "No tags found, proceeding with release."
28- echo "has_commits=true" >> $GITHUB_OUTPUT
29- else
30- AHEAD="$(gh api "repos/${REPO}/compare/${TAG}...main" --jq '.ahead_by')"
31- if [ "$AHEAD" -eq 0 ]; then
32- echo "No new commits since $TAG, skipping release."
33- echo "has_commits=false" >> $GITHUB_OUTPUT
34- else
35- echo "$AHEAD new commits since $TAG."
36- echo "has_commits=true" >> $GITHUB_OUTPUT
37- fi
38- fi
23+ run : .github/scripts/check-new-commits.sh
3924
4025 release-pr :
4126 needs : check
@@ -47,72 +32,19 @@ jobs:
4732 with :
4833 fetch-depth : 0
4934
50- - name : Increment version number
51- run : perl -i -pe 's/\b(\d+)(?=\D*$)/$1+1/e' VERSION
52-
53- - name : Get changelog
54- id : changelog
55- run : |
56- TAG="$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)"
57- GIT_LOG="$(git log $TAG..HEAD --oneline --pretty=format:"- %s [%an]")"
58- CHANGELOG=$(cat << EOF
59- Changelog:
60- $GIT_LOG
61- EOF
62- )
63- CHANGELOG="${CHANGELOG//'#'/''}"
64- echo "content<<EOF" >> "$GITHUB_OUTPUT"
65- echo "$CHANGELOG" >> "$GITHUB_OUTPUT"
66- echo "EOF" >> "$GITHUB_OUTPUT"
67-
68- - name : Display changelog
69- run : |
70- cat <<'EOF'
71- ${{ steps.changelog.outputs.content }}
72- EOF
73-
74- - name : Get version
75- run : |
76- VERSION="$(cat VERSION)"
77- echo "VERSION=$VERSION" >> $GITHUB_ENV
78-
79- - name : Get commit message
80- id : message
81- run : |
82- COMMIT_MSG=$(cat << 'EOF'
83- Release v${{ env.VERSION }}
84-
85- ${{ steps.changelog.outputs.content }}
86- EOF
87- )
88- echo "content<<EOF" >> "$GITHUB_OUTPUT"
89- echo "$COMMIT_MSG" >> "$GITHUB_OUTPUT"
90- echo "EOF" >> "$GITHUB_OUTPUT"
91-
92- - name : Get pull request body message
93- id : body
94- run : |
95- MSG=$(cat << 'EOF'
96- Auto-generated pull request for version ${{ env.VERSION }}.
97-
98- Please use **Squash and merge** to include the changelog in the release message.
99-
100- ${{ steps.changelog.outputs.content }}
101- EOF
102- )
103- echo "content<<EOF" >> "$GITHUB_OUTPUT"
104- echo "$MSG" >> "$GITHUB_OUTPUT"
105- echo "EOF" >> "$GITHUB_OUTPUT"
35+ - name : Prepare release
36+ id : release
37+ run : .github/scripts/prepare-release.sh
10638
10739 - name : Create Pull Request
10840 uses : peter-evans/create-pull-request@v8
10941 with :
11042 base : main
11143 add-paths : VERSION
11244 reviewers : antoninbas, jafingerhut, smolkaj
113- commit-message : ${{ steps.message .outputs.content }}
45+ commit-message : ${{ steps.release .outputs.commit_msg }}
11446 signoff : false
11547 branch : v${{ env.VERSION }}
11648 delete-branch : true
11749 title : Automated Release v${{ env.VERSION }}
118- body : ${{ steps.body .outputs.content }}
50+ body : ${{ steps.release .outputs.pr_body }}
0 commit comments