Skip to content

Commit

Permalink
Fix release.yml
Browse files Browse the repository at this point in the history
Close: #140
  • Loading branch information
henry0715-dev committed Jan 16, 2025
1 parent 57dee54 commit a3b5fd8
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,28 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ env.TAG }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Update to the Latest Version of Rust
run: rustup update
- name: Build Binary
run: |
cargo build --release
- name: Create a Release and Upload Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG }}
name: ${{ env.TITLE }} ${{ env.TAG }}
draft: false
prerelease: false
files: |
./target/release/${{ env.BINARY }}
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{"tag_name": "${{ env.TAG }}", "name": "${{ env.TITLE }} ${{ env.TAG }}", "draft": false, "prerelease": false}' \
https://api.github.com/repos/${{ github.repository }}/releases \
-o release.json
if [ "$(jq -r .id release.json)" == "null" ]; then
echo "Failed to create release" >&2
exit 1
fi
RELEASE_ID=$(jq -r .id release.json)
FILE="target/release/${{ env.BINARY }}"
UPLOAD_URL="https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=${{ env.BINARY }}"
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$FILE" \
"${UPLOAD_URL}"

0 comments on commit a3b5fd8

Please sign in to comment.