Skip to content

Commit ca5ef31

Browse files
Merge pull request #85 from adambkaplan/custom-release-notes
Generate cleaner release notes
2 parents 4f763c3 + ad1ea67 commit ca5ef31

File tree

2 files changed

+57
-30
lines changed

2 files changed

+57
-30
lines changed

.github/draft_release_notes.sh

100644100755
Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,27 @@ if [ -z ${PREVIOUS_TAG+x} ]; then
1515
echo "Error: PREVIOUS_TAG is not set"
1616
fi
1717

18+
releaseDir="/tmp/release-notes"
19+
20+
mkdir -p ${releaseDir}
21+
1822
sudo apt-get -y update
1923
sudo apt-get -y install wget curl git
2024
curl -L https://github.com/github/hub/releases/download/v2.14.2/hub-linux-amd64-2.14.2.tgz | tar xzf -
2125
PWD="$(pwd)"
2226
export PATH=$PWD/hub-linux-amd64-2.14.2/bin:$PATH
2327
git fetch --all --tags --prune --force
24-
echo "# Draft Release changes since ${PREVIOUS_TAG}" > Changes.md
25-
echo > Features.md
26-
echo "## Features" >> Features.md
27-
echo > Fixes.md
28-
echo "## Fixes" >> Fixes.md
29-
echo > API.md
30-
echo "## API Changes" >> API.md
31-
echo > Docs.md
32-
echo "## Docs" >> Docs.md
33-
echo > Misc.md
34-
echo "## Misc" >> Misc.md
28+
echo "# Draft Release changes since ${PREVIOUS_TAG}" > "${releaseDir}/Changes.md"
29+
echo > "${releaseDir}/Features.md"
30+
echo "## Features" >> "${releaseDir}/Features.md"
31+
echo > "${releaseDir}/Fixes.md"
32+
echo "## Fixes" >> "${releaseDir}/Fixes.md"
33+
echo > "${releaseDir}/API.md"
34+
echo "## API Changes" >> "${releaseDir}/API.md"
35+
echo > "${releaseDir}/Docs.md"
36+
echo "## Docs" >> "${releaseDir}/Docs.md"
37+
echo > "${releaseDir}/Misc.md"
38+
echo "## Misc" >> "${releaseDir}/Misc.md"
3539

3640
# this effectively gets the commit associated with github.event.inputs.tags
3741
COMMON_ANCESTOR=$(git merge-base $PREVIOUS_TAG HEAD)
@@ -100,42 +104,47 @@ while IFS= read -r pr; do
100104
echo $pr | grep 'kind/bug'
101105
rc=$?
102106
if [ ${rc} -eq 0 ]; then
103-
echo >> Fixes.md
104-
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> Fixes.md
107+
echo >> "${releaseDir}/Fixes.md"
108+
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> "${releaseDir}/Fixes.md"
105109
MISC=no
106110
fi
107111
echo $pr | grep 'kind/api-change'
108112
rc=$?
109113
if [ ${rc} -eq 0 ]; then
110-
echo >> API.md
111-
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> API.md
114+
echo >> "${releaseDir}/API.md"
115+
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> "${releaseDir}/API.md"
112116
MISC=no
113117
fi
114118
echo $pr | grep 'kind/feature'
115119
rc=$?
116120
if [ ${rc} -eq 0 ]; then
117-
echo >> Features.md
118-
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> Features.md
121+
echo >> "${releaseDir}/Features.md"
122+
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> "${releaseDir}/Features.md"
119123
MISC=no
120124
fi
121125
echo $pr | grep 'kind/documentation'
122126
rc=$?
123127
if [ ${rc} -eq 0 ]; then
124-
echo >> Docs.md
125-
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> Docs.md
128+
echo >> "${releaseDir}/Docs.md"
129+
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> "${releaseDir}/Docs.md"
126130
MISC=no
127131
fi
128132
if [ "$MISC" == "yes" ]; then
129-
echo >> Misc.md
130-
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> Misc.md
133+
echo >> "${releaseDir}/Misc.md"
134+
echo "$PR_NUM by $AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> "${releaseDir}/Misc.md"
131135
fi
132136
# update the PR template if our greps etc. for pulling the release note changes
133137
#PR_RELEASE_NOTE=$(wget -q -O- https://api.github.com/repos/shipwright-io/build/issues/${PR_NUM:1} | grep -oPz '(?s)(?<=```release-note..)(.+?)(?=```)' | grep -avP '\W*(Your release note here|action required: your release note here|NONE)\W*')
134138
echo "Added from ${AUTHOR} PR ${PR_NUM:1} to the release note draft"
135139
done < last-300-prs-with-release-note.txt
136140

137-
cat Features.md >> Changes.md
138-
cat Fixes.md >> Changes.md
139-
cat API.md >> Changes.md
140-
cat Docs.md >> Changes.md
141-
cat Misc.md >> Changes.md
141+
cat "${releaseDir}/Features.md" >> "${releaseDir}/Changes.md"
142+
cat "${releaseDir}/Fixes.md" >> "${releaseDir}/Changes.md"
143+
cat "${releaseDir}/API.md" >> "${releaseDir}/Changes.md"
144+
cat "${releaseDir}/Docs.md" >> "${releaseDir}/Changes.md"
145+
cat "${releaseDir}/Misc.md" >> "${releaseDir}/Changes.md"
146+
147+
echo "Cleaning up"
148+
149+
rm -rf hub-linux-amd64-2.14.2
150+
rm last-300-prs-with-release-note.txt

.github/workflows/release.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
---
22
name: Release
33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
workflow_dispatch:
5+
inputs:
6+
release:
7+
description: 'Release tag'
8+
required: true
9+
previous-tag:
10+
description: 'Previous release tag'
11+
required: true
712
jobs:
813
release:
914
name: Release
15+
if: ${{ github.repository == 'shipwright-io/cli' }}
1016
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write # To be able to update releases
1119
steps:
1220
- name: Checkout
1321
uses: actions/checkout@v2
1422
with:
23+
ref: ${{ github.event.inputs.release }}
1524
fetch-depth: 0
1625
- name: Set up Go
1726
uses: actions/setup-go@v2
1827
with:
1928
go-version: 1.17.x
29+
- name: Build Release Changelog
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
PREVIOUS_TAG: ${{ github.event.inputs.previous-tag }}
33+
# This creates a set of release notes at Changes.md
34+
run: |
35+
export GITHUB_TOKEN
36+
export PREVIOUS_TAG
37+
"${GITHUB_WORKSPACE}/.github/draft_release_notes.sh"
2038
- name: Run GoReleaser
2139
uses: goreleaser/goreleaser-action@v2
2240
with:
2341
version: latest
24-
args: release --rm-dist
42+
args: release --rm-dist --release-notes /tmp/release-notes/Changes.md
2543
env:
2644
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)