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 : arm4
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 : ${{ matrix.arch }}
64+
65+ - name : Build Docker image (${{ matrix.arch }})
66+ uses : ./.github/actions/docker-build
67+ with :
68+ push : false
69+ load : true
70+ platforms : ${{ matrix.platform }}
71+ dockerfile : ./Dockerfile
72+ context : .
73+ image-name : elementsinteractive/twyn
74+ cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:${{ matrix.cache-ref }}
75+ cache-to : type=registry,ref=ghcr.io/elementsinteractive/twyn:${{ matrix.cache-ref }},mode=max,compression=zstd,force-compression=true,oci-mediatypes=true
76+
77+ - name : Test Docker image (${{ matrix.arch }})
78+ run : |
79+ docker run --platform ${{ matrix.platform }} --rm elementsinteractive/twyn --version
80+
81+ publish_docker_images :
82+ name : Push Docker images to registries
83+ runs-on : ubuntu-latest
84+ needs : [build_and_test_docker]
3385 permissions :
3486 contents : read
3587 packages : write
@@ -50,16 +102,15 @@ jobs:
50102 username : ${{ github.actor }}
51103 password : ${{ secrets.GITHUB_TOKEN }}
52104
53- - name : Build and push Docker image
105+ - name : Push Docker images
54106 uses : ./.github/actions/docker-build
55107 with :
56- push-image : " true"
108+ push : " true"
57109 platforms : linux/amd64,linux/arm64
58110 dockerfile : ./Dockerfile
59111 context : .
60112 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
113+ cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64
63114
64115 - name : Delete old cache entries
65116 env :
@@ -68,17 +119,18 @@ jobs:
68119 # Get all versions of the container package
69120 versions=$(gh api "orgs/elementsinteractive/packages/container/twyn/versions" --paginate)
70121
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')
122+ # Extract version IDs that do NOT have any buildcache-* tags (buildcache-amd64, buildcache-arm64, etc.)
123+ ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | map(test("^ buildcache-")) | any | not) | .id')
73124
74125 # Delete them
75126 for id in $ids_to_delete; do
76127 echo "Deleting old cache version ID: $id"
77128 gh api -X DELETE "orgs/elementsinteractive/packages/container/twyn/versions/$id"
78129 done
130+
79131 release_notes :
80132 runs-on : ubuntu-latest
81- needs : [push_to_pypi, push_to_docker_hub ]
133+ needs : [push_to_pypi, publish_docker_images ]
82134 steps :
83135 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
84136 - name : Release
0 commit comments