Skip to content

Build & Publish Container Image #18

Build & Publish Container Image

Build & Publish Container Image #18

Workflow file for this run

name: "Build & Publish Container Image"
on:
workflow_call:
inputs:
tag:
type: string
required: true
workflow_dispatch:
inputs:
tag:
description: "Tag (e.g. liwan-v0.1.0)"
required: true
type: string
jobs:
docker-build:
permissions:
contents: read
packages: write
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # @v3
- name: Extract Semver
id: semver
env:
INPUT_TAG: "${{ inputs.tag }}"
run: |
SEMVER_VERSION=$(echo "$INPUT_TAG" | sed -E 's/liwan-v//')
echo "SEMVER_VERSION=${SEMVER_VERSION}" >> "$GITHUB_OUTPUT"
- name: Setup Docker Metadata
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # @v5
id: meta
with:
images: ghcr.io/${{ github.actor }}/liwan
tags: |
type=semver,pattern={{version}},value=${{ steps.semver.outputs.SEMVER_VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semver.outputs.SEMVER_VERSION }}
type=semver,pattern={{major}},value=${{ steps.semver.outputs.SEMVER_VERSION }}
type=raw,edge
- name: Login to GitHub Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # @v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download liwan binaries
run: |
mkdir -p dist/amd64 dist/arm64
curl -fsSL https://github.com/explodingcamera/liwan/releases/download/${{ inputs.tag }}/liwan-x86_64-unknown-linux-musl.tar.gz \
| tar -xz -C dist/amd64 &
curl -fsSL https://github.com/explodingcamera/liwan/releases/download/${{ inputs.tag }}/liwan-aarch64-unknown-linux-musl.tar.gz \
| tar -xz -C dist/arm64 &
wait
- name: Build and push Docker images
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
with:
context: .
file: ./scripts/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}