18
18
branches :
19
19
- Alpha
20
20
concurrency :
21
- group : ${{ github.workflow }}-${{ github.ref }}
21
+ group : " ${{ github.workflow }}-${{ github.ref }}"
22
22
cancel-in-progress : true
23
23
24
24
env :
@@ -270,7 +270,7 @@ jobs:
270
270
- name : Archive production artifacts
271
271
uses : actions/upload-artifact@v4
272
272
with :
273
- name : ${{ matrix.jobs.goos }}-${{ matrix.jobs.output }}
273
+ name : " ${{ matrix.jobs.goos }}-${{ matrix.jobs.output }}"
274
274
path : |
275
275
mihomo*.gz
276
276
mihomo*.deb
@@ -415,35 +415,35 @@ jobs:
415
415
uses : docker/setup-buildx-action@v3
416
416
with :
417
417
version : latest
418
-
419
- - name : Set Docker tags and labels based on trigger
420
- id : set-meta
421
- run : |
422
- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
423
- echo "tags=${{ github.event.inputs.version }}" >> $GITHUB_ENV
424
- echo "labels=org.opencontainers.image.version=${{ github.event.inputs.version }}" >> $GITHUB_ENV
425
- else
426
- echo "tags=${{ steps.meta.outputs.tags }}" >> $GITHUB_ENV
427
- echo "labels=${{ steps.meta.outputs.labels }}" >> $GITHUB_ENV
428
- fi
429
-
430
-
418
+
431
419
# Extract metadata (tags, labels) for Docker
432
420
# https://github.com/docker/metadata-action
433
421
- name : Extract Docker metadata
434
- id : meta
422
+ if : ${{ github.event_name != 'workflow_dispatch' }}
423
+ id : meta_alpha
435
424
uses : docker/metadata-action@v5
436
425
with :
437
- images : ${{ env.REGISTRY }}/${{ github.repository }}
438
- tags : ${{ env.tags }}
439
- labels : ${{ env.labels }}
440
-
441
-
426
+ images : ' ${{ env.REGISTRY }}/${{ github.repository }}'
427
+
428
+ # Extract metadata (tags, labels) for Docker
429
+ # https://github.com/docker/metadata-action
430
+ - name : Extract Docker metadata
431
+ if : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
432
+ id : meta_release
433
+ uses : docker/metadata-action@v5
434
+ with :
435
+ images : ' ${{ env.REGISTRY }}/${{ github.repository }}'
436
+ tags : |
437
+ ${{ github.event.inputs.version }}
438
+ flavor : |
439
+ latest=true
440
+ labels : org.opencontainers.image.version=${{ github.event.inputs.version }}
441
+
442
442
- name : Show files
443
443
run : |
444
444
ls .
445
445
ls bin/
446
-
446
+
447
447
- name : login to docker REGISTRY
448
448
uses : docker/login-action@v3
449
449
with :
@@ -454,7 +454,22 @@ jobs:
454
454
# Build and push Docker image with Buildx (don't push on PR)
455
455
# https://github.com/docker/build-push-action
456
456
- name : Build and push Docker image
457
- id : build-and-push
457
+ if : ${{ github.event_name != 'workflow_dispatch' }}
458
+ uses : docker/build-push-action@v5
459
+ with :
460
+ context : .
461
+ file : ./Dockerfile
462
+ push : ${{ github.event_name != 'pull_request' }}
463
+ platforms : |
464
+ linux/386
465
+ linux/amd64
466
+ linux/arm64
467
+ linux/arm/v7
468
+ tags : ${{ steps.meta_alpha.outputs.tags }}
469
+ labels : ${{ steps.meta_alpha.outputs.labels }}
470
+
471
+ - name : Build and push Docker image
472
+ if : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
458
473
uses : docker/build-push-action@v5
459
474
with :
460
475
context : .
@@ -465,5 +480,5 @@ jobs:
465
480
linux/amd64
466
481
linux/arm64
467
482
linux/arm/v7
468
- tags : ${{ steps.meta .outputs.tags }}
469
- labels : ${{ steps.meta .outputs.labels }}
483
+ tags : ${{ steps.meta_release .outputs.tags }}
484
+ labels : ${{ steps.meta_release .outputs.labels }}
0 commit comments