Skip to content

Commit

Permalink
scripts, .github/workflows: add script to extract changelog (#689)
Browse files Browse the repository at this point in the history
* scripts, .github/workflows: add script to extract changelog

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 (mossaka) Zhou <[email protected]>
  • Loading branch information
Mossaka authored Dec 4, 2024
1 parent a70ae91 commit 14d2a13
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,32 @@ 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 v${{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
NOTES_ARG=""
if [[ -f RELEASE_NOTES.md ]]; then
NOTES_ARG="--notes-file RELEASE_NOTES.md"
fi
gh release create "refs/tags/${{matrix.crate}}/v${{matrix.version}}" \
--title "${{matrix.crate}}/v${{matrix.version}}" \
$NOTES_ARG \
--verify-tag \
$PRERELEASE_ARGS
env:
GH_TOKEN: ${{ github.token }}
RELEASE_NAME: ${{ matrix.crate }}/v${{ matrix.version }}
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Must release the creates in this order due to dependencies:

## Release Steps

1. Open a PR to bump crate versions and dependency versions in `Cargo.toml` for that crate
1. Open a PR to bump crate versions and dependency versions in `Cargo.toml` for that crate, and change the "Unreleased" section in the `CHANGELOG.md` to the new version.
2. PR can be merged after 2 LGTMs
3. Run the release workflow for the dependent crate. (e.g. `containerd-shim-wasm/v0.2.0` where `crate=containerd-shim-wasm` and `version=0.2.0`)
4. Wait for the release workflow to complete
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 14d2a13

Please sign in to comment.