Skip to content

Commit cfd46c5

Browse files
committed
scripts, .github/workflows/release.yaml: add script to extract changelog
the new scripts/extract-changelog.sh script is used to extract the changelog from a tag name. This script is used in the release.yaml workflow to extract the changelog for the release notes. it also updates the release.yaml workflow to determine a prerelease based on the tag name. Signed-off-by: jiaxiao zhou <[email protected]>
1 parent 86b7cfc commit cfd46c5

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

.github/workflows/release.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,30 @@ jobs:
4747
mkdir -p _dist
4848
cp ./deployments/workloads/runtime.yaml _dist/runtime.yaml
4949
cp ./deployments/workloads/workload.yaml _dist/workload.yaml
50-
50+
51+
- name: extract changelog
52+
run: |
53+
TAG_NAME=${GITHUB_REF#refs/tags/}
54+
cd $GITHUB_WORKSPACE
55+
./scripts/extract-changelog.sh $TAG_NAME > RELEASE_NOTES.md
56+
cat RELEASE_NOTES.md
57+
5158
- name: create release
5259
if: startsWith(github.ref, 'refs/tags/v')
5360
env:
5461
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5562
run: |
63+
TAG_NAME=${GITHUB_REF#refs/tags/}
64+
if [[ "$TAG_NAME" =~ .+-pre.* ]]; then
65+
PRERELEASE_ARGS="--prerelease --latest=false"
66+
else
67+
PRERELEASE_ARGS=""
68+
fi
5669
gh release create ${{ env.RELEASE_VERSION }} \
57-
--generate-notes \
58-
-p \
70+
--notes-file RELEASE_NOTES.md \
71+
--title ${{ env.RELEASE_VERSION }} \
72+
--verify-tag
73+
$PRERELEASE_ARGS \
5974
_dist/runtime.yaml#example-runtimes \
6075
_dist/workload.yaml#example-workloads \
6176

scripts/extract-changelog.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# Inspired by https://stackoverflow.com/questions/40450238/parse-a-changelog-and-extract-changes-for-a-version
3+
# This script will extract the changelog for a specific version from the CHANGELOG.md file
4+
# Usage: ./extract-changelog.sh <version>
5+
version=$1
6+
7+
awk -v ver="$version" '
8+
/^## \[.*\]/ {
9+
if (p) exit
10+
if ($0 ~ "^## \\[" ver "\\]") { p=1; next }
11+
}
12+
p' CHANGELOG.md

0 commit comments

Comments
 (0)