From 12aa588dbc7c95c07817bda86bb0b57774259eb7 Mon Sep 17 00:00:00 2001 From: Ayato Tokubi Date: Tue, 2 May 2023 11:47:53 +0100 Subject: [PATCH] Auto-generate release note (#2878) --- .github/generate_release_note.sh | 19 +++++++++++++++++++ .github/workflows/release-note.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 .github/generate_release_note.sh create mode 100644 .github/workflows/release-note.yml diff --git a/.github/generate_release_note.sh b/.github/generate_release_note.sh new file mode 100755 index 000000000..d179fae9d --- /dev/null +++ b/.github/generate_release_note.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# It checks if the tag is annotated, otherwise it fails. +[ "$(git describe)" != "$(git describe --tags)" ] && echo "Tag must be annotated." && exit 1 + +CHANGELOG=$1 +CURRENT_TAG=$(git describe --abbrev=0) +PREVIOUS_TAG=$(git describe --abbrev=0 "$CURRENT_TAG"^) + +cat < "$CHANGELOG" +$(git tag -l --format='%(contents)' "$CURRENT_TAG") + +
Changes + +$(git log --oneline --no-decorate "$PREVIOUS_TAG".."$CURRENT_TAG") + +**Full Changelog**: https://github.com/Azure/ARO-RP/compare/$PREVIOUS_TAG...$CURRENT_TAG +
+EOF diff --git a/.github/workflows/release-note.yml b/.github/workflows/release-note.yml new file mode 100644 index 000000000..fcf6c4b84 --- /dev/null +++ b/.github/workflows/release-note.yml @@ -0,0 +1,29 @@ +name: release-note +on: + push: + tags: + - v* +permissions: + contents: write + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + # ref and fetch-depth: 0 are required to retrieve tag annotations. + # (see https://github.com/actions/runner-images/issues/1717) + - name: Generate Changelog + run: ./.github/generate_release_note.sh ${{ github.workspace }}/CHANGELOG.txt + - name: Release + uses: softprops/action-gh-release@v1 + with: + body_path: ${{ github.workspace }}/CHANGELOG.txt + name: Release ${{ github.ref_name }} + draft: false + prerelease: false