Skip to content

Commit

Permalink
ci: add check for changelog and release note uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
limebell committed Nov 22, 2024
1 parent 384ec50 commit 65be0db
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/bin/dist-github-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ elif [ "${GITHUB_REF:0:10}" != "refs/tags/" ]; then
fi

tag="${GITHUB_REF#refs/*/}"
if [ ! -f obj/release_note.txt ]; then
{
echo "obj/release_note.txt file is missing."
echo "dist:release-note action must be run first."
} > /dev/stderr
exit 1
fi

if command -v apk; then
apk add --no-cache ca-certificates
Expand All @@ -36,7 +43,7 @@ while ! "$(dirname "$0")/github-release.sh" info \
--repo "$github_repo" \
--tag "$tag" \
--name "$tag" \
--description "" || true
--description - < obj/release_note.txt || true
trial=$((trial + 1))
if [[ "$trial" -gt 5 ]]; then break; fi
done
Expand Down
31 changes: 31 additions & 0 deletions .github/bin/dist-release-note.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Extract a release note from the given changelog file.
# Note that this script is intended to be run by GitHub Actions.
set -e

if [ "$1" = "" ]; then
echo "A changelog file path is missing." > /dev/stderr
exit 1
elif [ "$2" = "" ]; then
echo "An output path is missing." > /dev/stderr
exit 1
fi

tag="${GITHUB_REF#refs/*/}"
wget -O /tmp/submark \
https://github.com/dahlia/submark/releases/download/0.2.0/submark-linux-x86_64
chmod +x /tmp/submark
/tmp/submark \
-o "$2" \
-iO \
--h2 "Version $tag" \
"$1"
rm /tmp/submark

if ! grep -E '\S' "$2" > /dev/null; then
echo "There is no section for the version $tag." > /dev/stderr
exit 1
elif grep -i "to be released" "$2"; then
echo 'Release date should be shown on the release note.' > /dev/stderr
exit 1
fi
15 changes: 15 additions & 0 deletions .github/workflows/check-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: check-changelog
on:
pull_request:
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
branches:
- main
- development
- 'rc-*'
jobs:
check-changelog:
runs-on: ubuntu-latest
steps:
- uses: tarides/changelog-check-action@v2
with:
changelog: CHANGES.md
5 changes: 5 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ jobs:
with:
dotnet-version: 6.0.x
- run: .github/bin/dist-pack.sh
- run: .github/bin/dist-release-note.sh CHANGES.md obj/release_note.txt
- uses: actions/upload-artifact@main
with:
name: dist-obj
path: obj/
- run: .github/bin/dist-github-release.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 65be0db

Please sign in to comment.