diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 54fc2fc..c76e2ce 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -75,14 +75,32 @@ jobs: else echo "Latest tag is: $LATEST_TAG" - # Get ISO timestamp of the latest tag commit - LATEST_TAG_COMMIT_DATE=$(curl -sf -H "Authorization: token $TOKEN" \ - "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/refs/tags/$LATEST_TAG" \ - | jq -r '.[0].object.sha' \ - | xargs -I{} curl -sf -H "Authorization: token $TOKEN" \ - "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/commits/{}" \ + # Step 1: Get the tag ref object + TAG_REF=$(curl -sf -H "Authorization: token $TOKEN" \ + "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/refs/tags/$LATEST_TAG") + + # Extract the first .object.sha (if it's an array) or directly if it's an object + if echo "$TAG_REF" | jq -e 'type == "array"' >/dev/null; then + TAG_OBJECT_SHA=$(echo "$TAG_REF" | jq -r '.[0].object.sha') + TAG_OBJECT_TYPE=$(echo "$TAG_REF" | jq -r '.[0].object.type') + else + TAG_OBJECT_SHA=$(echo "$TAG_REF" | jq -r '.object.sha') + TAG_OBJECT_TYPE=$(echo "$TAG_REF" | jq -r '.object.type') + fi + + # Step 2: If it's a tag object, resolve to commit + if [ "$TAG_OBJECT_TYPE" = "tag" ]; then + COMMIT_SHA=$(curl -sf -H "Authorization: token $TOKEN" \ + "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/tags/$TAG_OBJECT_SHA" \ + | jq -r '.object.sha') + else + COMMIT_SHA=$TAG_OBJECT_SHA + fi + + # Step 3: Get the commit date + COMMIT_DATE=$(curl -sf -H "Authorization: token $TOKEN" \ + "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/commits/$COMMIT_SHA" \ | jq -r '.committer.date') - COMMIT_DATE="$LATEST_TAG_COMMIT_DATE" echo "Fetching closed issues since $COMMIT_DATE..." CLOSED_ISSUES_JSON=$(curl -sf -H "Authorization: token $TOKEN" \