106 lines
3.3 KiB
YAML
106 lines
3.3 KiB
YAML
name: Docker Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Release tag (e.g. v0.1.0)'
|
|
required: true
|
|
default: v0.1.0
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
concurrency:
|
|
group: docker-release-${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }}-${{ matrix.arch }}
|
|
cancel-in-progress: false
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
arch: amd64
|
|
- platform: linux/arm64
|
|
arch: arm64
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }}
|
|
|
|
- name: Resolve version
|
|
id: version
|
|
env:
|
|
REF_NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
|
|
run: echo "version=${REF_NAME#v}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Set up QEMU
|
|
if: matrix.arch == 'arm64'
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push arch image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: ${{ matrix.platform }}
|
|
push: true
|
|
build-args: |
|
|
VERSION=${{ steps.version.outputs.version }}
|
|
tags: ${{ secrets.DOCKERHUB_USERNAME }}/havline:${{ steps.version.outputs.version }}-${{ matrix.arch }}
|
|
labels: |
|
|
org.opencontainers.image.source=${{ github.repositoryUrl }}
|
|
org.opencontainers.image.version=${{ steps.version.outputs.version }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
cache-from: type=gha,scope=${{ matrix.arch }}
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
|
|
|
|
create-manifest:
|
|
needs: build-and-push
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Resolve version
|
|
id: version
|
|
env:
|
|
REF_NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
|
|
run: echo "version=${REF_NAME#v}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Create multi-arch manifest
|
|
env:
|
|
IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/havline
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
run: |
|
|
if [ -z "${IMAGE}" ]; then
|
|
echo "DOCKERHUB_USERNAME secret is not set" >&2
|
|
exit 1
|
|
fi
|
|
docker buildx imagetools create \
|
|
-t "${IMAGE}:${VERSION}" \
|
|
-t "${IMAGE}:latest" \
|
|
"${IMAGE}:${VERSION}-amd64" \
|
|
"${IMAGE}:${VERSION}-arm64"
|