Skip to content

Commit ca612b3

Browse files
committed
perf: use native ARM runners for publish instead of QEMU
Split publish into build + merge jobs: - build: matrix of PG version × runner (ubuntu-latest, ubuntu-24.04-arm), each pushes a single-platform image by digest - merge: downloads digests per PG version and creates multi-arch manifests Eliminates QEMU emulation overhead for ARM builds.
1 parent b3d35b8 commit ca612b3

1 file changed

Lines changed: 78 additions & 24 deletions

File tree

.github/workflows/publish.yml

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,74 @@ on:
77

88
env:
99
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository_owner }}/${{ github.event.repository.name }}
1011

1112
jobs:
12-
build-and-push:
13+
build:
14+
runs-on: ${{ matrix.runner }}
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
strategy:
20+
matrix:
21+
runner: [ubuntu-latest, ubuntu-24.04-arm]
22+
pg_version: ["17.9", "16.13", "15.17", "14.22"]
23+
postgis_version: ["3.6.2"]
24+
pgvector_version: ["0.8.2"]
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v6
29+
30+
- name: Log in to GitHub Container Registry
31+
uses: docker/login-action@v4
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v4
39+
40+
- name: Extract metadata (tags, labels) for Docker
41+
id: meta
42+
uses: docker/metadata-action@v6
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
46+
- name: Build and push by digest
47+
id: build
48+
uses: docker/build-push-action@v7
49+
with:
50+
context: .
51+
push: true
52+
labels: ${{ steps.meta.outputs.labels }}
53+
build-args: |
54+
PG_VERSION=${{ matrix.pg_version }}
55+
POSTGIS_VERSION=${{ matrix.postgis_version }}
56+
PGVECTOR_VERSION=${{ matrix.pgvector_version }}
57+
cache-from: type=gha,scope=${{ matrix.pg_version }}-${{ matrix.runner }}
58+
cache-to: type=gha,mode=max,scope=${{ matrix.pg_version }}-${{ matrix.runner }}
59+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
60+
61+
- name: Export digest
62+
run: |
63+
mkdir -p /tmp/digests
64+
digest="${{ steps.build.outputs.digest }}"
65+
touch "/tmp/digests/${digest#sha256:}"
66+
67+
- name: Upload digest
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: digest-${{ matrix.pg_version }}-${{ matrix.runner }}
71+
path: /tmp/digests/*
72+
if-no-files-found: error
73+
retention-days: 1
74+
75+
merge:
1376
runs-on: ubuntu-latest
77+
needs: build
1478
permissions:
1579
contents: read
1680
packages: write
@@ -36,8 +100,12 @@ jobs:
36100
latest: false
37101

38102
steps:
39-
- name: Checkout repository
40-
uses: actions/checkout@v6
103+
- name: Download digests
104+
uses: actions/download-artifact@v4
105+
with:
106+
pattern: digest-${{ matrix.pg_version }}-*
107+
merge-multiple: true
108+
path: /tmp/digests
41109

42110
- name: Log in to GitHub Container Registry
43111
uses: docker/login-action@v4
@@ -46,33 +114,19 @@ jobs:
46114
username: ${{ github.actor }}
47115
password: ${{ secrets.GITHUB_TOKEN }}
48116

49-
- name: Set up QEMU
50-
uses: docker/setup-qemu-action@v4
51-
52-
- name: Set up Docker Buildx
53-
uses: docker/setup-buildx-action@v4
54-
55117
- name: Extract metadata (tags, labels) for Docker
56118
id: meta
57119
uses: docker/metadata-action@v6
58120
with:
59-
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ github.event.repository.name }}
121+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60122
tags: |
61123
type=raw,value=postgres-${{ matrix.pg_version }}-postgis-${{ matrix.postgis_version }}-pgvector-${{ matrix.pgvector_version }}
62124
type=raw,value=latest,enable=${{ matrix.latest }}
63125
type=ref,event=tag,enable=${{ matrix.latest }}
64126
65-
- name: Build and push Docker image
66-
uses: docker/build-push-action@v7
67-
with:
68-
context: .
69-
push: true
70-
platforms: linux/amd64,linux/arm64
71-
tags: ${{ steps.meta.outputs.tags }}
72-
labels: ${{ steps.meta.outputs.labels }}
73-
build-args: |
74-
PG_VERSION=${{ matrix.pg_version }}
75-
POSTGIS_VERSION=${{ matrix.postgis_version }}
76-
PGVECTOR_VERSION=${{ matrix.pgvector_version }}
77-
cache-from: type=gha
78-
cache-to: type=gha,mode=max
127+
- name: Create multi-arch manifest and push
128+
working-directory: /tmp/digests
129+
run: |
130+
docker buildx imagetools create \
131+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
132+
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)

0 commit comments

Comments
 (0)