Build and Release #13
Workflow file for this run
This file contains 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 Release | |
on: | |
push: | |
tags: | |
- v* # 仅当新增特定的标签时触发,例如 v1.0.0 | |
jobs: | |
build: | |
name: Build binaries | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [linux, windows, darwin] # 编译目标操作系统 | |
goarch: [amd64] # 编译目标架构 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go 1.21.3 | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.21.3 | |
- name: Build binary | |
run: | | |
mkdir -p dist | |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/routing-${{ matrix.goos }}-${{ matrix.goarch }} | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: routing-${{ matrix.goos }}-${{ matrix.goarch }} | |
path: dist/routing-${{ matrix.goos }}-${{ matrix.goarch }} | |
release: | |
name: Create GitHub Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download binaries - Linux | |
uses: actions/download-artifact@v4 | |
with: | |
name: routing-linux-amd64 | |
path: ./dist/linux-amd64 | |
- name: Download binaries - Windows | |
uses: actions/download-artifact@v4 | |
with: | |
name: routing-windows-amd64 | |
path: ./dist/windows-amd64 | |
- name: Download binaries - macOS | |
uses: actions/download-artifact@v4 | |
with: | |
name: routing-darwin-amd64 | |
path: ./dist/darwin-amd64 | |
- name: Rename Windows binary | |
run: mv ./dist/windows-amd64/routing-windows-amd64 ./dist/windows-amd64/routing-windows-amd64.exe | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ./dist/linux-amd64/routing-linux-amd64,./dist/windows-amd64/routing-windows-amd64.exe,./dist/darwin-amd64/routing-darwin-amd64 |