8000 publish docker images/image updates for major versions by samrose · Pull Request #1372 · supabase/postgres · GitHub
[go: up one dir, main page]

Skip to content

publish docker images/image updates for major versions #1372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 97 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
c37f69b
feat: orioledb-17 Docker image and publish workflow
samrose Dec 9, 2024
7ba55bf
feat: refactor to build docker images from major versions
samrose Dec 13, 2024
ee89cc2
feat: gen common vars hcl file
samrose Dec 13, 2024
c53895a
chore: cleanup
samrose Dec 13, 2024
1b17127
chore: adj trigger for run in PR`
samrose Dec 13, 2024
4c45cf1
chore: trigger release all major vers
samrose Dec 13, 2024
f4eb159
chore: trigger on any path
samrose Dec 13, 2024
74c5905
chore: cleanup version handling
samrose Dec 13, 2024
6bd45b1
chore: simplify name matching
samrose Dec 13, 2024
2be76f4
chore: matrix on version and arch in build_release_image
samrose Dec 13, 2024
7f16807
chore: try to get json formatting correct
samrose Dec 13, 2024
e5cbc7c
chore: more fixes to json parse
samrose Dec 13, 2024
6731dab
feat: collect all versions into file, then array
samrose Dec 13, 2024
7a69907
chore: try to account for gh action handling
samrose Dec 13, 2024
2addaab
chore: output single matrix for each version
samrose Dec 13, 2024
19f50db
chore: more fixes to matrix handling
samrose Dec 13, 2024
d3392e0
chore : fix output versions
samrose Dec 13, 2024
8000
33f8ae3
chore: matrix in all tasks
samrose Dec 16, 2024
ec1b4ac
chore: refactor matrix handling
samrose Dec 16, 2024
cf0702c
chore: fix syntax
samrose Dec 16, 2024
7b5c419
chore: look in the right dir
samrose Dec 16, 2024
4395c35
chore: need to pass full tag
samrose Dec 16, 2024
f7b36dc
fix: formatting
samrose Dec 16, 2024
2a5b6a4
chore: strip the prefix when passing to mirror.yml
samrose Dec 16, 2024
761d019
chore: get version formatted to pass to mirror.yml
samrose Dec 16, 2024
9f7ee62
fix: typo
samrose Dec 16, 2024
94c32a5
chore: fix vars
samrose Dec 17, 2024
2c94c9c
fix: tryo to pass the version
samrose Dec 17, 2024
4dbac71
chore: matrix on version and arch
samrose Dec 17, 2024
16788ef
chore: try to account for orioledb version issue
samrose Dec 17, 2024
de3b59d
chore: remove version
samrose Dec 17, 2024
9ef1aae
chore: reading the version info directly from vars.yml
samrose Dec 17, 2024
1882226
chore: force string context
samrose Dec 17, 2024
63c0222
chore: fixing logic
samrose Dec 17, 2024
4ce2b4f
chore: fix string handling logic
samrose Dec 17, 2024
d80e8b3
chore: use sed and grep instead
samrose Dec 17, 2024
a935b19
chore: revert this to working version
samrose Dec 17, 2024
a2323c2
chore: version extraction
samrose Dec 17, 2024
c9ff94f
chore: different logic on version processing if stmnt
samrose Dec 17, 2024
baa41b0
chore: try to avoid jq involvement in this section
samrose Dec 17, 2024
f65c5e6
chore: back to this version
samrose Dec 18, 2024
ea2bc3b
chore: refactor using nushell where scripting needed
samrose Dec 18, 2024
2c63e7a
chore: use data from previous step
samrose Dec 18, 2024
43ae0dc
chore: install with snap
samrose Dec 18, 2024
b91e4a7
chore: raw output on json
samrose Dec 18, 2024
4454104
chore: should be able to run on ephemeral runners
samrose Dec 18, 2024
cd65a52
chore: incrementing changes to matrix
samrose Dec 18, 2024
66b964c
chore: just use special key name if present
samrose Dec 18, 2024
75d2a56
chore: account for postgres namespace in matrix
samrose Dec 18, 2024
faa565a
chore: pg_version should be key/value
samrose Dec 18, 2024
1e46a6e
chrore: ubuntu latest
samrose Dec 18, 2024
4168531
chore: needs arm-runner after all
samrose Dec 18, 2024
030d3c8
chore: source nushell from nix
samrose Dec 18, 2024
f03c65a
chore: cannot have uses and run keys on same id
samrose Dec 18, 2024
413c7a4
chore: detect runner and adjust the way command is run
samrose Dec 18, 2024
084b300
chore: formatting
samrose Dec 18, 2024
126e974
chore: make sure env var can be appended in all contexts
samrose Dec 18, 2024
4a6db10
chore: outputs instead of env
samrose Dec 19, 2024
ad254d5
chore: fix get_publish_version
samrose Dec 19, 2024
8c777d0
chore: handle oriole
samrose Dec 19, 2024
98c9bee
chore: remove base64 encoding
samrose Dec 19, 2024
613b45c
ore: raw json
samrose Dec 19, 2024
2c662f2
chore: ensure proper variable naming
samrose Dec 19, 2024
9df7187
chore: use the matrix config we already have access to
samrose Dec 19, 2024
47e3258
chore: handling architecture
samrose Dec 19, 2024
369f534
chore directly use matrix
samrose Dec 19, 2024
cd2e596
chore: process each version
samrose Dec 19, 2024
e862161
chore: matrix_json variable
samrose Dec 19, 2024
cb685ba
fix: mirroring the merged manifest instead of per arch image
samrose Dec 20, 2024
d66ac71
chore: using tags from merge_manifest
samrose Dec 20, 2024
c40f455
chore: no longer need get_publish_version at all
samrose Dec 20, 2024
b8f58e6
chore: combine tags in outputs at the end of merge_manifest
samrose Dec 20, 2024
0d7253e
chore: cleanup steps to unbreak yaml
samrose Dec 20, 2024
60b2ea2
chore: no from json
samrose Dec 20, 2024
6ce3238
chore: try to build up json over iterations
samrose Dec 20, 2024
1b9fd7e
chore: use the github outputs array
samrose Dec 20, 2024
0d50263
chore: first collect all versions into array then output json array
samrose Dec 20, 2024
7664b4e
chore: debug mainfest output
samrose Dec 20, 2024
ce09b8e
chore: store the results data in artifacts
samrose Dec 20, 2024
de42c0e
chore: unique upload, then download and combine
samrose Dec 20, 2024
458d3db
fix: re-add actions and login
samrose Dec 20, 2024
74d63aa
chore: try quotes for name matching
samrose Dec 20, 2024
16cfb3f
chore: utilise versions from prepare for download of artifact
samrose Dec 20, 2024
60dd2dd
chore: format correctly for nushell
samrose Dec 20, 2024
6f7ce25
chore: parse matrix config directly
samrose Dec 20, 2024
90a45f4
chore: convert table to list of strings
samrose Dec 20, 2024
e42ab66
chore:rm redundant
samrose Dec 21, 2024
62f5ee2
chore: add debug
samrose Dec 21, 2024
f72840d
chore: from json
samrose Dec 21, 2024
4ab2e18
chore: download with pattern
samrose Dec 21, 2024
825dd85
chore: use list operations
samrose Dec 21, 2024
c619fb8
chore: include and debug
samrose Dec 21, 2024
2ec2b5c
chore: extract version
samrose Dec 21, 2024
b8399b9
chore: set up for merge to develop
samrose Dec 21, 2024
c2792dc
chore: add permission to proper dir
samrose Dec 21, 2024
c704342
chore: remove old files
samrose Dec 21, 2024
c571b3f
chore: newline
samrose Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 0 additions & 104 deletions .github/workflows/dockerhub-release-15-6.yml

This file was deleted.

240 changes: 240 additions & 0 deletions .github/workflows/dockerhub-release-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
name: Release all major versions on Dockerhub

on:
push:
branches:
- develop
- release/*
paths:
- ".github/workflows/dockerhub-release-matrix.yml"
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: |
echo "${{ steps.output_version.outputs.result }}" >> results.txt # Append results
- name: Upload Results Artifact
uses: actions/upload-artifact@v3
with:
name: merge_results-${{ matrix.version }}
path: results.txt
if-no-files-found: warn
- 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: [prepare, merge_manifest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@main

- name: Debug Input from Prepare
run: |
echo "Raw matrix_config output:"
echo "${{ needs.prepare.outputs.matrix_config }}"
- name: Get Versions from Matrix Config
id: get_versions
run: |
nix run nixpkgs#nushell -- -c '
# Parse the matrix configuration directly
let matrix_config = (${{ toJson(needs.prepare.outputs.matrix_config) }} | from json)

# Get versions directly from include array
let versions = ($matrix_config.include | get version)

echo "Versions: $versions"

# Convert the versions to a comma-separated string
let versions_str = ($versions | str join ",")
$"versions=$versions_str" | save --append $env.GITHUB_ENV
'
- name: Download Results Artifacts
uses: actions/download-artifact@v3
with:
pattern: merge_results-*
- name: Combine Results
id: combine
run: |
nix run nixpkgs#nushell -- -c '
# Get all results files and process them in one go
let files = (ls **/results.txt | get name)
echo $"Found files: ($files)"

let matrix = {
include: (
$files
| each { |file| open $file } # Open each file
| each { |content| $content | lines } # Split into lines
| flatten # Flatten the nested lists
| where { |line| $line != "" } # Filter empty lines
| each { |line|
# Extract just the version part after the last colon
let version = ($line | parse "supabase/postgres:{version}" | get version.0)
{version: $version}
}
)
}

let json_output = ($matrix | to json -r) # -r for raw output
echo $"Debug output: ($json_output)"

$"matrix=($json_output)" | 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
Loading
Loading
0