2016-10-04 22:33:32 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-05-20 08:02:18 +00:00
|
|
|
ARCHIVE_BUILD_FOLDER="/tmp/portainer-builds"
|
2016-10-04 22:33:32 +00:00
|
|
|
|
2017-07-11 07:30:25 +00:00
|
|
|
# parameter: "platform-architecture"
|
2017-05-20 08:02:18 +00:00
|
|
|
function build_and_push_images() {
|
2017-07-11 07:30:25 +00:00
|
|
|
docker build -t "portainer/portainer:$1-${VERSION}" -f build/linux/Dockerfile .
|
|
|
|
docker tag "portainer/portainer:$1-${VERSION}" "portainer/portainer:$1"
|
|
|
|
docker push "portainer/portainer:$1-${VERSION}"
|
|
|
|
docker push "portainer/portainer:$1"
|
2017-05-20 08:02:18 +00:00
|
|
|
}
|
|
|
|
|
2017-07-11 07:30:25 +00:00
|
|
|
# parameter: "platform-architecture"
|
2017-05-20 08:02:18 +00:00
|
|
|
function build_archive() {
|
2017-07-11 07:30:25 +00:00
|
|
|
BUILD_FOLDER="${ARCHIVE_BUILD_FOLDER}/$1"
|
2017-05-20 08:02:18 +00:00
|
|
|
rm -rf ${BUILD_FOLDER} && mkdir -pv ${BUILD_FOLDER}/portainer
|
2018-07-28 14:12:24 +00:00
|
|
|
cp -r dist/* ${BUILD_FOLDER}/portainer/
|
2017-05-20 08:02:18 +00:00
|
|
|
cd ${BUILD_FOLDER}
|
2017-07-11 07:30:25 +00:00
|
|
|
tar cvpfz "portainer-${VERSION}-$1.tar.gz" portainer
|
|
|
|
mv "portainer-${VERSION}-$1.tar.gz" ${ARCHIVE_BUILD_FOLDER}/
|
2017-05-20 08:02:18 +00:00
|
|
|
cd -
|
|
|
|
}
|
|
|
|
|
2017-07-11 07:30:25 +00:00
|
|
|
function build_all() {
|
|
|
|
mkdir -pv "${ARCHIVE_BUILD_FOLDER}"
|
|
|
|
for tag in $@; do
|
2018-09-16 02:34:46 +00:00
|
|
|
yarn grunt "release:`echo "$tag" | tr '-' ':'`"
|
2017-07-11 07:30:25 +00:00
|
|
|
name="portainer"; if [ "$(echo "$tag" | cut -c1)" = "w" ]; then name="${name}.exe"; fi
|
|
|
|
mv dist/portainer-$tag* dist/$name
|
|
|
|
if [ `echo $tag | cut -d \- -f 1` == 'linux' ]; then build_and_push_images "$tag"; fi
|
|
|
|
build_archive "$tag"
|
|
|
|
done
|
|
|
|
docker rmi $(docker images -q -f dangling=true)
|
|
|
|
}
|
2017-03-12 21:30:50 +00:00
|
|
|
|
2017-07-11 07:30:25 +00:00
|
|
|
if [[ $# -ne 1 ]] ; then
|
|
|
|
echo "Usage: $(basename $0) <VERSION>"
|
|
|
|
echo " $(basename $0) \"echo 'Custom' && <BASH COMMANDS>\""
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
VERSION="$1"
|
|
|
|
if [ `echo "$@" | cut -c1-4` == 'echo' ]; then
|
|
|
|
bash -c "$@";
|
2017-10-15 17:24:40 +00:00
|
|
|
else
|
2017-10-24 08:26:35 +00:00
|
|
|
build_all 'linux-amd64 linux-arm linux-arm64 linux-ppc64le linux-s390x darwin-amd64 windows-amd64'
|
2017-07-11 07:30:25 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|