-
Notifications
You must be signed in to change notification settings - Fork 17
196 lines (182 loc) · 7.16 KB
/
release.yaml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: Go Build and Release
on:
push:
tags:
- 'v*' # Trigger on version tags (e.g., v1.2.3)
# branches:
# - main # Trigger on push to main branch as well
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the release'
required: true
default: 'v2.0.1-Beta.3' # Default tag name
permissions:
contents: write # Allow writing to GitHub releases
# - [👏]
# - [🔧]
env:
PROJECT_NAME: ${{ github.event.repository.name }}
BUILD_DATE: ${{ github.run_id }}
VERSION: ${{ github.ref_name }} # Dynamic version based on the tag name
RELEASE_DIR: release
RELEASE_NOTICES: |
- [🔧] 优化AI提示词提高写题正确率
注:等GO版本追平Java版本功能后Java版本将不再进行维护,后续将主要针对GO版本进行维护,Java将不会更新新功能和适配新平台。
jobs:
# Linux build job
build-linux:
name: Build Linux
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full git history for versioning
# Install necessary dependencies
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev pkg-config gcc-aarch64-linux-gnu
# Set up Go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod' # Use Go version from go.mod
cache: true # Enable dependency caching
- name: Get dependencies
run: |
export GOPROXY=direct
export GONOSUMDB=*
go mod tidy
- name: Prepare Release Directory #创建压缩目录
run: mkdir -p ${{ env.RELEASE_DIR }}/yatori-go-console.${{env.VERSION}}-linux-amd64-release
# Build Linux AMD64
- name: Build Linux AMD64
run: |
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
-o ${{ env.RELEASE_DIR }}/yatori-go-console.${{env.VERSION}}-linux-amd64-release/${{ env.PROJECT_NAME }}
- name: Create release tar
run: | # 打包发布版本压缩包
cp command/config.yaml ${{ env.RELEASE_DIR }}/yatori-go-console.${{env.VERSION}}-linux-amd64-release
cd ${{ env.RELEASE_DIR }}
tar -czvf yatori-go-console.${{env.VERSION}}-linux-amd64-release.tar.gz yatori-go-console.${{env.VERSION}}-linux-amd64-release
rm -rf yatori-go-console.${{env.VERSION}}-linux-amd64-release
cd ..
# Create GitHub Release
- name: Create GitHub Release with custom notes
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ env.RELEASE_DIR }}/* # 文件发布目录
# generate_release_notes: true # 自动发行说明
draft: false # 不创建草稿发布
prerelease: false # 不标记为预发布
tag_name: ${{ env.VERSION }} # 从标签中使用动态版本
body: ${{env.RELEASE_NOTICES}} # 使用读取到的发布说明内容
# Windows build job
build-windows:
name: Build Windows
runs-on: windows-latest
needs: build-linux # Ensure Linux build completes first
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full git history for versioning
# Set up Go for Windows
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod' # Use Go version from go.mod
cache: true # Enable dependency caching
- name: Get dependencies
run: |
set GOPROXY=direct
set GONOSUMDB=*
go clean -modcache
del go.sum
go get -u ./...
go mod tidy
- name: Prepare Release Directory
run: mkdir -p ${{ env.RELEASE_DIR }}\yatori-go-console.${{env.VERSION}}-windows-amd64-release
# Build Windows AMD64
- name: Build Windows AMD64
run: |
set CGO_ENABLED=1
set GOOS=windows
set GOARCH=amd64
go build -o ${{ env.RELEASE_DIR }}\yatori-go-console.${{env.VERSION}}-windows-amd64-release\${{ env.PROJECT_NAME }}.exe
# tar -czvf yatori-go-console.${{env.VERSION}}-windows-amd64-release.tar.gz yatori-go-console.${{env.VERSION}}-windows-amd64-release 这个是windows打包tar.gz包的
- name: Create Release zip
run: |
copy command\config.yaml ${{ env.RELEASE_DIR }}\yatori-go-console.${{env.VERSION}}-windows-amd64-release
copy command\start.bat ${{ env.RELEASE_DIR }}\yatori-go-console.${{env.VERSION}}-windows-amd64-release
cd ${{ env.RELEASE_DIR }}
Compress-Archive -Path "yatori-go-console.${{env.VERSION}}-windows-amd64-release" -DestinationPath "yatori-go-console.${{env.VERSION}}-windows-amd64-release.zip"
Remove-Item -Recurse -Force "yatori-go-console.${{env.VERSION}}-windows-amd64-release"
cd ..
# Create GitHub Release
- name: Create Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ${{ env.RELEASE_DIR }}/* # 文件发布目录
generate_release_notes: true # 自动发行说明
draft: false # 不创建草稿发布
prerelease: false # 不标记为预发布
tag_name: ${{ env.VERSION }} # 从标签中使用动态版本
# # Create release on GitHub
# release:
# name: Create Release
# runs-on: ubuntu-latest
# needs: [build-linux, build-windows]
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Prepare Release Directory
# run: mkdir -p ${{ env.RELEASE_DIR }}
#
# # List files to verify the release directory contains binaries
# - name: List files in release directory
# run: |
# ls -l ${{ env.RELEASE_DIR }}
#
# # Create Source Code Tarball
# - name: Create Source Code Tarball
# run: |
# tar -czvf ${{ env.RELEASE_DIR }}/${{ env.PROJECT_NAME }}_${{ env.BUILD_DATE }}_source.tar.gz \
# --exclude=.git \
# --exclude=${{ env.RELEASE_DIR }} \
# .
#
# # Create Source Code Zip
# - name: Create Source Code Zip
# run: |
# zip -r ${{ env.RELEASE_DIR }}/${{ env.PROJECT_NAME }}_${{ env.BUILD_DATE }}_source.zip \
# . \
# -x .git\* \
# -x release\*
#
# # Generate SHA256 Checksums
# - name: Generate SHA256 Checksums
# run: |
# cd ${{ env.RELEASE_DIR }}
# sha256sum * > ${{ env.PROJECT_NAME }}_${{ env.BUILD_DATE }}_checksums.txt
#
# # Create GitHub Release
# - name: Create Release
# uses: softprops/action-gh-release@v2
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# files: ${{ env.RELEASE_DIR }}/* # 文件发布目录
# generate_release_notes: true # 自动发行说明
# draft: false # 不创建草稿发布
# prerelease: false # 不标记为预发布
# tag_name: ${{ env.VERSION }} # 从标签中使用动态版本