From caaa7fa6fe27026d9966429add70c5d5df584ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Tanr=C4=B1verdi?= Date: Mon, 23 Feb 2026 14:56:02 +0300 Subject: [PATCH] Add release notes generation workflow for Gitea --- .DS_Store | Bin 0 -> 6148 bytes .gitea/workflows/generate-release-notes.yml | 128 ++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 .DS_Store create mode 100644 .gitea/workflows/generate-release-notes.yml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..76abde3740802f82a74b0caad9dcfefa886c6804 GIT binary patch literal 6148 zcmeHKy-veG47Njrf><&#-V>m9VGdPzg1!KhqJq>a9biRS*%%q&30PPe5ii1fz~{3m zIYJo`0$cKZ7yrbUFI8L<5sxmWL!y$13aDVVh2;wozi3Y~vxt-B9`o67eB3OSy+}9w zRtDtV<+MvPI-~RS{oOrueT$~9C-Y_kTk&!=2(LHK`>B8Wt$%si`E6vkNTtp9x^zNE zY3)+ZmH4~$@AsarA1`D5Pca{7SQnF=g9dUA7iYj3a0dPx1L)Zz#kQia&VV!E46GQC z??ZqJR)(!&{B&T6BLFamISTeNOGr*ItPER4cp$8)Kuu*EF<8@K4;EJ$wu+igY{Lgz zWwr^0V|Cm=#BkzD(N|}{8Aut}(92T#|H1nCKTYy0XTTZwQw(rkkLwX0$$D$=;iT6F r=pj@@;#$R33O2D7BUW1R4m1kvK{mk3uvLTw;(r7p4Zb)7Kgz%x-e*X- literal 0 HcmV?d00001 diff --git a/.gitea/workflows/generate-release-notes.yml b/.gitea/workflows/generate-release-notes.yml new file mode 100644 index 0000000..c2ed753 --- /dev/null +++ b/.gitea/workflows/generate-release-notes.yml @@ -0,0 +1,128 @@ +name: Release Notes Template + +on: + workflow_call: + inputs: + previous_release: + description: 'Previous release tag' + required: true + type: string + current_release: + description: 'Current release tag' + required: true + type: string + gitea_url: + description: 'Gitea URL' + required: false + type: string + default: 'https://gitea.technarts.com' + repo_owner: + description: 'Repository owner' + required: true + type: string + repo_name: + description: 'Repository name' + required: true + type: string + update_release: + description: 'Update release description' + required: false + type: boolean + default: false + release_id: + description: 'Release ID to update' + required: false + type: string + default: '' + secrets: + gitea_token: + description: 'Gitea API token' + required: true + +jobs: + generate-and-update: + runs-on: ubuntu-latest + + steps: + - name: Generate and update release notes + env: + GITEA_TOKEN: ${{ secrets.gitea_token }} + GITEA_URL: ${{ inputs.gitea_url }} + REPO_OWNER: ${{ inputs.repo_owner }} + REPO_NAME: ${{ inputs.repo_name }} + PREVIOUS_RELEASE: ${{ inputs.previous_release }} + CURRENT_RELEASE: ${{ inputs.current_release }} + UPDATE_RELEASE: ${{ inputs.update_release }} + RELEASE_ID: ${{ inputs.release_id }} + run: | + echo "Generating release notes: $PREVIOUS_RELEASE -> $CURRENT_RELEASE" + echo "Repository: $REPO_OWNER/$REPO_NAME" + + # Get releases + RELEASES=$(curl -s -H "Authorization: token $GITEA_TOKEN" \ + "$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases") + + # Get release dates + PREVIOUS_DATE=$(echo "$RELEASES" | jq -r --arg tag "$PREVIOUS_RELEASE" \ + '.[] | select(.tag_name == $tag) | .created_at') + + CURRENT_DATE=$(echo "$RELEASES" | jq -r --arg tag "$CURRENT_RELEASE" \ + '.[] | select(.tag_name == $tag) | .created_at') + + if [ -z "$PREVIOUS_DATE" ] || [ "$PREVIOUS_DATE" = "null" ]; then + echo "ERROR: Release not found: $PREVIOUS_RELEASE" + exit 1 + fi + + if [ -z "$CURRENT_DATE" ] || [ "$CURRENT_DATE" = "null" ]; then + echo "ERROR: Release not found: $CURRENT_RELEASE" + exit 1 + fi + + echo "Date range: $PREVIOUS_DATE to $CURRENT_DATE" + + # Get merged PRs + PRS=$(curl -s -H "Authorization: token $GITEA_TOKEN" \ + "$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/pulls?state=closed&limit=200") + + # Build release notes + NOTES_HEADER="# Release Notes: $CURRENT_RELEASE"$'\n\n'"## Changes"$'\n\n' + + # Filter and format PRs + PR_LIST=$(echo "$PRS" | jq -r --arg prev_date "$PREVIOUS_DATE" --arg curr_date "$CURRENT_DATE" ' + [.[] | select(.merged == true and .merged_at > $prev_date and .merged_at <= $curr_date)] | + sort_by(.merged_at) | + reverse | + .[] | + "* **\(.title)** ([#\(.number)](\(.html_url)))\n Author: @\(.user.username)\n Merged: \(.merged_at | split("T")[0])\n" + ') + + # Count PRs + PR_COUNT=$(echo "$PRS" | jq --arg prev_date "$PREVIOUS_DATE" --arg curr_date "$CURRENT_DATE" \ + '[.[] | select(.merged == true and .merged_at > $prev_date and .merged_at <= $curr_date)] | length') + + NOTES_FOOTER=$'\n\n'"---"$'\n\n'"**Total changes:** $PR_COUNT pull requests merged" + + FULL_NOTES="${NOTES_HEADER}${PR_LIST}${NOTES_FOOTER}" + + echo "Release notes generated: $PR_COUNT PRs found" + echo "======================================" + echo "$FULL_NOTES" + echo "======================================" + + # Update release if requested + if [ "$UPDATE_RELEASE" = "true" ] && [ -n "$RELEASE_ID" ]; then + echo "Updating release description..." + + NOTES_JSON=$(echo "$FULL_NOTES" | jq -Rs .) + + curl -X PATCH \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + "$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID" \ + -d "{\"body\":$NOTES_JSON}" + + echo "Release description updated successfully!" + else + echo "Skipping release update" + fi