Skip to content

Unique tags per build #24

Unique tags per build

Unique tags per build #24

Workflow file for this run

name: 💫 Build and push Spilo
on:
push:
branches: [release]
concurrency:
group: environment-${{ github.ref }}
cancel-in-progress: true
jobs:
build_spilo:
name: 🔨 Build Spilo ${{ matrix.pgversion }} for ${{ matrix.arch }}
strategy:
matrix:
pgversion: [14, 15, 16, 17]
arch: [amd64, arm64]
include:
- arch: amd64
platform: linux/amd64
runs-on: ubuntu-24.04
- arch: arm64
platform: linux/arm64
runs-on: ubuntu-24.04-arm
runs-on: ${{ matrix.runs-on }}
env:
GITHUB_RUN_ID: ${{ github.run_id }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
# Set up cache for Docker layers
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Spilo image
if: success()
uses: docker/build-push-action@v5
with:
context: ./postgres-appliance
platforms: ${{ matrix.platform }}
provenance: false
push: true
file: ./postgres-appliance/Dockerfile
tags: |
ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}-${{ matrix.arch }}
ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-latest-${{ matrix.arch }}
build-args: |
PGVERSION=${{ matrix.pgversion }}
create_manifests:
name: 📦 Create and Push Multi-Arch Manifests for PostgreSQL ${{ matrix.pgversion }}
runs-on: ubuntu-24.04
needs: [build_spilo]
strategy:
matrix:
pgversion: [14, 15, 16, 17]
env:
GITHUB_RUN_ID: ${{ github.run_id }}
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifest for PG ${{ matrix.pgversion }}
run: |
# Create run-specific tag with both architectures
docker manifest create ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }} \
--amend ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}-arm64
docker manifest annotate --arch amd64 --os linux ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }} ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}-amd64
docker manifest annotate --arch arm64 --os linux ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }} ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}
# Tag as version-latest
docker manifest create ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-latest \
--amend ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}-arm64
docker manifest annotate --arch amd64 --os linux ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-latest ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}-amd64
docker manifest annotate --arch arm64 --os linux ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-latest ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-${{ github.run_id }}-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/spilo:${{ matrix.pgversion }}-latest
# Optional: Add a separate step to tag the latest PostgreSQL version as the default "latest" tag
tag_latest:
name: 🏷️ Tag PostgreSQL 17 as Latest
runs-on: ubuntu-24.04
needs: [create_manifests]
env:
GITHUB_RUN_ID: ${{ github.run_id }}
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag PostgreSQL 17 as latest
run: |
docker manifest create ghcr.io/${{ github.repository_owner }}/spilo:latest \
--amend ghcr.io/${{ github.repository_owner }}/spilo:17-${{ github.run_id }}-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/spilo:17-${{ github.run_id }}-arm64
docker manifest annotate --arch amd64 --os linux ghcr.io/${{ github.repository_owner }}/spilo:latest ghcr.io/${{ github.repository_owner }}/spilo:17-${{ github.run_id }}-amd64
docker manifest annotate --arch arm64 --os linux ghcr.io/${{ github.repository_owner }}/spilo:latest ghcr.io/${{ github.repository_owner }}/spilo:17-${{ github.run_id }}-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/spilo:latest