Fix docker tagging #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
tags: | |
- "*" | |
pull_request: | |
branches: | |
- master | |
permissions: {} | |
jobs: | |
build: | |
runs-on: ${{ matrix.runs-on }} | |
strategy: | |
matrix: | |
arch: [amd64, arm64] | |
include: | |
- arch: amd64 | |
runs-on: ubuntu-latest | |
- arch: arm64 | |
runs-on: ubuntu-24.04-arm | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: docker/setup-buildx-action@v3 | |
with: | |
cache-binary: false | |
- name: Build | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/${{ matrix.arch }} | |
push: false | |
build-args: | | |
${{ startsWith(github.ref, 'refs/tags/') && format('VERSION={0}', github.ref_name) || '' }} | |
cache-from: | | |
type=gha,scope=docker-build-${{ matrix.arch }} | |
cache-to: | | |
type=gha,mode=max,scope=docker-build-${{ matrix.arch }} | |
context: . | |
package: | |
needs: [build] | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- run: lscpu | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ github.token }} | |
- uses: docker/setup-buildx-action@v3 | |
with: | |
cache-binary: false | |
- uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
images: ghcr.io/${{ github.repository_owner }}/arti | |
tags: | | |
# For non-tag events | |
type=ref,event=branch | |
type=ref,event=pr | |
# For tag events, generate versions | |
type=match,pattern=arti-v(\d+)\.(\d+)\.(\d+),group=1.2.3 | |
type=match,pattern=arti-v(\d+)\.(\d+)\.(\d+),group=1.2 | |
type=match,pattern=arti-v(\d+)\.(\d+)\.(\d+),group=1 | |
# Set latest tag for tagged releases | |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
- name: Package and Push | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
${{ startsWith(github.ref, 'refs/tags/') && format('VERSION={0}', github.ref_name) || '' }} | |
push: true | |
cache-from: | | |
type=gha,scope=docker-package | |
type=gha,scope=docker-build-amd64 | |
type=gha,scope=docker-build-arm64 | |
cache-to: | | |
type=gha,mode=max,scope=docker-package | |
context: . |