Skip to content

Commit

Permalink
scripts, .github/workflows: add script to extract changelog
Browse files Browse the repository at this point in the history
the release workflow will use the script to extract the changelog and
uses it to create a release note. It also uses tag name to determine
if the release is pre-release or not.

Signed-off-by: jiaxiao zhou <[email protected]>
  • Loading branch information
Mossaka committed Oct 4, 2024
1 parent c41268a commit b2d41ad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,27 @@ jobs:
run: |
git tag "${{matrix.crate}}/v${{matrix.version}}"
git push origin "${{matrix.crate}}/v${{matrix.version}}"
- name: Extract release notes
if: ${{ matrix.crate == 'containerd-shim-wasm' && !inputs.dry_run }}
run:
cd $GITHUB_WORKSPACE
./scripts/extract-changelog.sh ${{matrix.version}} > RELEASE_NOTES.md
cat RELEASE_NOTES.md
- name: Create release
if: ${{ !inputs.dry_run }}
run: |
gh release create 'refs/tags/${{matrix.crate}}/v${{matrix.version}}' --generate-notes
TAG_NAME=${{matrix.version}}
if [[ "$TAG_NAME" =~ .+-pre.* ]]; then
PRERELEASE_ARGS="--prerelease --latest=false"
else
PRERELEASE_ARGS=""
fi
gh release create 'refs/tags/${{matrix.crate}}/v${{matrix.version}}' \
--title "${{matrix.crate}}/v${{matrix.version}}" \
--notes-file RELEASE_NOTES.md \
--verify-tag \
$PRERELEASE_ARGS \
env:
GH_TOKEN: ${{ github.token }}
RELEASE_NAME: ${{ matrix.crate }}/v${{ matrix.version }}
Expand Down
12 changes: 12 additions & 0 deletions scripts/extract-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Inspired by https://stackoverflow.com/questions/40450238/parse-a-changelog-and-extract-changes-for-a-version
# This script will extract the changelog for a specific version from the CHANGELOG.md file
# Usage: ./extract-changelog.sh <version>
version=$1

awk -v ver="$version" '
/^## \[.*\]/ {
if (p) exit
if ($0 ~ "^## \\[" ver "\\]") { p=1; next }
}
p' crates/containerd-shim-wasm/CHANGELOG.md

0 comments on commit b2d41ad

Please sign in to comment.