Some checks failed
Go Build & Release / build (amd64, imagehost-linux-amd64, linux) (push) Has been cancelled
Go Build & Release / build (amd64, imagehost-macos-amd64, darwin) (push) Has been cancelled
Go Build & Release / build (amd64, imagehost-windows-amd64.exe, windows) (push) Has been cancelled
Go Build & Release / build (arm64, imagehost-linux-arm64, linux) (push) Has been cancelled
Go Build & Release / build (arm64, imagehost-macos-arm64, darwin) (push) Has been cancelled
67 lines
1.7 KiB
YAML
67 lines
1.7 KiB
YAML
name: Go Build & Release
|
||
|
||
on:
|
||
push:
|
||
branches: [ "main" ]
|
||
tags:
|
||
- 'v*' # 监听形如 v1.0, v2.0 的提交签发事件以触发正式 Release
|
||
pull_request:
|
||
branches: [ "main" ]
|
||
|
||
# 【必需权限声明】:默认情况下的 GitHub Token 只有读能力。赋予 contents: write 才能创建 Release 页面并上传附件
|
||
permissions:
|
||
contents: write
|
||
|
||
jobs:
|
||
build:
|
||
runs-on: ubuntu-latest
|
||
strategy:
|
||
matrix:
|
||
include:
|
||
- os: linux
|
||
arch: amd64
|
||
name: imagehost-linux-amd64
|
||
- os: linux
|
||
arch: arm64
|
||
name: imagehost-linux-arm64
|
||
- os: windows
|
||
arch: amd64
|
||
name: imagehost-windows-amd64.exe
|
||
- os: darwin
|
||
arch: amd64
|
||
name: imagehost-macos-amd64
|
||
- os: darwin
|
||
arch: arm64
|
||
name: imagehost-macos-arm64
|
||
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
|
||
- name: Set up Go
|
||
uses: actions/setup-go@v4
|
||
with:
|
||
go-version: '1.21'
|
||
cache: true
|
||
|
||
- name: Build Binary
|
||
env:
|
||
GOOS: ${{ matrix.os }}
|
||
GOARCH: ${{ matrix.arch }}
|
||
run: |
|
||
mkdir -p dist
|
||
go build -v -o dist/${{ matrix.name }} ./cmd/main.go
|
||
|
||
- name: Upload Artifact (For standard push)
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: ${{ matrix.name }}
|
||
path: dist/${{ matrix.name }}
|
||
|
||
# 关键追加:当检测到 Tag 标签推入时,自动化传给 Release!
|
||
- name: Upload to GitHub Releases
|
||
uses: softprops/action-gh-release@v2
|
||
if: startsWith(github.ref, 'refs/tags/')
|
||
with:
|
||
files: dist/${{ matrix.name }}
|
||
generate_release_notes: true
|