-
Notifications
You must be signed in to change notification settings - Fork 11
76 lines (69 loc) · 2.66 KB
/
container.yaml
File metadata and controls
76 lines (69 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- 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@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
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@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download liwan binaries
env:
INPUT_TAG: "${{ inputs.tag }}"
run: |
mkdir -p dist/amd64 dist/arm64 dist/data
# sanitize tag: only keep alphanum, dot, underscore, dash
SAFE_TAG=$(echo "$INPUT_TAG" | sed 's/[^A-Za-z0-9._-]/_/g')
curl -fsSL https://github.com/explodingcamera/liwan/releases/download/$SAFE_TAG/liwan-x86_64-unknown-linux-musl.tar.gz \
| tar -xz -C dist/amd64 &
curl -fsSL https://github.com/explodingcamera/liwan/releases/download/$SAFE_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@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: .
file: ./scripts/Containerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}