mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-12 01:00:51 +00:00
Extract repeated frontend build, frontend restore, and Zig setup steps into shared GitHub Actions so CI workflows use the same artifact and toolchain setup path. Update binary and Docker builds to depend on the frontend artifact, and require an explicit Docker dispatch version for controlled image tagging.
122 lines
3.2 KiB
YAML
122 lines
3.2 KiB
YAML
name: Publish Docker Image Manually
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: Docker image tag and embedded version.
|
|
required: true
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
jobs:
|
|
build-frontend:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build frontend artifact
|
|
uses: ./.github/actions/build-frontend
|
|
with:
|
|
artifact-name: komari-frontend
|
|
|
|
build-docker-binaries:
|
|
needs: build-frontend
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Restore frontend artifact
|
|
uses: ./.github/actions/restore-frontend
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.23"
|
|
|
|
- name: Install Zig
|
|
uses: ./.github/actions/setup-zig
|
|
|
|
- name: Build static binaries for multi-arch
|
|
env:
|
|
GOOS: linux
|
|
CGO_ENABLED: 1
|
|
GIN_MODE: release
|
|
VERSION: ${{ github.event.inputs.version }}
|
|
run: |
|
|
VERSION_HASH="${{ github.sha }}"
|
|
LDFLAGS="-s -w -X github.com/komari-monitor/komari/utils.CurrentVersion=${VERSION} -X github.com/komari-monitor/komari/utils.VersionHash=${VERSION_HASH}"
|
|
|
|
echo "Building for linux/amd64..."
|
|
GOARCH=amd64 CC="zig cc -target x86_64-linux-musl" go build -trimpath -ldflags="$LDFLAGS" -o komari-linux-amd64
|
|
|
|
echo "Building for linux/arm64..."
|
|
GOARCH=arm64 CC="zig cc -target aarch64-linux-musl" go build -trimpath -ldflags="$LDFLAGS" -o komari-linux-arm64
|
|
|
|
- name: Upload Docker binaries
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: komari-docker-binaries
|
|
path: komari-linux-*
|
|
|
|
build-and-push-multi-arch:
|
|
needs: build-docker-binaries
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download Docker binaries
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: komari-docker-binaries
|
|
path: .
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=raw,value=${{ github.event.inputs.version }}
|
|
type=raw,value=latest
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
no-cache: true
|
|
provenance: false
|