From 56a1782be85ac2135f321842070bc347493df7c8 Mon Sep 17 00:00:00 2001 From: Cheap Nightbot Date: Fri, 15 Nov 2024 23:39:34 +0900 Subject: [PATCH] Update main.yml aaaaaaaaaaaaaaaaaaaaaa --- .github/workflows/main.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a779dfd..1bfad89 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,18 +41,21 @@ jobs: id: create_release if: github.event_name == 'push' && github.ref == 'refs/heads/main' run: | - RELEASE_TAG=$(date +'%Y-%m-%d') # Using hyphens for date format - echo "Creating release $RELEASE_TAG" + RELEASE_TAG=$(date +'%Y-%m-%d') - # Create a release on GitHub + # Create a release on GitHub and capture the response RESPONSE=$(curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -d '{"tag_name": "'"$RELEASE_TAG"'","name": "'"$RELEASE_TAG"'","body": "Automated release of calc binaries."}' \ "https://api.github.com/repos/${{ github.repository }}/releases") + # Extract the release ID from the response RELEASE_ID=$(echo $RESPONSE | jq -r .id) - echo "Release ID is $RELEASE_ID" - - echo "::set-output name=release_id::$RELEASE_ID" + if [[ "$RELEASE_ID" == "null" ]]; then + echo "Error creating release" + exit 1 + else + echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV + fi shell: bash - name: Upload Binaries to Release @@ -67,12 +70,15 @@ jobs: zip -r $FILENAME build/calc fi - # Get the release ID from the previous step - RELEASE_ID=${{ steps.create_release.outputs.release_id }} + # Ensure the release ID is set + if [ -z "${{ env.RELEASE_ID }}" ]; then + echo "Release ID is not set, exiting..." + exit 1 + fi # Upload the binary zip file to the release curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -H "Content-Type: application/zip" \ --data-binary @$FILENAME \ - "https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$FILENAME" + "https://uploads.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }}/assets?name=$FILENAME" shell: bash