-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (112 loc) · 4.12 KB
/
build-container-image.yml
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Build container image
on:
schedule:
- cron: "55 4 * * *"
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
image:
name: Build container image
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: uniget-bot
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install uniget
uses: uniget-org/uniget-action@2801de6989bb0c244342f750b29e6451498ba742 # v1
with:
prefix: helper
tools: jq regclient
- name: Fetch release asset
run: |
INPUT_VERSION="${{ inputs.tag }}"
if test -n "${INPUT_VERSION}"; then
VERSION="${INPUT_VERSION#v}"
else
VERSION="$( uniget --version | cut -d' ' -f3 )"
fi
if test -z "${VERSION}"; then
echo "### Unable to determine version from input (${INPUT_VERSION}) or uniget"
exit 1
fi
echo "VERSION=${VERSION}" >>"${GITHUB_ENV}"
echo "### Downloading from release ${VERSION}"
for ARCH in x86_64 aarch64; do
case "${ARCH}" in
x86_64)
ALT_ARCH=amd64
;;
aarch64)
ALT_ARCH=arm64
;;
*)
echo "### Unsupported architecture ${ARCH}"
exit 1
;;
esac
echo "### Downloading for architecture ${ARCH} (${ALT_ARCH})"
mkdir -p "dist/default_linux_${ALT_ARCH}"
url="https://github.com/uniget-org/cli/releases/download/v${VERSION}/uniget_Linux_${ARCH}.tar.gz"
echo "### Downloading from ${url}"
curl --silent --show-error --location --fail "${url}" \
| tar --extract --gzip --directory "dist/default_linux_${ALT_ARCH}" uniget
done
- name: Build systemd container image
run: |
echo "### Building container image for version ${VERSION}"
docker buildx build . \
--target systemd-uniget \
--platform linux/amd64,linux/arm64 \
--build-arg version="${VERSION}" \
--tag "ghcr.io/uniget-org/cli:${VERSION}" \
--push
LATEST_VERSION="$(
./helper/usr/local/bin/regctl tag list ghcr.io/uniget-org/cli \
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \
| sort -Vr \
| head -n 1
)"
if test -z "${LATEST_VERSION}"; then
echo "### No tags found"
exit
fi
echo "### Tagging ${LATEST_VERSION} as latest"
if ! ./helper/usr/local/bin/regctl manifest get ghcr.io/uniget-org/cli:${LATEST_VERSION}; then
echo " Tag ${LATEST_VERSION} does not exist"
exit
fi
./helper/usr/local/bin/regctl image copy \
"ghcr.io/uniget-org/cli:${VERSION}" \
"ghcr.io/uniget-org/cli:${LATEST_VERSION}"
- name: Build alpine container image
run: |
echo "### Building container image for version ${VERSION}"
docker buildx build . \
--target alpine-uniget \
--platform linux/amd64,linux/arm64 \
--build-arg version="${VERSION}" \
--tag "ghcr.io/uniget-org/cli:alpine-${VERSION}" \
--push
- name: Build noble container image
run: |
echo "### Building container image for version ${VERSION}"
docker buildx build . \
--target ubuntu2404-uniget \
--platform linux/amd64,linux/arm64 \
--build-arg version="${VERSION}" \
--tag "ghcr.io/uniget-org/cli:noble-${VERSION}" \
--push