diff --git a/.gitea/workflows/check_releases.yaml b/.gitea/workflows/check_releases.yaml index 3c439f9..5cbd1c5 100644 --- a/.gitea/workflows/check_releases.yaml +++ b/.gitea/workflows/check_releases.yaml @@ -8,27 +8,24 @@ jobs: env: TARGET_REPO_OWNER: "prefix-dev" TARGET_REPO_NAME: "pixi" + RELEASE_ARTIFACT: "pixi-x86_64-unknown-linux-musl.tar.gz" steps: - - name: Check - run: | - echo "Checking for new releases ..." - - name: Check for new releases in target repository + - name: Check for latest release on github id: check_release run: | - echo "--- Checking ${TARGET_REPO_OWNER}/${TARGET_REPO_NAME} for new releases ---" + echo "::notice::Checking ${TARGET_REPO_OWNER}/${TARGET_REPO_NAME} for new releases" - # 1. Fetch all releases and sort them by creation date descending - # We only need the latest release tag/date info + # Fetch all releases and sort them by creation date descending, we only need the latest release tag/date info API_OUTPUT=$(curl -s \ "https://api.github.com/repos/${{ env.TARGET_REPO_OWNER }}/${{ env.TARGET_REPO_NAME }}/releases?per_page=1") # Check if API call failed or returned no data if [ "$API_OUTPUT" == '[]' ]; then - echo "::error:: No releases found in the target repository." - exit 0 # Exit successfully, but do nothing. + echo "::error::No releases found in the target repository." + exit 1 fi - echo "${API_OUTPUT}" + echo "::debug::API output: ${API_OUTPUT}" # Extract the tag name and published date of the latest release LATEST_TAG=$(echo "${API_OUTPUT}" | jq -r '.[0].tag_name') @@ -36,11 +33,12 @@ jobs: echo "::notice:: Found latest version: ${LATEST_TAG} published on ${PUBLISH_DATE}" - echo "::set-output name=latest_tag::${LATEST_TAG}" - echo "::set-output name=publish_date::${PUBLISH_DATE}" + # Set output variables for subsequent steps + echo "latest_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT + echo "publish_date=${PUBLISH_DATE}" >> $GITHUB_OUTPUT - # 1. Check if the release already exists on Gitea - - name: Check if Release Exists + # Check if the release already exists on Gitea + - name: Check if release exists id: check_release_exists run: | HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ @@ -48,31 +46,27 @@ jobs: "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/${{ steps.check_release.outputs.latest_tag }}") if [ "$HTTP_STATUS" -eq 200 ]; then - echo "Release already exists. Skipping step." + echo "::notice::Release already exists. Skipping step." echo "exists=true" >> "$GITHUB_OUTPUT" else - echo "Release does not exist." + echo "::notice::Release does not exist." echo "exists=false" >> "$GITHUB_OUTPUT" fi - name: Download latest release if: steps.check_release_exists.outputs.exists != 'true' run: | - DOWNLOAD_URL="https://github.com/prefix-dev/pixi/releases/download/${{ steps.check_release.outputs.latest_tag }}/pixi-x86_64-unknown-linux-musl.tar.gz" + DOWNLOAD_URL="https://github.com/${{ env.TARGET_REPO_OWNER }}/${{ env.TARGET_REPO_NAME }}/releases/download/${{ steps.check_release.outputs.latest_tag }}/${{ env.RELEASE_ARTIFACT }}" - echo "Downloading latest release from $DOWNLOAD_URL ..." - - curl -L -o pixi-latest.tar.gz "$DOWNLOAD_URL" - # tar xfvz pixi-latest.tar.gz - find . - node --version + echo "::notice::Downloading release from $DOWNLOAD_URL ..." + curl -L -o "${{ env.RELEASE_ARTIFACT }}" "$DOWNLOAD_URL" - name: Create and upload release if: steps.check_release_exists.outputs.exists != 'true' - uses: actions/gitea-release-action@v1 + uses: actions/gitea-release-action with: name: ${{ steps.check_release.outputs.latest_tag }} tag_name: ${{ steps.check_release.outputs.latest_tag }} release_name: ${{ steps.check_release.outputs.latest_tag }} - body: "Release of version ${{ steps.check_release.outputs.latest_tag }} published on ${{ steps.check_release.outputs.publish_date }}" - files: ./pixi-latest.tar.gz + body: "Release ${{ steps.check_release.outputs.latest_tag }} published on ${{ steps.check_release.outputs.publish_date }}" + files: ./${{ env.RELEASE_ARTIFACT }}