Skip to content

Build and Release

Build and Release #13

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