-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-build-helper.sh
executable file
·50 lines (43 loc) · 1.12 KB
/
docker-build-helper.sh
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
#! /usr/bin/env bash
# Copyright 2024 Dotanuki Labs
# SPDX-License-Identifier: MIT
set -e
readonly runner="$RUNNER_NAME"
readonly docker_image="ghcr.io/dotanuki-labs/callinectes"
prepare_env_for_build() {
case "$runner" in
*arm64*)
echo "platform=arm64" >>"$GITHUB_OUTPUT"
;;
*amd64*)
echo "platform=amd64" >>"$GITHUB_OUTPUT"
;;
*)
echo "Error: unsupported runner → $runner"
exit 1
;;
esac
}
merge_and_push_manifest() {
local package="$docker_image:$argument"
local latest="$docker_image:latest"
docker manifest create "$latest" --amend "$package"-amd64 --amend "$package"-arm64
docker manifest annotate --arch amd64 --os linux "$latest" "$package"-amd64
docker manifest annotate --arch arm64 --os linux "$latest" "$package"-arm64
docker manifest inspect "$latest"
docker manifest push "$latest"
}
readonly task="$1"
readonly argument="$2"
case "$task" in
prepare-environment)
prepare_env_for_build
;;
push-merged-manifest)
merge_and_push_manifest
;;
*)
echo "Error: unsupported task → $task"
exit 1
;;
esac