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+ - arch : arm64
43+ platform : linux/arm64
44+ cache-ref : buildcache-arm64
45+ needs-qemu : true
46+ steps :
47+ - name : Check out the repo
48+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
49+
50+ - name : Log in to GitHub Container Registry
51+ uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
52+ with :
53+ registry : ghcr.io
54+ username : ${{ github.actor }}
55+ password : ${{ secrets.GITHUB_TOKEN }}
56+
57+ - name : Set up QEMU
58+ if : matrix.needs-qemu
59+ uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
60+ with :
61+ platforms : ${{ matrix.arch }}
62+
63+ - name : Build Docker image (${{ matrix.arch }})
64+ uses : ./.github/actions/docker-build
65+ with :
66+ push : false
67+ load : true
68+ platforms : ${{ matrix.platform }}
69+ dockerfile : ./Dockerfile
70+ context : .
71+ image-name : elementsinteractive/twyn
72+ cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:${{ matrix.cache-ref }}
73+ cache-to : type=registry,ref=ghcr.io/elementsinteractive/twyn:${{ matrix.cache-ref }},mode=max,compression=zstd,force-compression=true,oci-mediatypes=true
74+
75+ - name : Test Docker image (${{ matrix.arch }})
76+ run : |
77+ docker run --platform ${{ matrix.platform }} --rm elementsinteractive/twyn --version
78+
79+ publish_docker_images :
80+ name : Push Docker images to registries
81+ runs-on : ubuntu-latest
82+ needs : [build_and_test_docker]
3383 permissions :
3484 contents : read
3585 packages : write
@@ -50,16 +100,15 @@ jobs:
50100 username : ${{ github.actor }}
51101 password : ${{ secrets.GITHUB_TOKEN }}
52102
53- - name : Build and push Docker image
103+ - name : Push Docker images
54104 uses : ./.github/actions/docker-build
55105 with :
56- push-image : " true"
106+ push : " true"
57107 platforms : linux/amd64,linux/arm64
58108 dockerfile : ./Dockerfile
59109 context : .
60110 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
111+ cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64
63112
64113 - name : Delete old cache entries
65114 env :
@@ -68,17 +117,18 @@ jobs:
68117 # Get all versions of the container package
69118 versions=$(gh api "orgs/elementsinteractive/packages/container/twyn/versions" --paginate)
70119
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')
120+ # Extract version IDs that do NOT have any buildcache-* tags (buildcache-amd64, buildcache-arm64, etc.)
121+ ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | map(test("^ buildcache-")) | any | not) | .id')
73122
74123 # Delete them
75124 for id in $ids_to_delete; do
76125 echo "Deleting old cache version ID: $id"
77126 gh api -X DELETE "orgs/elementsinteractive/packages/container/twyn/versions/$id"
78127 done
128+
79129 release_notes :
80130 runs-on : ubuntu-latest
81- needs : [push_to_pypi, push_to_docker_hub ]
131+ needs : [push_to_pypi, publish_docker_images ]
82132 steps :
83133 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
84134 - name : Release
0 commit comments