From 8215fb10db4e930c3fc16914d0627f1346587205 Mon Sep 17 00:00:00 2001 From: AlexNDRmac Date: Thu, 17 Mar 2022 12:52:42 +0200 Subject: [PATCH] Add release notes parser and release update action --- .github/release-notes.sh | 17 +++++++++++++++++ .github/workflows/build.yml | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 .github/release-notes.sh diff --git a/.github/release-notes.sh b/.github/release-notes.sh new file mode 100755 index 0000000..f732868 --- /dev/null +++ b/.github/release-notes.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# -e Exit immediately if a command exits with a non-zero status. +# -u Treat unset variables as an error when substituting. + +set -eu +set -o pipefail + +# Get Release notes for the latest release from CHANGELOG.md +# How to use: +# release-notes.sh CHANGELOG.md > ReleaseNotes.md + +startline=$(($(cat "$1" | grep -nE '^## \[v[0-9]+' | head -n 1 | tail -n 1 | cut -d ":" -f 1) + 1)) +finishline=$(($(cat "$1" | grep -nE '^## \[v[0-9]+' | head -n 2 | tail -n 1 | cut -d ":" -f 1) - 1)) +changelog=$(sed -n "${startline},${finishline}p" "$1"); + +echo "${changelog}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3df55af..bb7f70e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,3 +78,24 @@ jobs: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} DOCKERHUB_REPOSITORY: alexmon1989/dripper + + - name: Get the release version + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} + id: get-version + run: | + echo ::set-output name=version::${GITHUB_REF#refs/tags/} + + - name: Prepare Release Notes + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} + run: | + ./.github/release-notes.sh ./CHANGELOG.md > ./release-notes.md + + - name: Update Release notes + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + name: v${{ steps.get-version.outputs.version }} + tag: ${{ steps.get-version.outputs.version }} + bodyFile: "./release-notes.md" + allowUpdates: true