1
+ name : Build Bowtie Image for all available versions
2
+
3
+ on :
4
+ workflow_dispatch :
5
+
6
+ env :
7
+ IMAGE_REGISTRY : ghcr.io/${{ github.repository_owner }}
8
+
9
+ jobs :
10
+ versions :
11
+ runs-on : ubuntu-latest
12
+ permissions :
13
+ contents : read
14
+ outputs :
15
+ revisions : ${{ steps.revisions.outputs.value }}
16
+ steps :
17
+ - name : Collect available versions
18
+ id : revisions
19
+ run : |
20
+ tags=$(gh api \
21
+ -H "Accept: application/vnd.github+json" \
22
+ -H "X-GitHub-Api-Version: 2022-11-28" \
23
+ /repos/${{ github.repository }}/releases | jq -c '. | map(.tag_name) + ["main"]')
24
+ echo "value=$(echo $tags | jq -c .)" >> $GITHUB_OUTPUT
25
+
26
+ build :
27
+ needs : versions
28
+ runs-on : ubuntu-latest
29
+ strategy :
30
+ fail-fast : true
31
+ matrix :
32
+ revision : ${{ fromJson(needs.versions.outputs.revisions) }}
33
+ permissions :
34
+ id-token : write
35
+ contents : read
36
+ attestations : write
37
+ packages : write
38
+ steps :
39
+ - uses : actions/checkout@v4
40
+ with :
41
+ ref : ${{ matrix.revision }}
42
+
43
+ - name : Install uv
44
+ uses : astral-sh/setup-uv@v5
45
+ with :
46
+ enable-cache : true
47
+
48
+ - name : Compute implementation name
49
+ id : impl
50
+ run : echo "name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT
51
+
52
+ - name : Install qemu
53
+ run : |
54
+ sudo apt-get update
55
+ sudo apt-get install -y qemu-user-static
56
+
57
+ - name : Build
58
+ id : build_image
59
+ uses : redhat-actions/buildah-build@v2
60
+ with :
61
+ context : ' .'
62
+ containerfiles : |
63
+ Dockerfile
64
+ image : ${{ steps.impl.outputs.name }}
65
+ tags : ${{ github.sha }} ${{ matrix.revision == 'main' && 'latest' || '' }}
66
+ archs : amd64, arm64
67
+
68
+ - name : Set DOCKER_HOST so podman-built images are findable
69
+ run : |
70
+ systemctl --user enable --now podman.socket
71
+ sudo loginctl enable-linger $USER
72
+ podman --remote info
73
+ echo "DOCKER_HOST=unix://$(podman info --format '{{.Host.RemoteSocket.Path}}')" >> $GITHUB_ENV
74
+
75
+ - name : Smoke Test
76
+ run : |
77
+ uvx --from 'bowtie-json-schema' --python 3.13 bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format json
78
+ uvx --from 'bowtie-json-schema' --python 3.13 bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format markdown >> $GITHUB_STEP_SUMMARY
79
+
80
+ - name : Collect current version
81
+ id : current-version
82
+ run : |
83
+ version=$(uvx --from 'bowtie-json-schema' --python 3.13 bowtie info \
84
+ --implementation "localhost/${{ steps.build_image.outputs.image-with-tag }}" \
85
+ --format json | jq -r '.version // empty')
86
+ echo "value=${version}" >> $GITHUB_OUTPUT
87
+
88
+ - name : Print collected version
89
+ run : echo "current_version=${{ steps.current-version.outputs.value }}"
90
+
91
+ - name : Log in to ghcr.io
92
+ uses : redhat-actions/podman-login@v1
93
+ with :
94
+ username : ${{ github.actor }}
95
+ password : ${{ github.token }}
96
+ registry : ${{ env.IMAGE_REGISTRY }}
97
+
98
+ - name : Add tag with version to the image
99
+ run : podman tag ${{ steps.build_image.outputs.image-with-tag }} ${{ steps.build_image.outputs.image }}:${{ steps.current-version.outputs.value }}
100
+
101
+ - name : Publish
102
+ id : push
103
+ uses : redhat-actions/push-to-registry@v2
104
+ with :
105
+ image : ${{ steps.build_image.outputs.image }}
106
+ tags : ${{ steps.current-version.outputs.value }} ${{ steps.build_image.outputs.tags }}
107
+ registry : ${{ env.IMAGE_REGISTRY }}
108
+
109
+ - name : Generate attestation for images
110
+ uses : actions/attest-build-provenance@v2
111
+ with :
112
+ subject-name : ${{ env.IMAGE_REGISTRY }}/${{ steps.build_image.outputs.image }}
113
+ subject-digest : ${{ steps.push.outputs.digest }}
114
+ push-to-registry : true
0 commit comments