diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa35d36..5027242 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,12 +10,19 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-and-push: - runs-on: ubuntu-latest + build-platform: + runs-on: ${{ matrix.runner }} permissions: contents: read packages: write id-token: write + strategy: + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + - platform: linux/arm64 + runner: ubuntu-24.04-arm64 steps: - name: Checkout repository @@ -45,18 +52,20 @@ jobs: org.opencontainers.image.title=Barycenter org.opencontainers.image.description=OpenID Connect Identity Provider with federation and auto-registration org.opencontainers.image.vendor=${{ github.repository_owner }} + flavor: | + suffix=-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} - - name: Build and push Docker image + - name: Build and push platform-specific image id: build uses: docker/build-push-action@v6 with: context: . - platforms: linux/amd64,linux/arm64 + platforms: ${{ matrix.platform }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=${{ matrix.platform }} + cache-to: type=gha,mode=max,scope=${{ matrix.platform }} build-args: | VERSION=${{ github.ref_name }} REVISION=${{ github.sha }} @@ -68,9 +77,48 @@ jobs: subject-digest: ${{ steps.build.outputs.digest }} push-to-registry: true + create-manifest: + runs-on: ubuntu-latest + needs: build-platform + permissions: + contents: read + packages: write + + steps: + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for manifest + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}},enable=${{ !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'rc') }} + type=semver,pattern={{major}},enable=${{ !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'rc') }} + type=sha,prefix=sha- + + - name: Create and push multi-platform manifest + run: | + # Extract tags into an array + TAGS=$(echo '${{ steps.meta.outputs.tags }}' | tr '\n' ' ') + + # For each tag, create a manifest combining both platform images + for TAG in $TAGS; do + echo "Creating manifest for $TAG" + docker buildx imagetools create -t $TAG \ + ${TAG}-amd64 \ + ${TAG}-arm64 + done + create-github-release: runs-on: ubuntu-latest - needs: build-and-push + needs: create-manifest permissions: contents: write