-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
build
executable file
·55 lines (49 loc) · 2.52 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
#!/bin/sh
# Set good defaults to allow script to be run by hand. The two variables below
# will never be used when run from within the Docker hub.
DOCKER_REPO=${DOCKER_REPO:-"efrecon/s3fs"}
SOURCE_COMMIT=${SOURCE_COMMIT:-$(git log --no-decorate|grep '^commit'|head -n 1| awk '{print $2}')}
# shellcheck disable=SC1091
. "$(dirname "$0")/reg-tags/image_tags.sh"
# github repo to get list of tags from
BASEREPO=s3fs-fuse/s3fs-fuse
MINVER=${MINVER:-1.78}
VERSIONS=${VERSIONS:-} # When empty, will be all version starting from $MINVER
if [ -z "$VERSIONS" ]; then
VERSIONS=$( curl -qsL https://api.github.com/repos/${BASEREPO}/tags |
grep "\"name\":" |
sed "s/,$//g" |
sed "s/^\s*\"name\":\s*//g" |
sed "s/\"//g")
fi
# Login at the Docker hub to be able to access info about the image.
token=$(img_auth "$DOCKER_REPO")
for version in $VERSIONS; do
official=$(echo "$version" | grep -E "^v[0-9]+(.[0-9]+)*")
if [ -n "$official" ]; then
tag=$(echo "$official" | sed "s/^v//g")
if [ "$tag" = "1.87" ] || [ "$(img_version "$tag")" -lt "$(img_version "$MINVER")" ]; then
echo "======================= Skipping ${DOCKER_REPO}:$tag, known to fail/too old"
else
# Get the revision out of the org.opencontainers.image.revision label, this
# will be the label where we store information about this repo (it cannot be
# the tag, since we tag as the base image).
revision=$(img_labels --verbose --token "$token" -- "$DOCKER_REPO" "$tag" |
grep "^org.opencontainers.image.revision" |
sed -E 's/^org.opencontainers.image.revision=(.+)/\1/')
# If the revision is different from the source commit (including empty,
# which will happen when our version of the image does not already exist),
# build the image, making sure we label with the git commit sha at the
# org.opencontainers.image.revision OCI label, but using the same tag as the
# library image.
if [ "$revision" != "$SOURCE_COMMIT" ]; then
echo "======================= Building ${DOCKER_REPO}:$tag"
docker buildx build --platform linux/arm64,linux/amd64,linux/arm/v7 --push \
--build-arg S3FS_VERSION="$version" \
--tag "${DOCKER_REPO}:$tag" \
--label "org.opencontainers.image.revision=$SOURCE_COMMIT" \
.
fi
fi
fi
done