From 73c203502cfdfc52c99027ca17c6db31bf0fb96e Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Jun 2025 15:48:33 +0100 Subject: [PATCH] Update .forgejo/workflows/release.yml --- .forgejo/workflows/release.yml | 54 +++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 1b91096..ef5a2b7 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -106,7 +106,37 @@ jobs: name: app-backend path: target/resilient*.jar - # auto-create a release + # Create the release notes (closed issues) + - name: Generate release notes from closed issues + id: generate_notes + run: | + OWNER="root" + REPO="resilient" + TOKEN="${{ secrets.FORGEJO_TOKEN }}" + VERSION="${{ steps.version.outputs.release_version }}" + FORGEJO_API="https://git.oguerreiro.com/api/v1" + + echo "Fetching latest release date..." + LAST_TAG_DATE=$(curl -s -H "Authorization: token $TOKEN" \ + "$FORGEJO_API/repos/$OWNER/$REPO/releases" | jq -r '.[0].created_at') + + echo "Fetching closed issues since $LAST_TAG_DATE..." + ISSUES=$(curl -s -H "Authorization: token $TOKEN" \ + "$FORGEJO_API/repos/$OWNER/$REPO/issues?state=closed&limit=100" | \ + jq -r --arg last_date "$LAST_TAG_DATE" ' + .[] | select(.closed_at > $last_date) | + "- [#\(.number)](\(.html_url)) \(.title)"') + + if [ -z "$ISSUES" ]; then + NOTES="## Release $VERSION\n\nNo issues closed since last release." + else + NOTES="## Release $VERSION\n\n### Closed Issues\n\n$ISSUES" + fi + + echo "$NOTES" > release-notes.md + cat release-notes.md + + # Create the release # NOTE: added system dependency install "jq" - name: Create release and upload JAR run: | @@ -115,18 +145,22 @@ jobs: REPO="root/resilient" # Create release - RESPONSE=$(curl -s -X POST "$API/repos/$REPO/releases" \ - -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ + RESPONSE=$(curl -s -X POST "$FORGEJO_API/repos/$OWNER/$REPO/releases" \ + -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ - -d "{ - \"tag_name\": \"v$VERSION\", - \"target_commitish\": \"master\", - \"name\": \"Release v$VERSION\", - \"body\": \"Automated release by CI\" - }") + -d @- <