-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
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 7ba55bf
feat: refactor to build docker images from major versions
samrose ee89cc2
feat: gen common vars hcl file
samrose c53895a
chore: cleanup
samrose 1b17127
chore: adj trigger for run in PR`
samrose 4c45cf1
chore: trigger release all major vers
samrose f4eb159
chore: trigger on any path
samrose 74c5905
chore: cleanup version handling
samrose 6bd45b1
chore: simplify name matching
samrose 2be76f4
chore: matrix on version and arch in build_release_image
samrose 7f16807
chore: try to get json formatting correct
samrose e5cbc7c
chore: more fixes to json parse
samrose 6731dab
feat: collect all versions into file, then array
samrose 7a69907
chore: try to account for gh action handling
samrose 2addaab
chore: output single matrix for each version
samrose 19f50db
chore: more fixes to matrix handling
samrose d3392e0
chore : fix output versions
samrose 33f8ae3
chore: matrix in all tasks
samrose ec1b4ac
chore: refactor matrix handling
samrose cf0702c
chore: fix syntax
samrose 7b5c419
chore: look in the right dir
samrose 4395c35
chore: need to pass full tag
samrose f7b36dc
fix: formatting
samrose 2a5b6a4
chore: strip the prefix when passing to mirror.yml
samrose 761d019
chore: get version formatted to pass to mirror.yml
samrose 9f7ee62
fix: typo
samrose 94c32a5
chore: fix vars
samrose 2c94c9c
fix: tryo to pass the version
samrose 4dbac71
chore: matrix on version and arch
samrose 16788ef
chore: try to account for orioledb version issue
samrose de3b59d
chore: remove version
samrose 9ef1aae
chore: reading the version info directly from vars.yml
samrose 1882226
chore: force string context
samrose 63c0222
chore: fixing logic
samrose 4ce2b4f
chore: fix string handling logic
samrose d80e8b3
chore: use sed and grep instead
samrose a935b19
chore: revert this to working version
samrose a2323c2
chore: version extraction
samrose c9ff94f
chore: different logic on version processing if stmnt
samrose baa41b0
chore: try to avoid jq involvement in this section
samrose f65c5e6
chore: back to this version
samrose ea2bc3b
chore: refactor using nushell where scripting needed
samrose 2c63e7a
chore: use data from previous step
samrose 43ae0dc
chore: install with snap
samrose b91e4a7
chore: raw output on json
samrose 4454104
chore: should be able to run on ephemeral runners
samrose cd65a52
chore: incrementing changes to matrix
samrose 66b964c
chore: just use special key name if present
samrose 75d2a56
chore: account for postgres namespace in matrix
samrose faa565a
chore: pg_version should be key/value
samrose 1e46a6e
chrore: ubuntu latest
samrose 4168531
chore: needs arm-runner after all
samrose 030d3c8
chore: source nushell from nix
samrose f03c65a
chore: cannot have uses and run keys on same id
samrose 413c7a4
chore: detect runner and adjust the way command is run
samrose 084b300
chore: formatting
samrose 126e974
chore: make sure env var can be appended in all contexts
samrose 4a6db10
chore: outputs instead of env
samrose ad254d5
chore: fix get_publish_version
samrose 8c777d0
chore: handle oriole
samrose 98c9bee
chore: remove base64 encoding
samrose 613b45c
ore: raw json
samrose 2c662f2
chore: ensure proper variable naming
samrose 9df7187
chore: use the matrix config we already have access to
samrose 47e3258
chore: handling architecture
samrose 369f534
chore directly use matrix
samrose cd2e596
chore: process each version
samrose e862161
chore: matrix_json variable
samrose cb685ba
fix: mirroring the merged manifest instead of per arch image
samrose d66ac71
chore: using tags from merge_manifest
samrose c40f455
chore: no longer need get_publish_version at all
samrose b8f58e6
chore: combine tags in outputs at the end of merge_manifest
samrose 0d7253e
chore: cleanup steps to unbreak yaml
samrose 60b2ea2
chore: no from json
samrose 6ce3238
chore: try to build up json over iterations
samrose 1b9fd7e
chore: use the github outputs array
samrose 0d50263
chore: first collect all versions into array then output json array
samrose 7664b4e
chore: debug mainfest output
samrose ce09b8e
chore: store the results data in artifacts
samrose de42c0e
chore: unique upload, then download and combine
samrose 458d3db
fix: re-add actions and login
samrose 74d63aa
chore: try quotes for name matching
samrose 16cfb3f
chore: utilise versions from prepare for download of artifact
samrose 60dd2dd
chore: format correctly for nushell
samrose 6f7ce25
chore: parse matrix config directly
samrose 90a45f4
chore: convert table to list of strings
samrose e42ab66
chore:rm redundant
samrose 62f5ee2
chore: add debug
samrose f72840d
chore: from json
samrose 4ab2e18
chore: download with pattern
samrose 825dd85
chore: use list operations
samrose c619fb8
chore: include and debug
samrose 2ec2b5c
chore: extract version
samrose b8399b9
chore: set up for merge to develop
samrose c2792dc
chore: add permission to proper dir
samrose c704342
chore: remove old files
samrose c571b3f
chore: newline
samrose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.