forked from openhab/openhab-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-travis-config.sh
executable file
·86 lines (78 loc) · 2.82 KB
/
update-travis-config.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
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
#!/bin/bash
set -eo pipefail
. update-functions.sh
file=.travis.yml
# Print static part of Travis configuration
print_static_configuration() {
cat > $1 <<-'EOI'
#
# ------------------------------------------------------------------------------
# NOTE: THIS TRAVIS CONFIGURATION IS GENERATED VIA "update.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
# ------------------------------------------------------------------------------
#
os: linux
dist: bionic
language: shell
branches:
only:
- master
before_install:
- set -e
# Configure environment so changes are picked up when the Docker daemon is restarted after upgrading
- echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
- export DOCKER_CLI_EXPERIMENTAL=enabled
- docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64
# Upgrade to Docker CE 19.03 for BuildKit support
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce=5:19.03.8~3-0~ubuntu-bionic # pin version for reproducibility
# Show info to simplify debugging and create a builder
- docker info
- docker buildx create --name builder --use
- docker buildx ls
# Prepare openHAB container build
- ./update-docker-files.sh
- source ./update-functions.sh
- validate_readme_constraints
install:
- build_arg_options="--build-arg BUILD_DATE=$(date +"%Y-%m-%dT%H:%M:%SZ") --build-arg VCS_REF=$TRAVIS_COMMIT --build-arg VERSION=$VERSION"
- tags=$(tags $VERSION $DIST)
- tag_options=${tags//$(docker_repo)/--tag $(docker_repo)}
- build_options="$build_arg_options --platform $(platforms $VERSION $DIST) $tag_options --progress plain"
- path="$VERSION/$DIST"
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
docker buildx build $build_options --push $path;
if [ "${SYNC_README:=false}" == "true" ] && [ "$VERSION" == "$(last_stable_version)" ] && [ "$DIST" == "debian" ]; then
./sync-docker-hub-readme.sh;
fi
else
docker buildx build $build_options $path;
fi
jobs:
fast_finish: true
env:
jobs:
EOI
}
# Print Travis matrix environment variables
print_matrix() {
cat >> $1 <<-EOI
- VERSION=$version DIST=$base
EOI
}
echo -n "Writing $file... "
# Generate the static part of the Travis configuration
print_static_configuration $file;
# Generate the matrix for building Dockerfiles
for version in $(build_versions)
do
for base in $(bases)
do
print_matrix $file;
done
done
echo "done"