@@ -2,19 +2,6 @@ name: Rebuild Bowtie Image
2
2
3
3
on :
4
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
5
pull_request :
19
6
push :
20
7
branches-ignore :
@@ -28,10 +15,11 @@ concurrency:
28
15
cancel-in-progress : true
29
16
30
17
jobs :
31
- list :
18
+ meta :
32
19
runs-on : ubuntu-latest
33
20
outputs :
34
- images : ${{ steps.images-matrix.outputs.images }}
21
+ latest-version : ${{ steps.version.outputs.value }}
22
+ implementation-name : ${{ steps.impl.outputs.name }}
35
23
steps :
36
24
- uses : actions/checkout@v4
37
25
@@ -40,56 +28,35 @@ jobs:
40
28
with :
41
29
enable-cache : true
42
30
43
- - name : Calculate which impages to build
44
- id : images-matrix
31
+ - name : Compute implementation name
32
+ id : impl
33
+ run : echo "name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT
34
+
35
+ - name : Compute latest implementation version
36
+ id : version
45
37
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
38
+ version=$(uvx --from 'bowtie-json-schema' --python 3.13 bowtie info \
39
+ --implementation ${{ steps.impl.outputs.name }} \
40
+ --format json | jq '.version // empty')
41
+ echo "value=${version}" >> $GITHUB_OUTPUT
65
42
66
43
build :
67
- needs : list
44
+ needs : meta
68
45
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
46
+ runs-on : ubuntu-latest
47
+
48
+ outputs :
49
+ current-version : ${{ steps.current-version.outputs.value }}
75
50
76
51
permissions :
77
52
id-token : write
78
53
contents : read
79
54
attestations : write
80
55
packages : write
81
56
82
- strategy :
83
- fail-fast : false
84
- matrix :
85
- include : ${{ fromJson(needs.list.outputs.images) }}
86
-
87
57
steps :
88
58
- uses : actions/checkout@v4
89
59
90
- - run : echo "name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT
91
- id : impl
92
-
93
60
- name : Install qemu
94
61
run : |
95
62
sudo apt-get update
@@ -102,11 +69,9 @@ jobs:
102
69
context : ' .'
103
70
containerfiles : |
104
71
Dockerfile
105
- image : ${{ steps.impl .outputs.name }}
106
- tags : ${{ matrix.version }} ${{ github.sha }}
72
+ image : ${{ needs.meta .outputs.implementation- name }}
73
+ tags : ${{ github.sha }}
107
74
archs : amd64, arm64
108
- build-args : |
109
- ${{ format('IMPLEMENTATION_VERSION={0}', matrix.version) }}
110
75
111
76
- name : Set DOCKER_HOST so podman-built images are findable
112
77
run : |
@@ -125,6 +90,14 @@ jobs:
125
90
uvx --from 'bowtie-json-schema' --python 3.13 bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format json
126
91
uvx --from 'bowtie-json-schema' --python 3.13 bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format markdown >> $GITHUB_STEP_SUMMARY
127
92
93
+ - name : Collect current version
94
+ id : current-version
95
+ run : |
96
+ version=$(uvx --from 'bowtie-json-schema' --python 3.13 bowtie info \
97
+ --implementation "localhost/${{ steps.build_image.outputs.image-with-tag }}" \
98
+ --format json | jq '.version // empty')
99
+ echo "value=${version}" >> $GITHUB_OUTPUT
100
+
128
101
- name : Log in to ghcr.io
129
102
uses : redhat-actions/podman-login@v1
130
103
with :
@@ -138,7 +111,7 @@ jobs:
138
111
uses : redhat-actions/push-to-registry@v2
139
112
with :
140
113
image : ${{ steps.build_image.outputs.image }}
141
- tags : ${{ steps.build_image .outputs.tags }}
114
+ tags : ${{ steps.current-version .outputs.value }} ${{ github.sha }} ${{ github.ref == 'refs/heads/main' && 'latest' || '' }}
142
115
registry : ${{ env.IMAGE_REGISTRY }}
143
116
if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
144
117
@@ -150,11 +123,29 @@ jobs:
150
123
push-to-registry : true
151
124
if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
152
125
126
+ version-changed :
127
+ needs : [build, meta]
128
+ runs-on : ubuntu-latest
129
+
130
+ if : github.event_name == 'pull_request' && needs.build.outputs.current-version != needs.meta.outputs.latest-version
131
+
132
+ permissions :
133
+ contents : write
134
+
135
+ steps :
136
+ - name : Checkout current head
137
+ uses : actions/checkout@v4
138
+ with :
139
+ ref : ${{ github.event.pull_request.base.ref }}
140
+
141
+ - name : Mark the current head with the latest version before the update
142
+ run : git tag v${{ needs.build.outputs.current-version }} && git push origin v${{ needs.build.outputs.current-version }}
143
+
153
144
automerge :
154
- needs : build
145
+ needs : [ build, version-changed]
155
146
runs-on : ubuntu-latest
156
147
157
- if : github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
148
+ if : (!cancelled() && github.event_name == 'pull_request' && github.actor == 'dependabot[bot]')
158
149
159
150
permissions :
160
151
contents : write
0 commit comments