Skip to content

Commit

Permalink
Add release notes parser and release update action
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNDRmac committed Mar 17, 2022
1 parent f9a9763 commit 8215fb1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/release-notes.sh
Original file line number Diff line number Diff line change
@@ -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}"
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8215fb1

Please sign in to comment.