From 4c9cd5bcede06814cb172306e6351c902159adac Mon Sep 17 00:00:00 2001 From: Tullio Sebastiani Date: Thu, 15 May 2025 09:05:31 +0100 Subject: [PATCH] added release notes automatic workflow on tag push (#813) Signed-off-by: Tullio Sebastiani typo Signed-off-by: Tullio Sebastiani typo Signed-off-by: Tullio Sebastiani --- .github/release-template.md | 7 ++++++ .github/release.yml | 0 .github/workflows/release.yml | 47 +++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .github/release-template.md create mode 100644 .github/release.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/release-template.md b/.github/release-template.md new file mode 100644 index 00000000..9504de37 --- /dev/null +++ b/.github/release-template.md @@ -0,0 +1,7 @@ +## Release {VERSION} + +### Download Artifacts +- 📦 Krkn sources (noarch): [krkn-{VERSION}-src.tar.gz](https://krkn-chaos.gateway.scarf.sh/krkn-src-{VERSION}.tar.gz) + +### Changes +{CHANGES} diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000..e69de29b diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..4caf96ab --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: Create Release +on: + push: + tags: + - 'v*' +jobs: + release: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: calculate previous tag + run: | + git fetch --tags origin + PREVIOUS_TAG=$(git tag --sort=-creatordate | sed -n '2 p') + echo $PREVIOUS_TAG + echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> "$GITHUB_ENV" + - name: generate release notes from template + id: release-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + NOTES=$(gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/krkn-chaos/krkn/releases/generate-notes \ + -f "tag_name=${{ github.ref_name }}" -f "target_commitish=main" -f "previous_tag_name=${{ env.PREVIOUS_TAG }}" | jq -r .body) + echo "NOTES<> $GITHUB_ENV + echo "$NOTES" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + - name: replace placeholders in template + run: | + echo "${{ env.NOTES }}" + TEMPLATE=$(cat .github/release-template.md) + VERSION=${{ github.ref_name }} + NOTES="${{ env.NOTES }}" + OUTPUT=${TEMPLATE//\{VERSION\}/$VERSION} + OUTPUT=${OUTPUT//\{CHANGES\}/$NOTES} + echo "$OUTPUT" > release-notes.md + - name: create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create ${{ github.ref_name }} --title "${{ github.ref_name }}" -F release-notes.md