1
+ name : Rebuild Bowtie Image
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ inputs :
6
+ version :
7
+ description : >
8
+ A specific version of the implementation you want to build.
9
+
10
+ If the implementation has historical version support (i.e. a `matrix-versions.json` file)
11
+ and your specified version is included in that file then only that version of the implementation
12
+ will be built and if you don't specify any version over here then all of its versions from that
13
+ file will be built.
14
+
15
+ If no file is found then just the latest version of the implementation will be built.
16
+ required : false
17
+ type : string
18
+ pull_request :
19
+ push :
20
+ branches-ignore :
21
+ - " wip*"
22
+
23
+ env :
24
+ IMAGE_REGISTRY : ghcr.io/${{ github.repository_owner }}
25
+
26
+ concurrency :
27
+ group : images-${{ github.ref }}
28
+ cancel-in-progress : true
29
+
30
+ jobs :
31
+ list :
32
+ runs-on : ubuntu-latest
33
+ outputs :
34
+ images : ${{ steps.images-matrix.outputs.images }}
35
+ steps :
36
+ - uses : actions/checkout@v4
37
+
38
+ - name : Install uv
39
+ uses : astral-sh/setup-uv@v5
40
+ with :
41
+ enable-cache : true
42
+
43
+ - name : Calculate which impages to build
44
+ id : images-matrix
45
+ run : |
46
+ version=${{ inputs.version }}
47
+ matrix_versions_file="matrix-versions.json"
48
+ MATRIX="[]"
49
+ if [ -f "$matrix_versions_file" ]; then
50
+ versions=$(cat "$matrix_versions_file" | jq -c)
51
+ if [ -n "$version" ]; then
52
+ if echo "$versions" | jq -e --arg version "$version" 'index($version) != null' > /dev/null; then
53
+ MATRIX="[{"version": $version}]"
54
+ else
55
+ echo "No such version ('$version') found in the \`matrix-versions.json\` file of $implementation. Please provide a correct version."
56
+ exit 1
57
+ fi
58
+ else
59
+ MATRIX=$(jq --argjson vers "$versions" '["version": $vers[]}]'
60
+ fi
61
+ else
62
+ MATRIX="[{"version": "latest"}]"
63
+ fi
64
+ echo "images=$(echo $MATRIX | jq -c .)" >> $GITHUB_OUTPUT
65
+
66
+ build :
67
+ needs : list
68
+
69
+ # Particularly for .NET (which we special case below),
70
+ # we need a newer buildah than what's in 22.04 (which is buildah 1.23.1)
71
+ # so that it properly sets TARGETARCH and therefore multi-architecture
72
+ # container image builds know which architecture we're building for.
73
+ # See https://github.com/containers/buildah/pull/4295.
74
+ runs-on : ubuntu-24.04
75
+
76
+ permissions :
77
+ id-token : write
78
+ contents : read
79
+ attestations : write
80
+ packages : write
81
+
82
+ strategy :
83
+ fail-fast : false
84
+ matrix :
85
+ include : ${{ fromJson(needs.list.outputs.images) }}
86
+
87
+ steps :
88
+ - uses : actions/checkout@v4
89
+
90
+ - run : echo "name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT
91
+ id : impl
92
+
93
+ - name : Install qemu
94
+ run : |
95
+ sudo apt-get update
96
+ sudo apt-get install -y qemu-user-static
97
+ if : (!startsWith(steps.impl.outputs.name, 'dotnet-'))
98
+ # See https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/ for why not .NET
99
+
100
+ - name : Build
101
+ id : build_image
102
+ uses : redhat-actions/buildah-build@v2
103
+ with :
104
+ context : ' .'
105
+ containerfiles : |
106
+ Dockerfile
107
+ image : ${{ steps.impl.outputs.name }}
108
+ tags : ${{ matrix.version }} ${{ github.sha }}
109
+ archs : amd64, arm64
110
+ build-args : |
111
+ ${{ matrix.version && format('IMPLEMENTATION_VERSION={0}', matrix.version) || '' }}
112
+
113
+ - name : Set DOCKER_HOST so podman-built images are findable
114
+ run : |
115
+ systemctl --user enable --now podman.socket
116
+ sudo loginctl enable-linger $USER
117
+ podman --remote info
118
+ echo "DOCKER_HOST=unix://$(podman info --format '{{.Host.RemoteSocket.Path}}')" >> $GITHUB_ENV
119
+
120
+ - name : Install uv
121
+ uses : astral-sh/setup-uv@v5
122
+ with :
123
+ enable-cache : true
124
+
125
+ - name : Smoke Test
126
+ run : |
127
+ uvx --from . --python 3.13 bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format json
128
+ uvx --from . --python 3.13 bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format markdown >> $GITHUB_STEP_SUMMARY
129
+
130
+ - name : Log in to ghcr.io
131
+ uses : redhat-actions/podman-login@v1
132
+ with :
133
+ username : ${{ github.actor }}
134
+ password : ${{ github.token }}
135
+ registry : ${{ env.IMAGE_REGISTRY }}
136
+ if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
137
+
138
+ - name : Publish
139
+ id : push
140
+ uses : redhat-actions/push-to-registry@v2
141
+ with :
142
+ image : ${{ steps.build_image.outputs.image }}
143
+ tags : ${{ steps.build_image.outputs.tags }}
144
+ registry : ${{ env.IMAGE_REGISTRY }}
145
+ if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
146
+
147
+ - name : Generate attestation for images
148
+ uses : actions/attest-build-provenance@v2
149
+ with :
150
+ subject-name : ${{ env.IMAGE_REGISTRY }}/${{ steps.build_image.outputs.image }}
151
+ subject-digest : ${{ steps.push.outputs.digest }}
152
+ push-to-registry : true
153
+ if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
0 commit comments