mirror of
https://github.com/unchainese/unchain.git
synced 2025-12-24 12:38:02 +08:00
56 lines
1.7 KiB
YAML
56 lines
1.7 KiB
YAML
name: Release
|
|
|
|
on:
|
|
release:
|
|
types: [published] # Trigger on release published by github web interface release page
|
|
|
|
|
|
jobs:
|
|
build:
|
|
name: Build Binaries
|
|
permissions:
|
|
contents: write
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [linux, windows, darwin]
|
|
goarch: [amd64, arm64]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: '1.23'
|
|
|
|
- name: Build executable
|
|
id: build
|
|
run: |
|
|
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o bin/${{ matrix.goos }}-${{ matrix.goarch }}/unchain main.go
|
|
echo "OUTPUT_DIR=bin/${{ matrix.goos }}-${{ matrix.goarch }}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create archive
|
|
run: |
|
|
cd bin/${{ matrix.goos }}-${{ matrix.goarch }}
|
|
if [[ "${{ matrix.goos }}" == "windows" ]]; then
|
|
mv unchain unchain.exe
|
|
zip unchain.zip unchain.exe
|
|
else
|
|
tar -czvf unchain.tar.gz unchain
|
|
fi
|
|
echo "ARCHIVE_NAME=$(ls *.zip *.tar.gz)" >> $GITHUB_OUTPUT
|
|
id: archive
|
|
|
|
- name: Upload archive to release
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ github.event.release.upload_url }}
|
|
asset_path: bin/${{ matrix.goos }}-${{ matrix.goarch }}/${{ steps.archive.outputs.ARCHIVE_NAME }}
|
|
asset_name: unchain-${{ matrix.goos }}-${{ matrix.goarch }}.${{ steps.archive.outputs.ARCHIVE_NAME}}
|
|
asset_content_type: application/octet-stream
|
|
|
|
|