Skip to content

Commit

Permalink
Update main.yml
Browse files Browse the repository at this point in the history
aaaaaaaaaaaaaaaaaaaaaa
  • Loading branch information
CheapNightbot authored Nov 15, 2024
1 parent cce1cee commit 56a1782
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 56a1782

Please sign in to comment.