blob: 574e3b3b8547ced55806bc49bd13a069669f5e92 (
plain) (
blame)
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
77
78
79
80
81
82
83
84
85
86
|
[tasks.tags]
description = "Show the Docker Hub tags for the current image version"
run = '''
#!/usr/bin/env bash
set -euo pipefail
arg_value() {
local name=$1
local values
values=$(sed -n "s/^ARG ${name}=//p" Containerfile | sort -u)
if [[ -z $values || $values == *$'\n'* ]]; then
echo "Containerfile must define one consistent value for ARG ${name}" >&2
exit 1
fi
printf '%s' "$values"
}
repository=${CGIT_IMAGE_REPOSITORY:-docker.io/pablu/cgit}
cgit_version=$(arg_value CGIT_VERSION)
image_revision=$(arg_value IMAGE_REVISION)
if [[ ! $cgit_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "CGIT_VERSION must be a three-part version, got: ${cgit_version}" >&2
exit 1
fi
if [[ ! $image_revision =~ ^[0-9]+$ ]]; then
echo "IMAGE_REVISION must be a non-negative integer, got: ${image_revision}" >&2
exit 1
fi
minor_version=${cgit_version%.*}
major_version=${cgit_version%%.*}
printf '%s\n' \
"${repository}:${cgit_version}-r${image_revision}" \
"${repository}:${cgit_version}" \
"${repository}:${minor_version}" \
"${repository}:${major_version}"
'''
[tasks.build]
description = "Build the current cgit image with Podman"
run = '''
#!/usr/bin/env bash
set -euo pipefail
arg_value() {
local name=$1
local values
values=$(sed -n "s/^ARG ${name}=//p" Containerfile | sort -u)
if [[ -z $values || $values == *$'\n'* ]]; then
echo "Containerfile must define one consistent value for ARG ${name}" >&2
exit 1
fi
printf '%s' "$values"
}
repository=${CGIT_IMAGE_REPOSITORY:-docker.io/pablu/cgit}
cgit_version=$(arg_value CGIT_VERSION)
image_revision=$(arg_value IMAGE_REVISION)
image=${repository}:${cgit_version}-r${image_revision}
podman build --tag "$image" --file Containerfile .
'''
[tasks.push]
description = "Build and push the versioned and rolling Docker Hub tags"
depends = ["build"]
run = '''
#!/usr/bin/env bash
set -euo pipefail
mapfile -t images < <(mise run tags)
source_image=${images[0]}
for image in "${images[@]}"; do
if [[ $image != "$source_image" ]]; then
podman tag "$source_image" "$image"
fi
podman push "$image"
done
'''
|