Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.24.2 | |
| - name: Run build script | |
| run: ./build.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/*; 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 |