-
Notifications
You must be signed in to change notification settings - Fork 9
285 lines (246 loc) · 10.1 KB
/
build-test.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: Build test
on: workflow_dispatch
jobs:
build-UI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: build UI
run: |
cd ui
npm install @vue/cli-service @vue/cli-plugin-babel @vue/cli-plugin-eslint @vue/cli-plugin-router
npm run build
ls
- name: Upload UI artifact
uses: actions/upload-artifact@v3
with:
name: UI
path: ui/dist/ # 上传 dist 目录
build-jar:
runs-on: ubuntu-latest
needs: build-UI
steps:
- uses: actions/checkout@v2
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: UI
path: src/main/resources/static/
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: |
mvn -B package --file pom.xml
- name: Upload jar artifact
uses: actions/upload-artifact@v3
with:
name: jar
path: target/ # 上传 target 目录
build-amd64:
permissions: write-all
runs-on: ubuntu-latest
needs: build-jar
steps:
- uses: actions/checkout@v3
- name: Download jar artifact
uses: actions/download-artifact@v3
with:
name: jar
path: .
# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}
# 获取最新yt-dlp、ffmpeg和jre8
- name: Get yt-dlp And ffmpeg-package
run: |
wget https://cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jre8.0.412-linux_x64.tar.gz
tar -xzf zulu8.78.0.19-ca-jre8.0.412-linux_x64.tar.gz
mv zulu8.78.0.19-ca-jre8.0.412-linux_x64 jre8
curl -L -o yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux
cp -rf ffmpeg-package/linux/amd64/ffmpeg .
chmod a+x yt-dlp ffmpeg
ls
# 构建 amd64 Docker镜像
- name: Build the amd64 Docker image
run: |
docker build . --file Dockerfile --tag yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d) --platform linux/amd64
docker push yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
build-arm64:
permissions: write-all
runs-on: ubuntu-latest
needs: build-jar
steps:
- uses: actions/checkout@v3
with:
arch: aarch64
- name: Download jar artifact
uses: actions/download-artifact@v3
with:
name: jar
path: .
# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# 通过 git 命令获取当前 tag 信息, 存入环境变量 APP_VERSION
- name: Generate App Version
run: echo "APP_VERSION=$(curl --silent "https://api.github.com/repos/yajuhua/podcast2/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" >> $GITHUB_ENV
# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}
# 获取最新yt-dlp和ffmpeg
- name: Get yt-dlp And ffmpeg-package
run: |
wget https://cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jre8.0.412-linux_aarch64.tar.gz
tar -xzf zulu8.78.0.19-ca-jre8.0.412-linux_aarch64.tar.gz
mv zulu8.78.0.19-ca-jre8.0.412-linux_aarch64 jre8
curl -L -o yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_aarch64
cp -rf ffmpeg-package/linux/arm64/ffmpeg .
chmod a+x yt-dlp ffmpeg
ls
# 构建 arm64 Docker镜像
- name: Build the arm64 Docker image
run: |
docker build . --file Dockerfile --tag yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d) --platform linux/arm64
docker push yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d)
build-arm32v7:
permissions: write-all
runs-on: ubuntu-latest
needs: build-jar
steps:
- uses: actions/checkout@v3
with:
arch: armv7
- name: Download jar artifact
uses: actions/download-artifact@v3
with:
name: jar
path: .
# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# 通过 git 命令获取当前 tag 信息, 存入环境变量 APP_VERSION
- name: Generate App Version
run: echo "APP_VERSION=$(curl --silent "https://api.github.com/repos/yajuhua/podcast2/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" >> $GITHUB_ENV
# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}
# 获取最新yt-dlp和ffmpeg
- name: Get yt-dlp And ffmpeg-package
run: |
wget https://cdn.azul.com/zulu-embedded/bin/zulu8.76.0.17-ca-jre8.0.402-linux_aarch32hf.tar.gz
tar -xzf zulu8.76.0.17-ca-jre8.0.402-linux_aarch32hf.tar.gz
mv zulu8.76.0.17-ca-jre8.0.402-linux_aarch32hf jre8
curl -L -o yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_armv7l
cp -rf ffmpeg-package/linux/armv7/ffmpeg .
chmod a+x yt-dlp ffmpeg
ls
# 构建 arm32v7 Docker镜像
- name: Build the arm32v7 Docker image
run: |
docker build . --file Dockerfile --tag yajuhua/podcast2:arm32v7-$(date +test-%Y-%m-%d) --platform linux/arm/v7
docker push yajuhua/podcast2:arm32v7-$(date +test-%Y-%m-%d)
push-docker-hub:
permissions: write-all
runs-on: ubuntu-latest
needs: [ build-arm64,build-amd64,build-arm32v7]
steps:
# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: pull amd4 and arm64 docker images
run: |
docker pull yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d)
docker pull yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
docker pull yajuhua/podcast2:arm32v7-$(date +test-%Y-%m-%d)
# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}
- name: create manifest
run: |
docker manifest create yajuhua/podcast2:beta-$(date +%Y-%m-%d) yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d) yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d) yajuhua/podcast2:arm32v7-$(date +test-%Y-%m-%d)
- name: push manifest
run: |
docker manifest push yajuhua/podcast2:beta-$(date +%Y-%m-%d)
build-installation-package:
permissions: write-all
runs-on: ubuntu-latest
needs: build-jar
steps:
- name: Download jar artifact
- run: mkdir tmp
uses: actions/download-artifact@v3
with:
name: jar
path: tmp/
- name: Build windows
run: |
RELEASE=$(curl --silent "https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
echo "${RELEASE}"
ls
unzip tmp/app.jar
curl -L -o "platform/windows/yt-dlp.exe" "https://github.com/yt-dlp/yt-dlp/releases/download/${RELEASE}/yt-dlp.exe"
cp -rf BOOT-INF/classes BOOT-INF/lib "${{ env.GITHUB_WORKSPACE }}platform/windows/"
zip -r podcast2-win-x64.zip platform/windows/
- name: Build osx
run: |
curl -L -o "${{ env.GITHUB_WORKSPACE }}platform/osx/yt-dlp" "https://github.com/yt-dlp/yt-dlp/releases/download/${RELEASE}/yt-dlp_macos_legacy"
chmod a+x platform/osx/yt-dlp
cp -rf BOOT-INF/classes BOOT-INF/lib "${{ env.GITHUB_WORKSPACE }}platform/osx/"
zip -r podcast2-osx-x64.zip "${{ env.GITHUB_WORKSPACE }}platform/osx/"
# 上传文件并发布 Release
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "$(date +beta-%Y-%m-%d)"
prerelease: true
title: "${{ env.RELEASE_VERSION }}"
files: |
podcast2-win-x64.zip
podcast2-osx-x64.zip