Skip to content

Commit 5ef718f

Browse files
Simplify release workflows by removing matrix strategy and steps (#177)
* refactor: simplify release workflows by removing matrix strategy and unnecessary steps * fix: update release workflows to support pre-release tags and improve local build handling
1 parent 0cd76b0 commit 5ef718f

2 files changed

Lines changed: 38 additions & 100 deletions

File tree

.github/workflows/release-pullrequest.yaml

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,46 @@ on:
77

88
env:
99
GHCR_REPO: ghcr.io/${{ github.repository }}
10+
LOCAL_KIND: false
1011

1112
jobs:
1213
build:
13-
name: Build and Push
14-
strategy:
15-
matrix:
16-
runner: [buildjet-2vcpu-ubuntu-2204-arm, buildjet-2vcpu-ubuntu-2204]
17-
include:
18-
- runner: buildjet-2vcpu-ubuntu-2204-arm
19-
platform: linux/arm64
20-
- runner: buildjet-2vcpu-ubuntu-2204
21-
platform: linux/amd64
22-
runs-on: ${{ matrix.runner }}
14+
runs-on: ubuntu-latest
2315

2416
permissions:
2517
contents: read
2618
packages: write
2719

2820
steps:
29-
- name: Prepare
30-
run: |
31-
platform=${{ matrix.platform }}
32-
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
21+
- name: Checkout
22+
uses: actions/checkout@v4
3323

3424
- name: Docker meta
3525
id: meta
3626
uses: docker/metadata-action@v5
3727
with:
3828
images: ${{ env.GHCR_REPO }}
3929

40-
- name: Login to GHCR
41-
uses: docker/login-action@v3
42-
with:
43-
registry: ghcr.io
44-
username: ${{ github.repository_owner }}
45-
password: ${{ secrets.GITHUB_TOKEN }}
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v3
4632

4733
- name: Set up Docker Buildx
4834
uses: docker/setup-buildx-action@v3
4935

50-
- name: Build and NOT push
51-
id: build
36+
- name: Build (no push)
5237
uses: docker/build-push-action@v5
5338
with:
54-
platforms: ${{ matrix.platform }}
5539
push: false
40+
load: ${{ env.LOCAL_KIND == 'true' }}
41+
no-cache: ${{ env.LOCAL_KIND == 'true' }}
42+
platforms: ${{ env.LOCAL_KIND == 'true' && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
43+
tags: ${{ steps.meta.outputs.tags }}
5644
labels: ${{ steps.meta.outputs.labels }}
45+
build-args: |
46+
CACHEBUST=${{ github.sha }}
47+
COMMIT_HASH=${{ github.sha }}
48+
cache-from: ${{ env.LOCAL_KIND == 'true' && '' || 'type=gha' }}
49+
cache-to: ${{ env.LOCAL_KIND == 'true' && '' || 'type=gha,mode=max' }}
5750

5851
test:
5952
runs-on: ubuntu-latest

.github/workflows/release-tag.yaml

Lines changed: 22 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,20 @@ on:
66

77
env:
88
GHCR_REPO: ghcr.io/${{ github.repository }}
9+
DOCKER_PUSH: true
10+
LOCAL_KIND: false
911

1012
jobs:
11-
build:
12-
name: Build and Push
13-
strategy:
14-
fail-fast: false
15-
matrix:
16-
runner: [buildjet-2vcpu-ubuntu-2204-arm, buildjet-2vcpu-ubuntu-2204]
17-
include:
18-
- runner: buildjet-2vcpu-ubuntu-2204-arm
19-
platform: linux/arm64
20-
- runner: buildjet-2vcpu-ubuntu-2204
21-
platform: linux/amd64
22-
runs-on: ${{ matrix.runner }}
23-
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
2416
permissions:
2517
contents: read
2618
packages: write
2719

2820
steps:
29-
- name: Prepare
30-
run: |
31-
platform=${{ matrix.platform }}
32-
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
21+
- name: Checkout
22+
uses: actions/checkout@v4
3323

3424
- name: Docker meta
3525
id: meta
@@ -38,78 +28,33 @@ jobs:
3828
images: ${{ env.GHCR_REPO }}
3929

4030
- name: Login to GHCR
31+
if: env.DOCKER_PUSH == 'true'
4132
uses: docker/login-action@v3
4233
with:
4334
registry: ghcr.io
4435
username: ${{ github.repository_owner }}
4536
password: ${{ secrets.GITHUB_TOKEN }}
4637

38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@v3
40+
4741
- name: Set up Docker Buildx
4842
uses: docker/setup-buildx-action@v3
4943

50-
- name: Build and push by digest
51-
id: build
44+
- name: Build and push
5245
uses: docker/build-push-action@v5
5346
with:
54-
platforms: ${{ matrix.platform }}
55-
push: true
47+
push: ${{ env.DOCKER_PUSH == 'true' }}
48+
load: ${{ env.LOCAL_KIND == 'true' }}
49+
no-cache: ${{ env.LOCAL_KIND == 'true' }}
50+
platforms: ${{ env.LOCAL_KIND == 'true' && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
51+
tags: ${{ steps.meta.outputs.tags }}
5652
labels: ${{ steps.meta.outputs.labels }}
57-
outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
58-
59-
- name: Export digest
60-
run: |
61-
mkdir -p /tmp/digests
62-
digest="${{ steps.build.outputs.digest }}"
63-
touch "/tmp/digests/${digest#sha256:}"
64-
65-
- name: Upload digest
66-
uses: actions/upload-artifact@v4
67-
with:
68-
name: digests-${{ env.PLATFORM_PAIR }}
69-
path: /tmp/digests/*
70-
if-no-files-found: error
71-
retention-days: 1
72-
73-
merge:
74-
runs-on: ubuntu-latest
75-
needs:
76-
- build
77-
permissions:
78-
contents: read
79-
packages: write
80-
steps:
81-
- name: Download digests
82-
uses: actions/download-artifact@v4
83-
with:
84-
path: /tmp/digests
85-
pattern: digests-*
86-
merge-multiple: true
87-
88-
- name: Login to GHCR
89-
uses: docker/login-action@v3
90-
with:
91-
registry: ghcr.io
92-
username: ${{ github.repository_owner }}
93-
password: ${{ secrets.GITHUB_TOKEN }}
94-
95-
- name: Set up Docker Buildx
96-
uses: docker/setup-buildx-action@v3
97-
98-
- name: Docker meta
99-
id: meta
100-
uses: docker/metadata-action@v5
101-
with:
102-
images: ${{ env.GHCR_REPO }}
103-
104-
- name: Create manifest list and push
105-
working-directory: /tmp/digests
106-
run: |
107-
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
108-
$(printf '${{ env.GHCR_REPO }}@sha256:%s ' *)
109-
110-
- name: Inspect image
111-
run: |
112-
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}
53+
build-args: |
54+
CACHEBUST=${{ github.sha }}
55+
COMMIT_HASH=${{ github.sha }}
56+
cache-from: ${{ env.LOCAL_KIND == 'true' && '' || 'type=gha' }}
57+
cache-to: ${{ env.LOCAL_KIND == 'true' && '' || 'type=gha,mode=max' }}
11358

11459
test:
11560
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)