-
Notifications
You must be signed in to change notification settings - Fork 2
210 lines (182 loc) · 5.95 KB
/
mavenBuild.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: Maven构建
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
check-files:
name: 检查仓库文件
runs-on: ubuntu-latest
outputs:
changed-files: ${{ steps.check-changed-files.outputs.all_changed_and_modified_files }}
steps:
- name: 检出仓库内容
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: 检查文件改动情况
id: check-changed-files
uses: tj-actions/[email protected]
with:
since_last_remote_commit: 'true'
- name: 输出更改文件列表
run: echo ${{ steps.check-changed-files.outputs.all_changed_and_modified_files }}
windows-x86-build:
name: Windows x86 构建
runs-on: windows-latest
needs: check-files
if: contains(needs.check-files.outputs.changed-files, 'src/') || (github.event_name == 'push' && contains(github.event.commits[0].message, '+b'))
steps:
- name: 检出仓库内容
uses: actions/checkout@v2
- name: 缓存Maven依赖项
id: cache
uses: actions/cache@v2
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-PNX-CLI-WINDOWS-X86
restore-keys: |
${{ runner.os }}-PNX-CLI-WINDOWS-X86
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Maven构建
run: mvn -B package --file pom.xml
- id: get-version
uses: jactions/[email protected]
- name: 配置msvc环境
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
- name: 本机静态编译
shell: cmd
run: |
chcp 936
cd .\target
native-image -jar PNX-CLI-${{ steps.get-version.outputs.version }}.jar -Dfile.encoding=GBK -H:Name=pnx -H:-CheckToolchain
- name: 添加图标
shell: cmd
run: tool\rcedit-x64 "target\pnx.exe" --set-icon "data\pnx.ico"
- name: 上传可执行文件
uses: actions/upload-artifact@v2
with:
name: PNX-CLI-Windows-x86
path: target/pnx.exe
linux-x86-build:
name: Linux x86 构建
runs-on: ubuntu-20.04
needs: check-files
if: contains(needs.check-files.outputs.changed-files, 'src/') || (github.event_name == 'push' && contains(github.event.commits[0].message, '+b'))
steps:
- name: 检出仓库内容
uses: actions/checkout@v2
- name: 缓存Maven依赖项
id: cache
uses: actions/cache@v2
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-PNX-CLI-LINUX-X86
restore-keys: |
${{ runner.os }}-PNX-CLI-LINUX-X86
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Maven构建
run: mvn -B package --file pom.xml
- id: get-version
uses: jactions/[email protected]
- name: 配置GCC环境
uses: egor-tensin/setup-gcc@v1
with:
version: latest
platform: x64
- name: 本机静态编译
run: |
cd target
native-image -jar PNX-CLI-${{ steps.get-version.outputs.version }}.jar -H:Name=pnx
- name: 上传jar包
uses: actions/upload-artifact@v2
with:
name: PNX-CLI-Jar
path: target/PNX-CLI-*.jar
- name: 上传可执行文件
uses: actions/upload-artifact@v2
with:
name: PNX-CLI-Linux-x86
path: target/pnx
# linux-arm-build:
# name: Linux arm 构建
# runs-on: self-hosted
# needs: check-files
# if: contains(needs.check-files.outputs.changed-files, 'src/') || (github.event_name == 'push' && contains(github.event.commits[0].message, '+b'))
#
# steps:
# - name: 检出仓库内容
# uses: actions/checkout@v2
#
# - name: Maven构建
# run: mvn -B package --file pom.xml
#
# - id: get-version
# uses: jactions/[email protected]
#
# - name: 本机静态编译
# run: |
# cd target
# native-image -jar PNX-CLI-${{ steps.get-version.outputs.version }}.jar -H:Name=pnx
#
# - name: 上传可执行文件
# uses: actions/upload-artifact@v2
# with:
# name: PNX-CLI-Linux-arm
# path: target/pnx
release:
name: 发布发行版
runs-on: ubuntu-latest
needs: [ windows-x86-build, linux-x86-build ]
if: startsWith(github.ref, 'refs/heads/master')
steps:
- name: 检出仓库内容
uses: actions/checkout@v2
with:
fetch-depth: 0
- id: get-version
uses: jactions/[email protected]
- name: 下载Windows x86可执行文件
uses: actions/download-artifact@v2
with:
name: PNX-CLI-Windows-x86
path: target/windows-x86
- name: 下载Linux x86可执行文件
uses: actions/download-artifact@v2
with:
name: PNX-CLI-Linux-x86
path: target/linux-x86
- name: 下载jar包
uses: actions/download-artifact@v2
with:
name: PNX-CLI-Jar
path: target/jar
- name: 压缩可执行文件
run: |
zip -r PNX-CLI-Windows-x86.zip target/windows-x86/pnx.exe
zip -r PNX-CLI-Linux-x86.zip target/linux-x86/pnx
- name: 创建发行版
uses: softprops/action-gh-release@v1
with:
files: |
PNX-CLI-Windows-x86.zip
PNX-CLI-Linux-x86.zip
target/jar/PNX-CLI-${{ steps.get-version.outputs.version }}.jar
draft: false
prerelease: true
tag_name: ${{ steps.get-version.outputs.version }}
name: PNX-CLI v${{ steps.get-version.outputs.version }}
body: ${{ github.sha }}