44 workflow_dispatch :
55 inputs :
66 postgresVersion :
7- description : ' Optional. Postgres version to publish against , i.e. 15.1.1.78'
8- required : false
7+ description : ' Postgres version to publish, i.e. 15.1.1.78'
8+ required : true
99
1010jobs :
11- prepare :
12- runs-on : ubuntu-latest
13- outputs :
14- matrix_config : ${{ steps.set-matrix.outputs.matrix_config }}
15- steps :
16- - uses : DeterminateSystems/nix-installer-action@main
17- - name : Checkout Repo
18- uses : actions/checkout@v3
19- - name : Generate build matrix
20- id : set-matrix
21- run : |
22- nix run nixpkgs#nushell -- -c 'let versions = (open ansible/vars.yml | get postgres_major)
23- let matrix = ($versions | each { |ver|
24- let version = ($ver | str trim)
25- let dockerfile = $"Dockerfile-($version)"
26- if ($dockerfile | path exists) {
27- {
28- version: $version,
29- dockerfile: $dockerfile
30- }
31- } else {
32- null
33- }
34- } | compact)
35-
36- let matrix_config = {
37- include: $matrix
38- }
39-
40- $"matrix_config=($matrix_config | to json -r)" | save --append $env.GITHUB_OUTPUT'
4111 build :
42- needs : prepare
43- strategy :
44- matrix : ${{ fromJson(needs.prepare.outputs.matrix_config) }}
4512 runs-on : ubuntu-latest
4613 outputs :
4714 build_args : ${{ steps.args.outputs.result }}
4815 steps :
4916 - uses : actions/checkout@v3
5017 - uses : DeterminateSystems/nix-installer-action@main
51- - name : Set PostgreSQL version environment variable
52- run : echo "POSTGRES_MAJOR_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
5318
5419 - id : args
5520 run : |
@@ -61,11 +26,11 @@ jobs:
6126 | str join "\n"
6227 | save --append $env.GITHUB_OUTPUT
6328 '
29+
6430 build_release_image :
65- needs : [prepare, build]
31+ needs : build
6632 strategy :
6733 matrix :
68- postgres : ${{ fromJson(needs.prepare.outputs.matrix_config).include }}
6934 arch : [amd64, arm64]
7035 runs-on : ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'arm-runner' }}
7136 timeout-minutes : 180
8348 - name : Get image tag
8449 id : image
8550 run : |
86- if [[ "${{ matrix.arch }}" == "arm64" ]]; then
87- pg_version=$(sudo nix run nixpkgs#nushell -- -c '
88- let version = "${{ matrix.postgres.version }}"
89- let release_key = if ($version | str contains "orioledb") {
90- $"postgresorioledb-17"
91- } else {
92- $"postgres($version)"
93- }
94- let base_version = (open ansible/vars.yml | get postgres_release | get $release_key | str trim)
95- let final_version = if "${{ inputs.postgresVersion }}" != "" {
96- "${{ inputs.postgresVersion }}"
97- } else {
98- $base_version
99- }
100- $final_version | str trim
101- ')
102- echo "pg_version=supabase/postgres:$pg_version" >> $GITHUB_OUTPUT
103- else
104- pg_version=$(nix run nixpkgs#nushell -- -c '
105- let version = "${{ matrix.postgres.version }}"
106- let release_key = if ($version | str contains "orioledb") {
107- $"postgresorioledb-17"
108- } else {
109- $"postgres($version)"
110- }
111- let base_version = (open ansible/vars.yml | get postgres_release | get $release_key | str trim)
112- let final_version = if "${{ inputs.postgresVersion }}" != "" {
113- "${{ inputs.postgresVersion }}"
114- } else {
115- $base_version
116- }
117- $final_version | str trim
118- ')
119- echo "pg_version=supabase/postgres:$pg_version" >> $GITHUB_OUTPUT
120- fi
51+ echo "pg_version=supabase/postgres:${{ inputs.postgresVersion }}" >> $GITHUB_OUTPUT
52+
12153 - id : build
12254 uses : docker/build-push-action@v5
12355 with :
@@ -129,12 +61,10 @@ jobs:
12961 platforms : linux/${{ matrix.arch }}
13062 cache-from : type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
13163 cache-to : type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
132- file : ${{ matrix.postgres.dockerfile }}
64+ file : Dockerfile-${{ matrix.arch }}
65+
13366 merge_manifest :
134- needs : [prepare, build, build_release_image]
135- strategy :
136- matrix :
137- include : ${{ fromJson(needs.prepare.outputs.matrix_config).include }}
67+ needs : build_release_image
13868 runs-on : ubuntu-latest
13969 steps :
14070 - uses : actions/checkout@v3
@@ -144,107 +74,16 @@ jobs:
14474 with :
14575 username : ${{ secrets.DOCKER_USERNAME }}
14676 password : ${{ secrets.DOCKER_PASSWORD }}
147- - name : Get image tag
148- id : get_version
149- run : |
150- nix run nixpkgs#nushell -- -c '
151- let version = "${{ matrix.version }}"
152- let release_key = if ($version | str contains "orioledb") {
153- $"postgresorioledb-17"
154- } else {
155- $"postgres($version)"
156- }
157- let pg_version = (open ansible/vars.yml | get postgres_release | get $release_key | str trim)
158- $"pg_version=supabase/postgres:($pg_version)" | save --append $env.GITHUB_OUTPUT
159- '
160- - name : Output version
161- id : output_version
162- run : |
163- echo "result=${{ steps.get_version.outputs.pg_version }}" >> $GITHUB_OUTPUT
164- - name : Collect versions
165- id : collect_versions
166- run : |
167- echo "${{ steps.output_version.outputs.result }}" >> results.txt # Append results
168- - name : Upload Results Artifact
169- uses : actions/upload-artifact@v4
170- with :
171- name : merge_results-${{ matrix.version }}
172- path : results.txt
173- if-no-files-found : warn
77+
17478 - name : Merge multi-arch manifests
17579 run : |
176- docker buildx imagetools create -t ${{ steps.get_version.outputs.pg_version }} \
177- ${{ steps.get_version.outputs.pg_version }}_amd64 \
178- ${{ steps.get_version.outputs.pg_version }}_arm64
179- combine_results :
180- needs : [prepare, merge_manifest]
181- runs-on : ubuntu-latest
182- steps :
183- - uses : actions/checkout@v3
184- - uses : DeterminateSystems/nix-installer-action@main
80+ docker buildx imagetools create -t supabase/postgres:${{ inputs.postgresVersion }} \
81+ supabase/postgres:${{ inputs.postgresVersion }}_amd64 \
82+ supabase/postgres:${{ inputs.postgresVersion }}_arm64
18583
186- - name : Debug Input from Prepare
187- run : |
188- echo "Raw matrix_config output:"
189- echo "${{ needs.prepare.outputs.matrix_config }}"
190- - name : Get Versions from Matrix Config
191- id : get_versions
192- run : |
193- nix run nixpkgs#nushell -- -c '
194- # Parse the matrix configuration directly
195- let matrix_config = (${{ toJson(needs.prepare.outputs.matrix_config) }} | from json)
196-
197- # Get versions directly from include array
198- let versions = ($matrix_config.include | get version)
199-
200- echo "Versions : $versions"
201-
202- # Convert the versions to a comma-separated string
203- let versions_str = ($versions | str join ",")
204- $"versions=$versions_str" | save --append $env.GITHUB_ENV
205- '
206- - name: Download Results Artifacts
207- uses: actions/download-artifact@v4
208- with:
209- pattern: merge_results-*
210- - name: Combine Results
211- id: combine
212- run: |
213- nix run nixpkgs#nushell -- -c '
214- # Get all results files and process them in one go
215- let files = (ls **/results.txt | get name)
216- echo $"Found files : ($files)"
217-
218- let matrix = {
219- include : (
220- $files
221- | each { |file| open $file } # Open each file
222- | each { |content| $content | lines } # Split into lines
223- | flatten # Flatten the nested lists
224- | where { |line| $line != "" } # Filter empty lines
225- | each { |line|
226- # Extract just the version part after the last colon
227- let version = ($line | parse "supabase/postgres:{version}" | get version.0)
228- {version: $version}
229- }
230- )
231- }
232-
233- let json_output = ($matrix | to json -r) # -r for raw output
234- echo $"Debug output : ($json_output)"
235-
236- $"matrix=($json_output)" | save --append $env.GITHUB_OUTPUT
237- '
238- - name: Debug Combined Results
239- run: |
240- echo "Combined Results: ' ${{ steps.combine.outputs.matrix }}'"
241- outputs :
242- matrix : ${{ steps.combine.outputs.matrix }}
24384 publish :
244- needs : combine_results
245- strategy :
246- matrix : ${{ fromJson(needs.combine_results.outputs.matrix) }}
247- uses : ./.github/workflows/mirror.yml
248- with :
249- version : ${{ inputs.postgresVersion != '' && inputs.postgresVersion || matrix.version }}
250- secrets : inherit
85+ needs : merge_manifest
86+ uses : ./.github/workflows/mirror.yml
87+ with :
88+ version : ${{ inputs.postgresVersion }}
89+ secrets : inherit
0 commit comments