mirror of
https://github.com/oneclickvirt/backtrace.git
synced 2025-02-23 17:35:39 +08:00
update
This commit is contained in:
parent
2306fdf46f
commit
49a3bf8a72
49
.github/workflows/main.yaml
vendored
49
.github/workflows/main.yaml
vendored
@ -45,26 +45,35 @@ jobs:
|
|||||||
cd cmd
|
cd cmd
|
||||||
go build -o ../bin/backtrace-${{ matrix.goos }}-${{ matrix.goarch }} -v .
|
go build -o ../bin/backtrace-${{ matrix.goos }}-${{ matrix.goarch }} -v .
|
||||||
|
|
||||||
- name: Create Release
|
- name: Check, Delete Existing Assets and Upload New Assets
|
||||||
id: create_release
|
run: |
|
||||||
uses: actions/create-release@v1
|
release_id=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/backtrace/releases/latest" | jq -r '.id')
|
||||||
with:
|
echo "Checking, deleting existing assets, and uploading new assets..."
|
||||||
tag_name: ${{ github.ref }}
|
for file in ./bin/*; do
|
||||||
release_name: Release ${{ github.ref }}
|
echo "Processing file: $file"
|
||||||
body: |
|
existing_asset_id=$(curl -s -H "Accept: application/vnd.github.v3+json" \
|
||||||
Description of the release
|
"https://api.github.com/repos/oneclickvirt/backtrace/releases/$release_id/assets" \
|
||||||
draft: false
|
| jq -r --arg name "$(basename "$file")" '.[] | select(.name == $name) | .id')
|
||||||
prerelease: false
|
if [ -n "$existing_asset_id" ]; then
|
||||||
|
echo "Asset already exists in release, deleting existing asset..."
|
||||||
- name: Upload Release Asset
|
delete_response=$(curl -s -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/backtrace/releases/assets/$existing_asset_id")
|
||||||
id: upload-release-asset
|
echo "$delete_response"
|
||||||
uses: actions/upload-release-asset@v1
|
if [ $? -eq 0 ] && ! echo "$delete_response" | grep -q "error"; then
|
||||||
with:
|
echo "Existing asset deleted successfully."
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
else
|
||||||
asset_path: ./bin/backtrace-${{ matrix.goos }}-${{ matrix.goarch }}
|
echo "Failed to delete existing asset. Skipping file upload..."
|
||||||
asset_name: backtrace-${{ matrix.goos }}-${{ matrix.goarch }}
|
continue
|
||||||
asset_content_type: application/octet-stream
|
fi
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
else
|
||||||
|
echo "No existing asset found."
|
||||||
|
fi
|
||||||
|
echo "Uploading $file to release..."
|
||||||
|
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/zip" \
|
||||||
|
--data-binary @"$file" \
|
||||||
|
"https://uploads.github.com/repos/oneclickvirt/incus_images/releases/$release_id/assets?name=$(basename "$file")"
|
||||||
|
rm -rf $file
|
||||||
|
done
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
Loading…
Reference in New Issue
Block a user