Spaces:
Running
Running
Create .github/workflows/release.yml
Browse files
.github/workflows/release.yml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Go Build
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
release: # 只在Release创建时触发
|
| 5 |
+
types:
|
| 6 |
+
- created # 当新Release创建时触发
|
| 7 |
+
workflow_dispatch: # 手动触发(可选)
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
build:
|
| 11 |
+
name: Build
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
strategy:
|
| 14 |
+
fail-fast: false
|
| 15 |
+
matrix:
|
| 16 |
+
include:
|
| 17 |
+
- goos: windows
|
| 18 |
+
goarch: 386
|
| 19 |
+
- goos: windows
|
| 20 |
+
goarch: amd64
|
| 21 |
+
- goos: windows
|
| 22 |
+
goarch: arm64
|
| 23 |
+
- goos: linux
|
| 24 |
+
goarch: 386
|
| 25 |
+
- goos: linux
|
| 26 |
+
goarch: amd64
|
| 27 |
+
- goos: linux
|
| 28 |
+
goarch: arm64
|
| 29 |
+
- goos: freebsd
|
| 30 |
+
goarch: 386
|
| 31 |
+
- goos: freebsd
|
| 32 |
+
goarch: amd64
|
| 33 |
+
- goos: freebsd
|
| 34 |
+
goarch: arm64
|
| 35 |
+
steps:
|
| 36 |
+
- name: Checkout code
|
| 37 |
+
uses: actions/checkout@v3
|
| 38 |
+
|
| 39 |
+
- name: Setup Go
|
| 40 |
+
uses: actions/setup-go@v4
|
| 41 |
+
with:
|
| 42 |
+
go-version: '1.22'
|
| 43 |
+
|
| 44 |
+
- name: Build
|
| 45 |
+
run: |
|
| 46 |
+
echo "Building for ${{ matrix.goos }} ${{ matrix.goarch }}"
|
| 47 |
+
suffix=""
|
| 48 |
+
if [ "${{ matrix.goos }}" == "windows" ]; then
|
| 49 |
+
suffix=".exe"
|
| 50 |
+
fi
|
| 51 |
+
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ./build/ddgchatgo-${{ matrix.goos }}-${{ matrix.goarch }}$suffix
|
| 52 |
+
|
| 53 |
+
- name: Upload release artifact
|
| 54 |
+
uses: svenstaro/upload-release-action@v2 # 使用此插件将文件上传到Release
|
| 55 |
+
with:
|
| 56 |
+
repo_token: ${{ secrets.GITHUB_TOKEN }} # 使用 GitHub 令牌授权
|
| 57 |
+
file: ./build/ddgchatgo-${{ matrix.goos }}-${{ matrix.goarch }}* # 上传构建产物
|
| 58 |
+
file_glob: true
|
| 59 |
+
tag: ${{ github.ref_name }} # 使用Release的标签作为标识
|
| 60 |
+
name: ddgchatgo-${{ matrix.goos }}-${{ matrix.goarch }}
|