Skip to content

Build and Upload Release Binaries #8

Build and Upload Release Binaries

Build and Upload Release Binaries #8

Workflow file for this run

name: Build and Upload Release Binaries
on:
release:
types: [published]
permissions:
contents: write # 授予 GITHUB_TOKEN 写入发布资源的权限
jobs:
build:
name: Build and Upload
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.2
- name: Run build script
run: ./build.sh
- name: Run dist2zip script
run: ./dist2zip.sh
- name: Upload binaries to release
env:
UPLOAD_URL: ${{ github.event.release.upload_url }}
run: |
# 去掉 {?name,label} 占位符
CLEANED_URL="${UPLOAD_URL%\{?name,label\}}"
for file in ./dist/zip/*; do
echo "Uploading $file..."
curl -sSL \
-X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"$CLEANED_URL?name=$(basename "$file")"
done
- name: Clean up dist directory
run: rm -rf ./dist