chore: store the results data in artifacts #75
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release all major versions on Dockerhub | |
on: | |
push: | |
branches: | |
- develop | |
- release/* | |
- sam/docker-oriole17 | |
paths: | |
- '**' | |
workflow_dispatch: | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix_config: ${{ steps.set-matrix.outputs.matrix_config }} | |
steps: | |
- uses: DeterminateSystems/nix-installer-action@main | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
- name: Generate build matrix | |
id: set-matrix | |
run: | | |
nix run nixpkgs#nushell -- -c 'let versions = (open ansible/vars.yml | get postgres_major) | |
let matrix = ($versions | each { |ver| | |
let version = ($ver | str trim) | |
let dockerfile = $"Dockerfile-($version)" | |
if ($dockerfile | path exists) { | |
{ | |
version: $version, | |
dockerfile: $dockerfile | |
} | |
} else { | |
null | |
} | |
} | compact) | |
let matrix_config = { | |
include: $matrix | |
} | |
$"matrix_config=($matrix_config | to json -r)" | save --append $env.GITHUB_OUTPUT' | |
build: | |
needs: prepare | |
strategy: | |
matrix: ${{ fromJson(needs.prepare.outputs.matrix_config) }} | |
runs-on: ubuntu-latest | |
outputs: | |
build_args: ${{ steps.args.outputs.result }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- name: Set PostgreSQL version environment variable | |
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.version }}" >> $GITHUB_ENV | |
- id: args | |
run: | | |
nix run nixpkgs#nushell -- -c ' | |
open ansible/vars.yml | |
| items { |key value| {name: $key, item: $value} } | |
| where { |it| ($it.item | describe) == "string" } | |
| each { |it| $"($it.name)=($it.item)" } | |
| str join "\n" | |
| save --append $env.GITHUB_OUTPUT | |
' | |
build_release_image: | |
needs: [prepare, build] | |
strategy: | |
matrix: | |
postgres: ${{ fromJson(needs.prepare.outputs.matrix_config).include }} | |
arch: [amd64, arm64] | |
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'arm-runner' }} | |
timeout-minutes: 180 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- run: docker context create builders | |
- uses: docker/setup-buildx-action@v3 | |
with: | |
endpoint: builders | |
- uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get image tag | |
id: image | |
run: | | |
if [[ "${{ matrix.arch }}" == "arm64" ]]; then | |
pg_version=$(sudo nix run nixpkgs#nushell -- -c ' | |
let version = "${{ matrix.postgres.version }}" | |
let release_key = if ($version | str contains "orioledb") { | |
$"postgresorioledb-17" | |
} else { | |
$"postgres($version)" | |
} | |
open ansible/vars.yml | get postgres_release | get $release_key | str trim | |
') | |
echo "pg_version=supabase/postgres:$pg_version" >> $GITHUB_OUTPUT | |
else | |
pg_version=$(nix run nixpkgs#nushell -- -c ' | |
let version = "${{ matrix.postgres.version }}" | |
let release_key = if ($version | str contains "orioledb") { | |
$"postgresorioledb-17" | |
} else { | |
$"postgres($version)" | |
} | |
open ansible/vars.yml | get postgres_release | get $release_key | str trim | |
') | |
echo "pg_version=supabase/postgres:$pg_version" >> $GITHUB_OUTPUT | |
fi | |
- id: build | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
build-args: | | |
${{ needs.build.outputs.build_args }} | |
target: production | |
tags: ${{ steps.image.outputs.pg_version }}_${{ matrix.arch }} | |
platforms: linux/${{ matrix.arch }} | |
cache-from: type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }} | |
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }} | |
file: ${{ matrix.postgres.dockerfile }} | |
merge_manifest: | |
needs: [prepare, build, build_release_image] | |
strategy: | |
matrix: | |
include: ${{ fromJson(needs.prepare.outputs.matrix_config).include }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get image tag | |
id: get_version | |
run: | | |
nix run nixpkgs#nushell -- -c ' | |
let version = "${{ matrix.version }}" | |
let release_key = if ($version | str contains "orioledb") { | |
$"postgresorioledb-17" | |
} else { | |
$"postgres($version)" | |
} | |
let pg_version = (open ansible/vars.yml | get postgres_release | get $release_key | str trim) | |
$"pg_version=supabase/postgres:($pg_version)" | save --append $env.GITHUB_OUTPUT | |
' | |
- name: Output version | |
id: output_version | |
run: | | |
echo "result=${{ steps.get_version.outputs.pg_version }}" >> $GITHUB_OUTPUT | |
- name: Collect versions | |
id: collect_versions | |
run: | | |
versions=() | |
versions+=("${{ steps.output_version.outputs.result }}") | |
echo "matrix_results=[\"${versions[*]}\"]" >> $GITHUB_OUTPUT | |
- name: Debug matrix_results Output | |
run: | | |
echo "Debug matrix_results: '${{ steps.collect_versions.outputs.matrix_results }}'" | |
- name: Append Results to Artifact | |
run: | | |
echo "${{ steps.collect_versions.outputs.matrix_results }}" >> results.txt | |
- name: Upload Results Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: merge_results | |
path: results.txt | |
- name: Merge multi-arch manifests | |
run: | | |
docker buildx imagetools create -t ${{ steps.get_version.outputs.pg_version }} \ | |
${{ steps.get_version.outputs.pg_version }}_amd64 \ | |
${{ steps.get_version.outputs.pg_version }}_arm64 | |
combine_results: | |
needs: merge_manifest | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 # Required if other file dependencies are in the repository | |
- uses: DeterminateSystems/nix-installer-action@main # Ensures Nushell is available | |
- name: Download Results Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: merge_results | |
- name: Combine Results | |
id: combine | |
run: | | |
nix run nixpkgs#nushell -- -c ' | |
let results = (open results.txt | lines | where { |line| $line != "" }) | |
let matrix = { include: ($results | each { |ver| { version: $ver } }) } | |
$"matrix=($matrix | to json -r)" | save --append $env.GITHUB_OUTPUT | |
' | |
- name: Debug Combined Results | |
run: | | |
echo "Combined Results: '${{ steps.combine.outputs.matrix }}'" | |
outputs: | |
matrix: ${{ steps.combine.outputs.matrix }} | |
publish: | |
needs: combine_results | |
strategy: | |
matrix: ${{ fromJson(needs.combine_results.outputs.matrix) }} | |
uses: ./.github/workflows/mirror.yml | |
with: | |
version: ${{ matrix.version }} | |
secrets: inherit |