2727 uv build
2828 uv publish
2929
30- push_to_docker_hub :
31- name : Push Docker image to Docker Hub
30+ build_and_test_docker :
31+ name : Build and test Docker image (${{ matrix.arch }})
3232 runs-on : ubuntu-latest
33+ permissions :
34+ contents : read
35+ packages : write
36+ strategy :
37+ matrix :
38+ include :
39+ - arch : AMD64
40+ platform : linux/amd64
41+ cache-ref : buildcache-amd64
42+ test-image : elementsinteractive/twyn:test-amd64
43+ - arch : ARM64
44+ platform : linux/arm64
45+ cache-ref : buildcache-arm64
46+ test-image : elementsinteractive/twyn:test-arm64
47+ needs-qemu : true
48+ steps :
49+ - name : Check out the repo
50+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
51+
52+ - name : Log in to GitHub Container Registry
53+ uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
54+ with :
55+ registry : ghcr.io
56+ username : ${{ github.actor }}
57+ password : ${{ secrets.GITHUB_TOKEN }}
58+
59+ - name : Set up QEMU
60+ if : matrix.needs-qemu
61+ uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
62+ with :
63+ platforms : arm64
64+
65+ - name : Build Docker image (${{ matrix.arch }})
66+ uses : ./.github/actions/docker-build
67+ with :
68+ push : " false"
69+ platforms : ${{ matrix.platform }}
70+ dockerfile : ./Dockerfile
71+ context : .
72+ image-name : elementsinteractive/twyn
73+ cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:${{ matrix.cache-ref }}
74+ cache-to : type=registry,ref=ghcr.io/elementsinteractive/twyn:${{ matrix.cache-ref }},mode=max,compression=zstd,force-compression=true,oci-mediatypes=true
75+
76+ - name : Test Docker image (${{ matrix.arch }})
77+ run : |
78+ docker run --platform ${{ matrix.platform }} --rm ${{ matrix.test-image }} --version
79+
80+ publish_docker_images :
81+ name : Push Docker images to registries
82+ runs-on : ubuntu-latest
83+ needs : [build_and_test_docker]
3384 permissions :
3485 contents : read
3586 packages : write
@@ -50,16 +101,25 @@ jobs:
50101 username : ${{ github.actor }}
51102 password : ${{ secrets.GITHUB_TOKEN }}
52103
53- - name : Build and push Docker image
104+ - name : Push Docker image (AMD64)
105+ uses : ./.github/actions/docker-build
106+ with :
107+ push : " true"
108+ platforms : linux/amd64
109+ dockerfile : ./Dockerfile
110+ context : .
111+ image-name : elementsinteractive/twyn
112+ cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64
113+
114+ - name : Push Docker image (ARM64)
54115 uses : ./.github/actions/docker-build
55116 with :
56- push-image : " true"
57- platforms : linux/amd64,linux/ arm64
117+ push : " true"
118+ platforms : linux/arm64
58119 dockerfile : ./Dockerfile
59120 context : .
60121 image-name : elementsinteractive/twyn
61- cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache
62- cache-to : type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache,mode=max,compression=zstd,force-compression=true,oci-mediatypes=true
122+ cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64
63123
64124 - name : Delete old cache entries
65125 env :
@@ -68,17 +128,18 @@ jobs:
68128 # Get all versions of the container package
69129 versions=$(gh api "orgs/elementsinteractive/packages/container/twyn/versions" --paginate)
70130
71- # Extract version IDs that do NOT have the ' buildcache' tag
72- ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | index(" buildcache") | not) | .id')
131+ # Extract version IDs that do NOT have any buildcache-* tags (buildcache-amd64, buildcache-arm64, etc.)
132+ ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | map(test("^ buildcache-")) | any | not) | .id')
73133
74134 # Delete them
75135 for id in $ids_to_delete; do
76136 echo "Deleting old cache version ID: $id"
77137 gh api -X DELETE "orgs/elementsinteractive/packages/container/twyn/versions/$id"
78138 done
139+
79140 release_notes :
80141 runs-on : ubuntu-latest
81- needs : [push_to_pypi, push_to_docker_hub ]
142+ needs : [push_to_pypi, publish_docker_images ]
82143 steps :
83144 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
84145 - name : Release
0 commit comments