forked from ChimeraCoder/gojson
-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (44 loc) · 1.37 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
# .github/workflows/release.yml
name: Release
on:
push:
tags:
- 'v*' # 触发标签格式为 v开头,如 v1.0.0
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取所有历史记录用于生成更新日志
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.18.x'
# 如果是跨平台编译
- name: Build Binaries
run: |
# Linux
GOOS=linux GOARCH=amd64 go build -o ./bin/gojson-linux-amd64
# Windows
GOOS=windows GOARCH=amd64 go build -o ./bin/gojson-windows-amd64.exe
# macOS
GOOS=darwin GOARCH=amd64 go build -o ./bin/gojson-darwin-amd64
# 自动生成更新日志
- name: Generate Changelog
run: |
echo "## What's Changed" > CHANGELOG.md
git log $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty=format:"* %s" >> CHANGELOG.md
# 创建 Release
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
./bin/gojson-linux-amd64
./bin/gojson-windows-amd64.exe
./bin/gojson-darwin-amd64
body_path: CHANGELOG.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}