|
|
@@ -2,6 +2,31 @@ name: Build
|
|
2
|
2
|
|
|
3
|
3
|
on:
|
|
4
|
4
|
workflow_dispatch:
|
|
|
5
|
+ inputs:
|
|
|
6
|
+ BASE_IMAGE_NAMESPACE:
|
|
|
7
|
+ description: 'Base image namespace (Default: Your Github username)'
|
|
|
8
|
+ required: false
|
|
|
9
|
+ default: ''
|
|
|
10
|
+ DOCKERHUB_IMAGE_NAMESPACE:
|
|
|
11
|
+ description: 'Docker Hub image namespace (Default: Your Github username)'
|
|
|
12
|
+ required: false
|
|
|
13
|
+ default: ''
|
|
|
14
|
+ GHCR_IMAGE_NAMESPACE:
|
|
|
15
|
+ description: 'GitHub Container Registry image namespace (Default: Your Github username)'
|
|
|
16
|
+ required: false
|
|
|
17
|
+ default: ''
|
|
|
18
|
+ SKIP_DOCKER_HUB:
|
|
|
19
|
+ description: 'Set to true to skip pushing to Docker Hub (default: false)'
|
|
|
20
|
+ required: false
|
|
|
21
|
+ default: 'false'
|
|
|
22
|
+ SKIP_GHCR:
|
|
|
23
|
+ description: 'Set to true to skip pushing to GHCR (default: false)'
|
|
|
24
|
+ required: false
|
|
|
25
|
+ default: 'false'
|
|
|
26
|
+ WEBCLIENT_SOURCE_LOCATION:
|
|
|
27
|
+ description: 'Web Client API Repository'
|
|
|
28
|
+ required: true
|
|
|
29
|
+ default: 'https://github.com/lejianwen/rustdesk-api-web'
|
|
5
|
30
|
push:
|
|
6
|
31
|
tags:
|
|
7
|
32
|
- 'v*.*.*' # 当推送带有版本号的 tag(例如 v1.0.0)时触发工作流
|
|
|
@@ -9,6 +34,12 @@ on:
|
|
9
|
34
|
|
|
10
|
35
|
env:
|
|
11
|
36
|
LATEST_TAG: latest
|
|
|
37
|
+ WEBCLIENT_SOURCE_LOCATION: ${{ github.event.inputs.WEBCLIENT_SOURCE_LOCATION }}
|
|
|
38
|
+ BASE_IMAGE_NAMESPACE: ${{ github.event.inputs.BASE_IMAGE_NAMESPACE || github.actor }}
|
|
|
39
|
+ DOCKERHUB_IMAGE_NAMESPACE: ${{ github.event.inputs.DOCKERHUB_IMAGE_NAMESPACE || github.actor }}
|
|
|
40
|
+ GHCR_IMAGE_NAMESPACE: ${{ github.event.inputs.GHCR_IMAGE_NAMESPACE || github.actor }}
|
|
|
41
|
+ SKIP_DOCKER_HUB: ${{ github.event.inputs.SKIP_DOCKER_HUB }}
|
|
|
42
|
+ SKIP_GHCR: ${{ github.event.inputs.SKIP_GHCR }}
|
|
12
|
43
|
jobs:
|
|
13
|
44
|
build:
|
|
14
|
45
|
runs-on: ubuntu-latest
|
|
|
@@ -38,7 +69,7 @@ jobs:
|
|
38
|
69
|
|
|
39
|
70
|
- name: build rustdesk-api-web
|
|
40
|
71
|
run: |
|
|
41
|
|
- git clone https://github.com/lejianwen/rustdesk-api-web
|
|
|
72
|
+ git clone ${{ env.WEBCLIENT_SOURCE_LOCATION }}
|
|
42
|
73
|
cd rustdesk-api-web
|
|
43
|
74
|
npm install
|
|
44
|
75
|
npm run build
|
|
|
@@ -86,13 +117,13 @@ jobs:
|
|
86
|
117
|
path: |
|
|
87
|
118
|
${{ matrix.job.goos}}-${{ matrix.job.platform }}.tar.gz
|
|
88
|
119
|
${{ matrix.job.goos}}-${{ matrix.job.platform }}.zip
|
|
89
|
|
-
|
|
90
|
120
|
- name: Upload to GitHub Release
|
|
91
|
121
|
uses: softprops/action-gh-release@v2
|
|
92
|
122
|
with:
|
|
93
|
123
|
files: |
|
|
94
|
124
|
${{ matrix.job.goos}}-${{ matrix.job.platform }}.tar.gz
|
|
95
|
125
|
${{ matrix.job.goos}}-${{ matrix.job.platform }}.zip
|
|
|
126
|
+ tag_name: ${{ env.LATEST_TAG }}
|
|
96
|
127
|
env:
|
|
97
|
128
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
98
|
129
|
|
|
|
@@ -117,20 +148,34 @@ jobs:
|
|
117
|
148
|
uses: docker/setup-buildx-action@v2
|
|
118
|
149
|
|
|
119
|
150
|
- name: Log in to Docker Hub
|
|
|
151
|
+ if: ${{ env.SKIP_DOCKER_HUB == 'false' }} # Only log in if SKIP_DOCKER_HUB is false
|
|
120
|
152
|
uses: docker/login-action@v2
|
|
121
|
153
|
with:
|
|
122
|
154
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
123
|
155
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
|
124
|
156
|
|
|
|
157
|
+ - name: Log in to GitHub Container Registry
|
|
|
158
|
+ if: ${{ env.SKIP_GHCR == 'false' }} # Only log in if GHCR push is enabled
|
|
|
159
|
+ uses: docker/login-action@v2
|
|
|
160
|
+ with:
|
|
|
161
|
+ registry: ghcr.io
|
|
|
162
|
+ username: ${{ github.actor }}
|
|
|
163
|
+ password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
164
|
+
|
|
125
|
165
|
- name: Extract version from tag
|
|
126
|
166
|
id: vars
|
|
127
|
|
- run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
|
|
167
|
+ run: |
|
|
|
168
|
+ if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
|
|
169
|
+ echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
|
|
170
|
+ else
|
|
|
171
|
+ echo "TAG=latest" >> $GITHUB_ENV # Default to 'latest' if not a tag
|
|
|
172
|
+ fi
|
|
128
|
173
|
|
|
129
|
174
|
- name: Extract metadata (tags, labels) for Docker
|
|
130
|
175
|
id: meta
|
|
131
|
176
|
uses: docker/metadata-action@v4
|
|
132
|
177
|
with:
|
|
133
|
|
- images: lejianwen/rustdesk-api
|
|
|
178
|
+ images: ${{ env.BASE_IMAGE_NAMESPACE }}/rustdesk-api
|
|
134
|
179
|
|
|
135
|
180
|
- name: Download binaries
|
|
136
|
181
|
uses: actions/download-artifact@v4
|
|
|
@@ -144,7 +189,8 @@ jobs:
|
|
144
|
189
|
tar -xzf ${{ matrix.job.goos }}-${{ matrix.job.platform }}.tar.gz -C ${{ matrix.job.platform }}
|
|
145
|
190
|
file ${{ matrix.job.platform }}/apimain
|
|
146
|
191
|
|
|
147
|
|
- - name: Build and push Docker image ${{ matrix.job.platform }}
|
|
|
192
|
+ - name: Build and push Docker image to Docker Hub ${{ matrix.job.platform }}
|
|
|
193
|
+ if: ${{ env.SKIP_DOCKER_HUB == 'false' }} # Only run this step if SKIP_DOCKER_HUB is false
|
|
148
|
194
|
uses: docker/build-push-action@v5
|
|
149
|
195
|
with:
|
|
150
|
196
|
context: "."
|
|
|
@@ -155,8 +201,24 @@ jobs:
|
|
155
|
201
|
build-args: |
|
|
156
|
202
|
BUILDARCH=${{ matrix.job.platform }}
|
|
157
|
203
|
tags: |
|
|
158
|
|
- lejianwen/rustdesk-api:${{ env.LATEST_TAG }}-${{ matrix.job.platform }}
|
|
159
|
|
- lejianwen/rustdesk-api:${{ env.TAG }}-${{ matrix.job.platform }}
|
|
|
204
|
+ ${{ env.DOCKERHUB_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.LATEST_TAG }}-${{ matrix.job.platform }},
|
|
|
205
|
+ ${{ env.DOCKERHUB_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.TAG }}-${{ matrix.job.platform }}
|
|
|
206
|
+ labels: ${{ steps.meta.outputs.labels }}
|
|
|
207
|
+
|
|
|
208
|
+ - name: Build and push Docker image to GHCR ${{ matrix.job.platform }}
|
|
|
209
|
+ if: ${{ env.SKIP_GHCR == 'false' }} # Only run this step if SKIP_GHCR is false
|
|
|
210
|
+ uses: docker/build-push-action@v5
|
|
|
211
|
+ with:
|
|
|
212
|
+ context: "."
|
|
|
213
|
+ file: ./Dockerfile
|
|
|
214
|
+ platforms: ${{ matrix.job.docker_platform }}
|
|
|
215
|
+ push: true
|
|
|
216
|
+ provenance: false
|
|
|
217
|
+ build-args: |
|
|
|
218
|
+ BUILDARCH=${{ matrix.job.platform }}
|
|
|
219
|
+ tags: |
|
|
|
220
|
+ ghcr.io/${{ env.GHCR_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.LATEST_TAG }}-${{ matrix.job.platform }},
|
|
|
221
|
+ ghcr.io/${{ env.GHCR_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.TAG }}-${{ matrix.job.platform }}
|
|
160
|
222
|
labels: ${{ steps.meta.outputs.labels }}
|
|
161
|
223
|
|
|
162
|
224
|
#
|
|
|
@@ -167,24 +229,62 @@ jobs:
|
|
167
|
229
|
steps:
|
|
168
|
230
|
- name: Extract version from tag
|
|
169
|
231
|
id: vars
|
|
170
|
|
- run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
|
|
232
|
+ run: |
|
|
|
233
|
+ if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
|
|
234
|
+ echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
|
|
235
|
+ else
|
|
|
236
|
+ echo "TAG=latest" >> $GITHUB_ENV # Default to 'latest' if not a tag
|
|
|
237
|
+ fi
|
|
171
|
238
|
|
|
172
|
239
|
- name: Log in to Docker Hub
|
|
|
240
|
+ if: ${{ env.SKIP_DOCKER_HUB == 'false' }} # Only log in if Docker Hub push is enabled
|
|
173
|
241
|
uses: docker/login-action@v2
|
|
174
|
242
|
with:
|
|
175
|
243
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
176
|
244
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
|
177
|
245
|
|
|
178
|
|
- - name: Create and push manifest (:version)
|
|
|
246
|
+ - name: Log in to GitHub Container Registry
|
|
|
247
|
+ if: ${{ env.SKIP_GHCR == 'false' }} # Only log in if GHCR push is enabled
|
|
|
248
|
+ uses: docker/login-action@v2
|
|
|
249
|
+ with:
|
|
|
250
|
+ registry: ghcr.io
|
|
|
251
|
+ username: ${{ github.actor }}
|
|
|
252
|
+ password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
253
|
+
|
|
|
254
|
+ - name: Create and push manifest Docker Hub (:version)
|
|
|
255
|
+ if: ${{ env.SKIP_DOCKER_HUB == 'false' }}
|
|
|
256
|
+ uses: Noelware/docker-manifest-action@master
|
|
|
257
|
+ with:
|
|
|
258
|
+ base-image: ${{ env.BASE_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.TAG }}
|
|
|
259
|
+ extra-images: ${{ env.DOCKERHUB_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.TAG }}-amd64,
|
|
|
260
|
+ ${{ env.DOCKERHUB_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.TAG }}-arm64
|
|
|
261
|
+ push: true
|
|
|
262
|
+
|
|
|
263
|
+ - name: Create and push manifest GHCR (:version)
|
|
|
264
|
+ if: ${{ env.SKIP_GHCR == 'false' }}
|
|
|
265
|
+ uses: Noelware/docker-manifest-action@master
|
|
|
266
|
+ with:
|
|
|
267
|
+ base-image: ghcr.io/${{ env.BASE_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.TAG }}
|
|
|
268
|
+ extra-images: ghcr.io/${{ env.GHCR_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.TAG }}-amd64,
|
|
|
269
|
+ ghcr.io/${{ env.GHCR_IMAGE_NAMESPACE }}/rustdesk-api:${{ env.TAG }}-arm64
|
|
|
270
|
+ push: true
|
|
|
271
|
+ amend: true
|
|
|
272
|
+
|
|
|
273
|
+ - name: Create and push manifest Docker Hub (:latest)
|
|
|
274
|
+ if: ${{ env.SKIP_DOCKER_HUB == 'false' }}
|
|
179
|
275
|
uses: Noelware/docker-manifest-action@master
|
|
180
|
276
|
with:
|
|
181
|
|
- base-image: lejianwen/rustdesk-api:${{ env.TAG }}
|
|
182
|
|
- extra-images: lejianwen/rustdesk-api:${{ env.TAG }}-amd64,lejianwen/rustdesk-api:${{ env.TAG }}-arm64
|
|
|
277
|
+ base-image: ${{ env.BASE_IMAGE_NAMESPACE }}/rustdesk-api:latest
|
|
|
278
|
+ extra-images: ${{ env.DOCKERHUB_IMAGE_NAMESPACE }}/rustdesk-api:latest-amd64,
|
|
|
279
|
+ ${{ env.DOCKERHUB_IMAGE_NAMESPACE }}/rustdesk-api:latest-arm64
|
|
183
|
280
|
push: true
|
|
184
|
281
|
|
|
185
|
|
- - name: Create and push manifest (:latest)
|
|
|
282
|
+ - name: Create and push manifest GHCR (:latest)
|
|
|
283
|
+ if: ${{ env.SKIP_GHCR == 'false' }}
|
|
186
|
284
|
uses: Noelware/docker-manifest-action@master
|
|
187
|
285
|
with:
|
|
188
|
|
- base-image: lejianwen/rustdesk-api:latest
|
|
189
|
|
- extra-images: lejianwen/rustdesk-api:latest-amd64,lejianwen/rustdesk-api:latest-arm64
|
|
|
286
|
+ base-image: ghcr.io/${{ env.BASE_IMAGE_NAMESPACE }}/rustdesk-api:latest
|
|
|
287
|
+ extra-images: ghcr.io/${{ env.GHCR_IMAGE_NAMESPACE }}/rustdesk-api:latest-amd64,
|
|
|
288
|
+ ghcr.io/${{ env.GHCR_IMAGE_NAMESPACE }}/rustdesk-api:latest-arm64
|
|
190
|
289
|
push: true
|
|
|
290
|
+ amend: true
|