diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 1295213..19d4901 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -116,9 +116,31 @@ jobs: 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 latest release tag..." + LATEST_TAG=$(curl -sf -H "Authorization: token $TOKEN" \ + "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/tags" \ + | jq -r '.[0].name') + + if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "null" ]]; then + echo "No previous tags found. Assuming first release." + CLOSED_ISSUES="" + else + echo "Latest tag is: $LATEST_TAG" + + # Get ISO timestamp of the latest tag commit + COMMIT_DATE=$(git log -1 --format=%cI "$LATEST_TAG") + echo "Fetching closed issues since $COMMIT_DATE..." + + CLOSED_ISSUES_JSON=$(curl -sf -H "Authorization: token $TOKEN" \ + "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/issues?state=closed&since=$COMMIT_DATE") + + if [[ -z "$CLOSED_ISSUES_JSON" ]]; then + echo "Warning: No closed issues or invalid response." + CLOSED_ISSUES="" + else + CLOSED_ISSUES=$(echo "$CLOSED_ISSUES_JSON" | jq -r '.[] | "- [#\(.number)](\(.html_url)) \(.title)"') + fi + fi echo "Fetching closed issues since $LAST_TAG_DATE..." # Get closed issues since last tag (if any) @@ -130,8 +152,8 @@ jobs: CLOSED_ISSUES="" fi - # Build release notes with proper line breaks - { + # Build release notes markdown + { echo "## Release v$VERSION" echo if [[ -n "$CLOSED_ISSUES" ]]; then