-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (55 loc) · 1.88 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Release Coss Cli
on:
push:
tags:
- 'v*.*.*' # 只在 tag push 时触发工作流
jobs:
build-and-release:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [ linux, windows, darwin ]
arch: [ amd64 ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22
- name: Set environment variables
run: |
echo "GOOS=${{ matrix.platform }}" >> $GITHUB_ENV
echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV
if [ "${{ matrix.platform }}" = "windows" ]; then
echo "EXT=.exe" >> $GITHUB_ENV
else
echo "EXT=" >> $GITHUB_ENV
fi
- name: Build
run: |
make build
# 输出构建好的文件
ls build/${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}*
env:
GO: go
VERSION: ${{ github.ref_name }}
- name: Create Release
id: create_release
if: ${{ matrix.platform == 'linux' && matrix.arch == 'amd64' }} # 只在一个平台上创建发布,以避免重复创建
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
body: Release version ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}*
asset_name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}
asset_content_type: application/octet-stream