Skip to content

Commit 69b2440

Browse files
committed
Fix generating release notes
1 parent 7d7ab3b commit 69b2440

File tree

1 file changed

+73
-54
lines changed

1 file changed

+73
-54
lines changed

.github/workflows/releases.yml

Lines changed: 73 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,16 @@ jobs:
2727
- name: Remove optional "v" prefix
2828
id: version
2929
run: |
30-
VERSION=${{ inputs.version }}
3130
echo "version=${VERSION#v}" >> "$GITHUB_OUTPUT"
31+
env:
32+
VERSION: ${{ inputs.version }}
3233

3334
- name: Check if branch and version match
3435
id: guard
3536
run: |
3637
MAJOR_VERSION="${NUMERIC_VERSION%%.*}"
3738
BRANCH_MAJOR_VERSION="${BRANCH%%.*}"
3839
39-
echo "MAJOR_VERSION=$(echo $MAJOR_VERSION)" >> $GITHUB_OUTPUT;
40-
echo "BRANCH_MAJOR_VERSION=$(echo $BRANCH_MAJOR_VERSION)" >> $GITHUB_OUTPUT;
41-
4240
if [ "$MAJOR_VERSION" != "$BRANCH_MAJOR_VERSION" ]; then
4341
echo "Mismatched versions! Aborting."
4442
VERSION_MISMATCH='true';
@@ -47,7 +45,7 @@ jobs:
4745
VERSION_MISMATCH='false';
4846
fi
4947
50-
echo "VERSION_MISMATCH=$(echo $VERSION_MISMATCH)" >> $GITHUB_OUTPUT;
48+
echo "VERSION_MISMATCH=$(echo $VERSION_MISMATCH)" >> "$GITHUB_OUTPUT";
5149
env:
5250
BRANCH: ${{ github.ref_name }}
5351
NUMERIC_VERSION: ${{ steps.version.outputs.version }}
@@ -67,53 +65,74 @@ jobs:
6765
with:
6866
commit_message: "Update version to v${{ steps.version.outputs.version }}"
6967

70-
- name: SSH into splitter server
71-
uses: appleboy/ssh-action@master
68+
# - name: SSH into splitter server
69+
# uses: appleboy/ssh-action@master
70+
# with:
71+
# host: 104.248.56.26
72+
# username: forge
73+
# key: ${{ secrets.SSH_PRIVATE_KEY_SPLITTER }}
74+
# script: |
75+
# cd laravel-${{ github.ref_name }}
76+
# git pull origin ${{ github.ref_name }}
77+
# bash ./bin/release.sh v${{ steps.version.outputs.version }}
78+
# script_stop: true
79+
80+
- name: Generate release notes
81+
id: generated-notes
82+
uses: RedCrafter07/release-notes-action@main
7283
with:
73-
host: 104.248.56.26
74-
username: forge
75-
key: ${{ secrets.SSH_PRIVATE_KEY_SPLITTER }}
76-
script: |
77-
cd laravel-${{ github.ref_name }}
78-
git pull origin ${{ github.ref_name }}
79-
bash ./bin/release.sh v${{ steps.version.outputs.version }}
80-
script_stop: true
81-
82-
# - name: Generate release notes
83-
# id: generated-notes
84-
# uses: RedCrafter07/release-notes-action@main
85-
# with:
86-
# tag-name: v${{ steps.version.outputs.version }}
87-
# token: ${{ secrets.GITHUB_TOKEN }}
88-
# branch: ${{ github.ref_name }}
89-
90-
# - name: Cleanup release notes
91-
# id: cleaned-notes
92-
# run: |
93-
# RELEASE_NOTES=$(echo $RELEASE_NOTES | sed '/## What/d')
94-
# RELEASE_NOTES=$(echo $RELEASE_NOTES | sed '/## New Contributors/,$d')
95-
# echo "notes=${RELEASE_NOTES}" >> "$GITHUB_OUTPUT"
96-
# env:
97-
# RELEASE_NOTES: ${{ steps.generated-notes.outputs.release-notes }}
98-
99-
# - name: Create release
100-
# uses: softprops/action-gh-release@v2
101-
# env:
102-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103-
# with:
104-
# tag_name: v${{ steps.version.outputs.version }}
105-
# name: v${{ steps.version.outputs.version }}
106-
# body: ${{ steps.cleaned-notes.outputs.notes }}
107-
# target_commitish: ${{ github.ref_name }}
108-
# make_latest: 'legacy'
109-
110-
# update-changelog:
111-
# needs: release
112-
113-
# name: Update changelog
114-
115-
# uses: laravel/.github/.github/workflows/update-changelog.yml@main
116-
# with:
117-
# branch: ${{ github.ref_name }}
118-
# version: "v${{ needs.release.outputs.version }}"
119-
# notes: ${{ needs.release.outputs.notes }}
84+
tag-name: v${{ steps.version.outputs.version }}
85+
token: ${{ secrets.GITHUB_TOKEN }}
86+
branch: ${{ github.ref_name }}
87+
88+
- name: Cleanup release notes
89+
id: cleaned-notes
90+
run: |
91+
START_FROM=$(echo -n "$RELEASE_NOTES" | awk "/What's Changed/{ print NR; exit }" -)
92+
DROP_FROM_CONTRIBUTORS=$(echo -n "$RELEASE_NOTES" | awk "/New Contributors/{ print NR; exit }" -)
93+
DROP_FROM_FULL_CHANGELOG=$(echo -n "$RELEASE_NOTES" | awk "/Full Changelog/{ print NR; exit }" -)
94+
95+
# Drop everything starting from "Full Changelog"
96+
if [ ! -z "$DROP_FROM_FULL_CHANGELOG" ]; then
97+
RELEASE_NOTES=$(echo -n "$RELEASE_NOTES" | sed "${DROP_FROM_FULL_CHANGELOG},$ d")
98+
fi
99+
100+
# Drop everything starting from "New Contributors"
101+
if [ ! -z "$DROP_FROM_CONTRIBUTORS" ]; then
102+
RELEASE_NOTES=$(echo -n "$RELEASE_NOTES" | sed "${DROP_FROM_CONTRIBUTORS},$ d")
103+
fi
104+
105+
# Drop the line "What's Changed"
106+
if [ ! -z "$START_FROM" ]; then
107+
RELEASE_NOTES=$(echo -n "$RELEASE_NOTES" | sed "${START_FROM}d")
108+
fi
109+
110+
{
111+
echo 'notes<<EOF'
112+
echo "$RELEASE_NOTES"
113+
echo EOF
114+
} >> "$GITHUB_OUTPUT";
115+
env:
116+
RELEASE_NOTES: ${{ steps.generated-notes.outputs.release-notes }}
117+
118+
- name: Create release
119+
uses: softprops/action-gh-release@v2
120+
env:
121+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122+
with:
123+
tag_name: v${{ steps.version.outputs.version }}
124+
name: v${{ steps.version.outputs.version }}
125+
body: ${{ steps.cleaned-notes.outputs.notes }}
126+
target_commitish: ${{ github.ref_name }}
127+
make_latest: "${{ github.ref_name == github.event.repository.default_branch }}"
128+
129+
update-changelog:
130+
needs: release
131+
132+
name: Update changelog
133+
134+
uses: laravel/.github/.github/workflows/update-changelog.yml@main
135+
with:
136+
branch: ${{ github.ref_name }}
137+
version: "v${{ needs.release.outputs.version }}"
138+
notes: ${{ needs.release.outputs.notes }}

0 commit comments

Comments
 (0)