Skip to content

Release and Publish Docker Images #10

Release and Publish Docker Images

Release and Publish Docker Images #10

name: Release and Publish Docker Images
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. v1.2.3)'
required: true
type: string
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ${{ github.repository }}
VERSION: ${{ github.event.inputs.version }}
jobs:
build-binaries:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build test-runner
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build -o test-runner-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/test-runner
- name: Build snapshot-checker
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build -o snapshot-checker-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/snapshot-checker
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
test-runner-${{ matrix.goos }}-${{ matrix.goarch }}
snapshot-checker-${{ matrix.goos }}-${{ matrix.goarch }}
docker:
needs: build-binaries
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- name: test-runner
dockerfile: Dockerfile.test-runner
- name: snapshot-checker
dockerfile: Dockerfile.snapshot-checker
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ matrix.name }}:${{ env.VERSION }}
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ matrix.name }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
release:
needs: [build-binaries, docker]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: binaries
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
files: binaries/*
generate_release_notes: true