-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [released] | ||
workflow_dispatch: | ||
inputs: | ||
TAG_NAME: | ||
description: "Tag name" | ||
required: true | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
patch-changelog: | ||
runs-on: ubuntu-latest | ||
name: Patch CHANGELOG.md and update GitHub release notes | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set environment variables | ||
run: | | ||
echo GIT_BRANCH_NAME=mark-version-${TAG_NAME#v}-as-released >> $GITHUB_ENV | ||
echo GIT_COMMIT_MESSAGE=Mark version ${TAG_NAME#v} as released >> $GITHUB_ENV | ||
echo RELEASE_ID=$(gh api -H "Accept: application/vnd.github+json" /repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME} | jq '.id') >> $GITHUB_ENV | ||
- name: Get changelog for this specific release and update release notes | ||
run: | | ||
gh api \ | ||
--method PATCH \ | ||
--header "Accept: application/vnd.github+json" \ | ||
/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID} \ | ||
-f body="$(./get-changelog.sh)" | ||
- name: Checkout new branch and patch changelog | ||
run: | | ||
git checkout -b $GIT_BRANCH_NAME | ||
sed -i "/^\#\# \[Unreleased\]$/a \\\n\#\# $TAG_NAME - $(date '+%Y-%m-%d')" CHANGELOG.md | ||
- name: Commit, push and create pull request | ||
run: | | ||
git config --global user.email "office@geowerkstatt.ch" | ||
git config --global user.name "GeoWerkstatt-Build" | ||
git commit -am "$GIT_COMMIT_MESSAGE" | ||
git push --set-upstream origin $GIT_BRANCH_NAME | ||
gh pr create --title "$GIT_COMMIT_MESSAGE" --body "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
# This script gets all changelog entries from CHANGELOG.md since last release. | ||
|
||
set -e | ||
|
||
tempDir="$(mktemp -d)" | ||
tempFile=$tempDir/gh_release_notes.md | ||
|
||
# Get changelog entries since last release | ||
cat CHANGELOG.md | \ | ||
grep -Pazo '(?s)(?<=\#{2} \[Unreleased\]\n{2}).*?(?=\n\#{2} v|$)' \ | ||
> $tempFile | ||
|
||
# Improve readability and add some icons | ||
sed -i -E 's/(###) (Added)/\1 🚀 \2/' $tempFile | ||
sed -i -E 's/(###) (Changed)/\1 🔨 \2/' $tempFile | ||
sed -i -E 's/(###) (Fixed)/\1 🐛 \2/' $tempFile | ||
sed -i 's/\x0//g' $tempFile | ||
|
||
cat $tempFile | ||
|
||
# Cleanup temporary files | ||
trap 'rm -rf -- "$tempDir"' EXIT |