From 71dd64f71bd91f2bb0e7c09cb2942832eaad8d0f Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Jun 2025 11:58:19 +0100 Subject: [PATCH] Update .forgejo/workflows/release.yml --- .forgejo/workflows/release.yml | 45 ++++++++++++++-------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 5a54e2a..7108d1c 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -64,74 +64,67 @@ jobs: VERSION="${{ steps.version.outputs.release_version }}" API_BASE="https://git.oguerreiro.com/api/v1" - echo "Fetching latest release tag..." + # Step 1. Get the latest tag + echo "Step 1 : Fetching latest release tag..." LATEST_TAG=$(curl -H "Authorization: token $TOKEN" \ "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/tags" \ | jq -r '.[0].name') if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "null" ]]; then + # Doesn't have tag. Its the first release echo "No previous tags found. Assuming first release." CLOSED_ISSUES="" else + # Tag found echo "Latest tag is: $LATEST_TAG" - # Step 1: Get the tag ref object + # Step 2: Get the tag ref object + echo "Step 2 : Fetch tag ref object from tag = $LATEST_TAG" TAG_REF=$(curl -H "Authorization: token $TOKEN" \ "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/refs/tags/$LATEST_TAG") - echo "TAG_REF is: $TAG_REF" + echo "... TAG_REF is: $TAG_REF" # 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 - echo "TAG_REF is an array" + echo "... is an array" TAG_OBJECT_SHA=$(echo "$TAG_REF" | jq -r '.[0].object.sha') TAG_OBJECT_TYPE=$(echo "$TAG_REF" | jq -r '.[0].object.type') else - echo "TAG_REF is an object" + echo "... is an object" TAG_OBJECT_SHA=$(echo "$TAG_REF" | jq -r '.object.sha') TAG_OBJECT_TYPE=$(echo "$TAG_REF" | jq -r '.object.type') fi - echo "TAG_OBJECT_SHA is (1): $TAG_OBJECT_SHA" - echo "TAG_OBJECT_TYPE is (1): $TAG_OBJECT_TYPE" + echo "... TAG SHA is (1): $TAG_OBJECT_SHA" + echo "... TAG TYPE is (1): $TAG_OBJECT_TYPE" # Resolve annotated tag to commit SHA while [ "$TAG_OBJECT_TYPE" != "commit" ]; do - echo "Try : $API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/$TAG_OBJECT_TYPE/$TAG_OBJECT_SHA" + echo "..." + echo "... TAG OBJECT is not of type commit. Try : $API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/$TAG_OBJECT_TYPE/$TAG_OBJECT_SHA" TAG_OBJECT=$(curl -H "Authorization: token $TOKEN" \ "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/tags/$TAG_OBJECT_SHA") - echo "TAG_OBJECT is: $TAG_OBJECT" - echo "Read" if echo "$TAG_OBJECT" | jq -e 'type == "array"' >/dev/null; then - echo "TAG_OBJECT is an array" + echo "... ... is an array" TAG_OBJECT_SHA=$(echo "$v" | jq -r '.[0].object.sha') TAG_OBJECT_TYPE=$(echo "$TAG_OBJECT" | jq -r '.[0].object.type') else - echo "TAG_OBJECT is an object" + echo "... ... is an object" TAG_OBJECT_SHA=$(echo "$TAG_OBJECT" | jq -r '.object.sha') TAG_OBJECT_TYPE=$(echo "$TAG_OBJECT" | jq -r '.object.type') fi - echo "Response" - echo "TAG_OBJECT_SHA is (2): $TAG_OBJECT_SHA" - echo "TAG_OBJECT_TYPE is (2): $TAG_OBJECT_TYPE" + echo "... TAG_OBJECT_SHA is (2): $TAG_OBJECT_SHA" + echo "... TAG_OBJECT_TYPE is (2): $TAG_OBJECT_TYPE" done - - # Step 2: If it's a tag object, resolve to commit - if [ "$TAG_OBJECT_TYPE" = "tag" ]; then - COMMIT_SHA=$(curl -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 - echo "COMMIT_SHA is : $COMMIT_SHA" # Step 3: Get the commit date + echo "Step 3 : Get the commit date from commit = $COMMIT_SHA COMMIT_DATE=$(curl -H "Authorization: token $TOKEN" \ "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/git/commits/$COMMIT_SHA" \ | jq -r '.committer.date') - echo "Fetching closed issues since $COMMIT_DATE..." + echo "... Fetching closed issues since $COMMIT_DATE..." CLOSED_ISSUES_JSON=$(curl -H "Authorization: token $TOKEN" \ "$API_BASE/repos/$REPO_OWNER/$REPO_NAME/issues?state=closed&since=$COMMIT_DATE")