Skip to content

chore: install with snap #40

chore: install with snap

chore: install with snap #40

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:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Install Nushell
run: |
sudo snap install nushell --classic
- name: Generate build matrix
id: set-matrix
run: |
nu -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) | 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
- name: Install Nushell
run: |
sudo snap install nushell --classic
- name: Set PostgreSQL version environment variable
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
- name: Generate common-nix.vars.pkr.hcl
run: |
nu -c 'let pg_version = (open ansible/vars.yml | get postgres_release | get $"postgres${{ matrix.version }}" | str trim)
$"postgres-version = \"($pg_version)\"" | save common-nix.vars.pkr.hcl
"" | save --append common-nix.vars.pkr.hcl'
- id: settings
run: |
nu -c 'open common-nix.vars.pkr.hcl | str replace -a "[\\s\"]+" "" | save --append $env.GITHUB_OUTPUT'
- id: args
run: |
nu -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:
include: ${{ fromJson(needs.prepare.outputs.matrix_config).include }}
arch: [amd64, arm64]
runs-on: ${{ matrix.arch == 'amd64' && fromJson('["self-hosted", "X64"]') || 'arm-runner' }}
timeout-minutes: 180
steps:
- uses: actions/checkout@v3
- name: Install Nushell
run: |
sudo snap install nushell --classic
- 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
run: |
nu -c '
let version = "${{ matrix.version }}"
let release_key = if ($version | str contains "orioledb") {
$"postgres($version | str replace "-" "")"
} else {
$"postgres($version)"
}
let pg_version = (open ansible/vars.yml | get postgres_release | get $release_key | str trim)
$"supabase/postgres:($pg_version)" | save --append $env.GITHUB_ENV
'
- id: build
uses: docker/build-push-action@v5
with:
push: true
build-args: |
${{ needs.build.outputs.build_args }}
target: production
tags: ${{ env.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.dockerfile }}
- name: Slack Notification
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
SLACK_USERNAME: "gha-failures-notifier"
SLACK_COLOR: "danger"
SLACK_MESSAGE: "Building Postgres ${{ matrix.arch }} image failed for version ${{ matrix.version }}"
SLACK_FOOTER: ""
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
- name: Install Nushell
run: |
sudo snap install nushell --classic
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get image tag
run: |
nu -c '
let version = "${{ matrix.version }}"
let release_key = if ($version | str contains "orioledb") {
$"postgres($version | str replace "-" "")"
} else {
$"postgres($version)"
}
let pg_version = (open ansible/vars.yml | get postgres_release | get $release_key | str trim)
$"supabase/postgres:($pg_version)" | save --append $env.GITHUB_ENV
'
- name: Merge multi-arch manifests
run: |
docker buildx imagetools create -t ${{ env.pg_version }} \
${{ env.pg_version }}_amd64 \
${{ env.pg_version }}_arm64
get_publish_version:
needs: [prepare, merge_manifest]
strategy:
matrix:
include: ${{ fromJson(needs.prepare.outputs.matrix_config).include }}
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get_versions.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- name: Install Nushell
run: |
sudo snap install nushell --classic
- name: Get version
id: get_versions
run: |
nu -c '
let version = "${{ matrix.version }}"
let release_key = if ($version | str contains "orioledb") {
$"postgres($version | str replace "-" "")"
} else {
$"postgres($version)"
}
let pg_version = (open ansible/vars.yml | get postgres_release | get $release_key | str trim)
let matrix = {include: [{version: $pg_version}]}
$"matrix=($matrix | to json)" | save --append $env.GITHUB_OUTPUT
'
publish:
needs: get_publish_version
strategy:
matrix: ${{ fromJson(needs.get_publish_version.outputs.matrix) }}
uses: ./.github/workflows/mirror.yml
with:
version: ${{ matrix.version }}
secrets: inherit