Skip to content

Commit 34bf885

Browse files
author
David Zuckerman
committed
build and release fix
1 parent 0744f88 commit 34bf885

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

.github/workflows/build.yml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ jobs:
1515
build:
1616
runs-on: ${{ matrix.runner }}
1717
outputs:
18-
image-arm64: ${{ steps.gen-output.outputs.image-arm64 }}
19-
image-x64: ${{ steps.gen-output.outputs.image-x64 }}
18+
build-image-arm: ${{ steps.gen-output.outputs.image-arm64 }}
19+
build-image-x64: ${{ steps.gen-output.outputs.image-x64 }}
2020
strategy:
2121
fail-fast: false
2222
matrix:
2323
include:
2424
- platform: linux/amd64
25+
runner: ubuntu-24.04
26+
- platform: linux/arm64
2527
runner: ubuntu-24.04-arm
26-
- platform: linux/arm64
27-
runner: ubuntu-24.04-arm
2828
steps:
2929
- name: Checkout code
3030
uses: actions/checkout@v4
@@ -40,15 +40,15 @@ jobs:
4040
password: ${{ secrets.GITHUB_TOKEN }}
4141

4242
- id: build-meta
43-
name: Docker meta
43+
name: Produce the build image tag
4444
uses: docker/metadata-action@v5
4545
with:
4646
images: ghcr.io/${{ github.repository }}
4747
tags: type=sha,suffix=${{ env.BUILD_SUFFIX }}
4848

4949
# Build cache is shared among all builds of the same architecture
5050
- id: cache-meta
51-
name: Docker meta
51+
name: Fetch build cache metadata
5252
uses: docker/metadata-action@v5
5353
with:
5454
images: ghcr.io/${{ github.repository }}
@@ -59,11 +59,22 @@ jobs:
5959
run: |
6060
echo "registry=$(echo '${{ steps.build-meta.outputs.tags }}' | cut -f1 -d:)" | tee -a "$GITHUB_OUTPUT"
6161
62+
- id: set_build_url
63+
name: Set BUILD_URL
64+
run: |
65+
echo "build_url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | tee -a "$GITHUB_OUTPUT"
66+
6267
- id: build
6368
name: Build/push the arch-specific image
6469
uses: docker/build-push-action@v6
6570
with:
6671
platforms: ${{ matrix.platform }}
72+
build-args: |
73+
BUILD_TIMESTAMP=${{ github.event.repository.updated_at }}
74+
BUILD_URL=${{ steps.set_build_url.outputs.build_url }}
75+
GIT_REF_NAME=${{ github.ref_name }}
76+
GIT_SHA=${{ github.sha }}
77+
GIT_REPOSITORY_URL=${{ github.repositoryUrl }}
6778
cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
6879
cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
6980
labels: ${{ steps.build-meta.outputs.labels }}
@@ -78,11 +89,12 @@ jobs:
7889
echo "image-${RUNNER_ARCH,,}=${{ steps.get-registry.outputs.registry }}@${{ steps.build.outputs.digest }}" | tee -a "$GITHUB_OUTPUT"
7990
8091
merge:
81-
runs-on: ubuntu-24.04
82-
needs: build
92+
runs-on: ubuntu-latest
93+
needs:
94+
- build
8395
env:
84-
DOCKER_APP_IMAGE_ARM64: ${{ needs.build.outputs.image-arm64 }}
85-
DOCKER_APP_IMAGE_X64: ${{ needs.build.outputs.image-x64 }}
96+
DOCKER_APP_IMAGE_ARM64: ${{ needs.build.outputs.build-image-arm }}
97+
DOCKER_APP_IMAGE_X64: ${{ needs.build.outputs.build-image-x64 }}
8698
outputs:
8799
build-image: ${{ steps.meta.outputs.tags }}
88100
build-image-arm: ${{ needs.build.outputs.build-image-arm }}
@@ -101,14 +113,15 @@ jobs:
101113
username: ${{ github.actor }}
102114
password: ${{ secrets.GITHUB_TOKEN }}
103115

104-
- id: meta
105-
name: Generate tag for the app image
116+
- name: Docker meta
117+
id: meta
106118
uses: docker/metadata-action@v5
107119
with:
108120
images: ghcr.io/${{ github.repository }}
109-
tags: type=sha,suffix=${{ env.BUILD_SUFFIX }}
121+
tags: |
122+
type=sha,suffix=-build-${{ github.run_id }}_${{ github.run_attempt }}
110123
111-
- name: Push the multi-platform app image
124+
- name: Push the multi-platform image
112125
run: |
113126
docker buildx imagetools create \
114127
--tag "$DOCKER_METADATA_OUTPUT_TAGS" \
@@ -174,6 +187,8 @@ jobs:
174187
- test
175188
env:
176189
DOCKER_APP_IMAGE: ${{ needs.merge.outputs.build-image }}
190+
DOCKER_APP_IMAGE_ARM64: ${{ needs.merge.outputs.build-image-arm }}
191+
DOCKER_APP_IMAGE_X64: ${{ needs.merge.outputs.build-image-x64 }}
177192
steps:
178193
- name: Checkout code
179194
uses: actions/checkout@v4
@@ -189,6 +204,7 @@ jobs:
189204
password: ${{ secrets.GITHUB_TOKEN }}
190205

191206
- name: Produce permanent image tags
207+
id: branch-meta
192208
uses: docker/metadata-action@v5
193209
with:
194210
images: ghcr.io/${{ github.repository }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
env:
3939
BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }}
4040
run: |
41-
docker pull "$BASE_IMAGE"
41+
docker manifest inspect "$BASE_IMAGE"
4242
4343
- name: Produce release tags
4444
id: tag-meta

0 commit comments

Comments
 (0)