-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathbuild
executable file
·56 lines (49 loc) · 1.82 KB
/
build
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
#!/bin/bash
set -e
source .envrc
DIR=${DIR:=.}
REGISTRY=${REGISTRY:="$NAME"}
ARCHS=${ARCHS:='amd64 arm64'}
# For main Sqitch build, the main tag is "latest" and there
# is no sub-package.
PKG=""
TAG="latest"
if [ "$DIR" != "." ]; then
# For other builds, we need to append a sub-package name and use the
# diretory name as the main tag.
cd $DIR
PKG="-$DIR"
TAG="$DIR"
fi
# Always include "latest" and the version.
tagopt=(
--tag "${REGISTRY}/${NAME}:${TAG}"
--tag "${REGISTRY}/${NAME}:v${VERSION}${PKG}"
)
# Include the git tag if differnt from the version.
if [ "$GITHUB_REF_TYPE" == "tag" ]; then
GIT_TAG=${GITHUB_REF/refs\/tags\//}
if [ "$GIT_TAG" != "$VERSION" ]; then
tagopt+=(--tag "${REGISTRY}/${NAME}:${GIT_TAG}${PKG}")
fi
fi
# Build and export imaages to Docker for all supported architectures.
for arch in $ARCHS; do
printf "Building for linux/%s\n" "${arch}"
docker buildx build --platform="linux/${arch}" --pull --load --progress=plain \
--label org.opencontainers.image.created=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label org.opencontainers.image.authors="${AUTHORS}" \
--label org.opencontainers.image.url="${URL}" \
--label org.opencontainers.image.documentation="${DOCS}" \
--label org.opencontainers.image.source="${SOURCE}" \
--label org.opencontainers.image.version="v${VERSION}" \
--label org.opencontainers.image.revision="$(git rev-parse --abbrev-ref HEAD)" \
--label org.opencontainers.image.vendor="${VENDOR}" \
--label org.opencontainers.image.licenses="${LICENSE}" \
--label org.opencontainers.image.ref.name="${NAME}${PKG}-v${VERSION}" \
--label org.opencontainers.image.title="${TITLE}" \
--label org.opencontainers.image.description="${DESCRIPTION}" \
"${tagopt[@]}" \
--build-arg "VERSION=${VERSION}" \
"$@" .
done