release: rework release scripts

* fix windows build
This commit is contained in:
Corentin Le Molgat
2022-06-27 18:09:30 +02:00
committed by Mizux Seiha
parent 4c82ba2192
commit 2dc8df2af5
11 changed files with 641 additions and 231 deletions

View File

@@ -1,7 +1,4 @@
# Need a Centos 7 to avoid this:
# https://github.com/google/or-tools/issues/2520#issuecomment-825119882
# note: PEP 599 manylinux2014 is also based on Centos 7 which will reach End of Life (EOL) on June 30th, 2024
FROM centos:7 AS env
FROM quay.io/pypa/manylinux2014_x86_64:latest AS env
#############
## SETUP ##
@@ -12,23 +9,14 @@ RUN yum -y update \
&& yum clean all \
&& rm -rf /var/cache/yum
# Bump to gcc-11
RUN yum -y update \
&& yum -y install centos-release-scl \
&& yum -y install devtoolset-11 \
&& yum clean all \
&& echo "source /opt/rh/devtoolset-11/enable" >> /etc/bashrc
SHELL ["/usr/bin/bash", "--login", "-c"]
ENTRYPOINT ["/usr/bin/bash", "--login", "-c"]
CMD ["/usr/bin/bash", "--login"]
# RUN g++ --version
ENTRYPOINT ["/usr/bin/bash", "-c"]
CMD ["/usr/bin/bash"]
# Install CMake 3.23.2
RUN ARCH=$(uname -m) \
&& wget -q "https://cmake.org/files/v3.23/cmake-3.23.2-linux-${ARCH}.sh" \
&& chmod a+x cmake-3.23.2-linux-${ARCH}.sh \
&& ./cmake-3.23.2-linux-${ARCH}.sh --prefix=/usr/local/ --skip-license \
&& rm cmake-3.23.2-linux-${ARCH}.sh
RUN wget -q --no-check-certificate "https://cmake.org/files/v3.23/cmake-3.23.2-linux-x86_64.sh" \
&& chmod a+x cmake-3.23.2-linux-x86_64.sh \
&& ./cmake-3.23.2-linux-x86_64.sh --prefix=/usr --skip-license \
&& rm cmake-3.23.2-linux-x86_64.sh
# Install Swig 4.0.2
RUN curl --location-trusted \
@@ -66,12 +54,6 @@ RUN yum -y update \
&& yum repolist \
&& yum -y install openssl11
# Install Python
RUN yum -y update \
&& yum -y install python3 python3-devel python3-pip numpy \
&& yum clean all \
&& rm -rf /var/cache/yum
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

View File

@@ -0,0 +1,95 @@
# To build it on x86_64 please read
# https://github.com/multiarch/qemu-user-static#getting-started
#FROM quay.io/pypa/manylinux2014_aarch64:latest AS env
FROM --platform=linux/arm64 centos:7 AS env
#############
## SETUP ##
#############
RUN yum -y update \
&& yum -y groupinstall 'Development Tools' \
&& yum -y install wget curl pcre-devel openssl redhat-lsb-core pkgconfig autoconf libtool zlib-devel which \
&& yum clean all \
&& rm -rf /var/cache/yum
ENTRYPOINT ["/usr/bin/bash", "-c"]
CMD ["/usr/bin/bash"]
# Install CMake 3.23.2
RUN wget -q --no-check-certificate "https://cmake.org/files/v3.23/cmake-3.23.2-linux-aarch64.sh" \
&& chmod a+x cmake-3.23.2-linux-aarch64.sh \
&& ./cmake-3.23.2-linux-aarch64.sh --prefix=/usr --skip-license \
&& rm cmake-3.23.2-linux-aarch64.sh
# Install Swig 4.0.2
RUN curl --location-trusted \
--remote-name "https://downloads.sourceforge.net/project/swig/swig/swig-4.0.2/swig-4.0.2.tar.gz" \
-o swig-4.0.2.tar.gz \
&& tar xvf swig-4.0.2.tar.gz \
&& rm swig-4.0.2.tar.gz \
&& cd swig-4.0.2 \
&& ./configure --prefix=/usr \
&& make -j 4 \
&& make install \
&& cd .. \
&& rm -rf swig-4.0.2
# Install .Net
# see https://docs.microsoft.com/en-us/dotnet/core/install/linux-centos#centos-7-
RUN wget -q "https://dot.net/v1/dotnet-install.sh" \
&& chmod a+x dotnet-install.sh \
&& ./dotnet-install.sh -c 3.1 -i /usr/local/bin \
&& ./dotnet-install.sh -c 6.0 -i /usr/local/bin
# Trigger first run experience by running arbitrary cmd
RUN objdump -p /lib64/libstdc++.so.6
RUN g++ --version
RUN dotnet --info
# Install Java 8 SDK
RUN yum -y update \
&& yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel maven \
&& yum clean all \
&& rm -rf /var/cache/yum
ENV JAVA_HOME=/usr/lib/jvm/java
# Openssl 1.1
RUN yum -y update \
&& yum -y install epel-release \
&& yum repolist \
&& yum -y install openssl11
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
################
## OR-TOOLS ##
################
FROM env AS devel
WORKDIR /root
# Download sources
# use ORTOOLS_GIT_SHA1 to modify the command
# i.e. avoid docker reusing the cache when new commit is pushed
ARG ORTOOLS_GIT_BRANCH
ENV ORTOOLS_GIT_BRANCH ${ORTOOLS_GIT_BRANCH:-main}
ARG ORTOOLS_GIT_SHA1
ENV ORTOOLS_GIT_SHA1 ${ORTOOLS_GIT_SHA1:-unknown}
RUN git clone -b "${ORTOOLS_GIT_BRANCH}" --single-branch https://github.com/google/or-tools \
&& cd or-tools \
&& git reset --hard "${ORTOOLS_GIT_SHA1}"
# Build delivery
FROM devel AS delivery
WORKDIR /root/or-tools
ENV GPG_ARGS ""
ARG ORTOOLS_TOKEN
ENV ORTOOLS_TOKEN ${ORTOOLS_TOKEN}
ARG ORTOOLS_DELIVERY
ENV ORTOOLS_DELIVERY ${ORTOOLS_DELIVERY:-all}
RUN ./tools/release/build_delivery_linux.sh "${ORTOOLS_DELIVERY}"
# Publish delivery
FROM delivery AS publish
RUN ./tools/release/publish_delivery_linux.sh "${ORTOOLS_DELIVERY}"

View File

@@ -22,17 +22,18 @@ function help() {
${BOLD}NAME${RESET}
\t$NAME - Build delivery using the ${BOLD}local host system${RESET}.
${BOLD}SYNOPSIS${RESET}
\t$NAME [-h|--help] [examples|dotnet|java|all]
\t$NAME [-h|--help|help] [examples|dotnet|java|python|all|reset]
${BOLD}DESCRIPTION${RESET}
\tBuild Google OR-Tools deliveries.
\tYou ${BOLD}MUST${RESET} define the following variables before running this script:
\t* ORTOOLS_TOKEN: secret use to decrypt key to sign .Net and Java package.
\t* ORTOOLS_TOKEN: secret use to decrypt keys to sign .Net and Java packages.
${BOLD}OPTIONS${RESET}
\t-h --help: show this help text
\tdotnet: Build dotnet packages
\tjava: Build java packages
\texamples: Build examples archives
\t-h --help: display this help text
\tdotnet: build all .Net packages
\tjava: build all Java packages
\tpython: build all Pyhon packages
\texamples: build examples archives
\tall: build everything (default)
${BOLD}EXAMPLES${RESET}
@@ -40,11 +41,11 @@ Using export to define the ${BOLD}ORTOOLS_TOKEN${RESET} env and only building th
export ORTOOLS_TOKEN=SECRET
$0 java
note: the 'export ...' should be placed in your bashrc to avoid leak of the secret
in your bash history
note: the 'export ...' should be placed in your bashrc to avoid any leak
of the secret in your bash history
EOF
)
echo -e "$help"
echo -e "$help"
}
function assert_defined(){
@@ -57,7 +58,7 @@ function assert_defined(){
# .Net build
function build_dotnet() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/dotnet_build" -; then
echo "build .Net up to date!"
echo "build .Net up to date!" | tee -a build.log
return 0
fi
@@ -92,6 +93,7 @@ function build_dotnet() {
#cmake --build temp_dotnet --target test
#echo "cmake test: DONE" | tee -a build.log
# copy nupkg to export
cp temp_dotnet/dotnet/packages/*nupkg export/
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/dotnet_build"
}
@@ -127,14 +129,18 @@ function build_java() {
# Install Java GPG
echo -n "Install Java GPG..." | tee -a build.log
$OPENSSL_PRG aes-256-cbc -iter 42 -pass pass:"$ORTOOLS_TOKEN" -in tools/release/private-key.gpg.enc -out private-key.gpg -d
$OPENSSL_PRG aes-256-cbc -iter 42 -pass pass:"$ORTOOLS_TOKEN" \
-in tools/release/private-key.gpg.enc \
-out private-key.gpg -d
gpg --batch --import private-key.gpg
# Don't need to trust the key
#expect -c "spawn gpg --edit-key "corentinl@google.com" trust quit; send \"5\ry\r\"; expect eof"
# Install the maven settings.xml having the GPG passphrase
mkdir -p ~/.m2
$OPENSSL_PRG aes-256-cbc -iter 42 -pass pass:"$ORTOOLS_TOKEN" -in tools/release/settings.xml.enc -out ~/.m2/settings.xml -d
$OPENSSL_PRG aes-256-cbc -iter 42 -pass pass:"$ORTOOLS_TOKEN" \
-in tools/release/settings.xml.enc \
-out ~/.m2/settings.xml -d
echo "DONE" | tee -a build.log
# Clean java
@@ -159,6 +165,7 @@ function build_java() {
#cmake --build temp_java --target test
#echo "cmake test: DONE" | tee -a build.log
# copy jar to export
cp temp_java/java/ortools-linux-x86-64/target/*.jar* export/
cp temp_java/java/ortools-java/target/*.jar* export/
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/java_build"
@@ -217,7 +224,8 @@ function build_archive() {
make archive_java
echo "DONE" | tee -a build.log
# TODO(user) copy archives to export/
# move archive to export
mv or-tools_*.tar.gz export/
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/archive_build"
}
@@ -242,20 +250,20 @@ function build_examples() {
make dotnet_examples_archive UNIX_PYTHON_VER=3
echo "DONE" | tee -a build.log
# TODO(user) copy example to export/
# move example to export/
mv or-tools_*_examples_*.tar.gz export/
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/examples_build"
}
# Main
function main() {
case ${1} in
-h | --help)
-h | --help | help)
help; exit ;;
esac
assert_defined ORTOOLS_TOKEN
echo "ORTOOLS_TOKEN: FOUND" | tee -a build.log
make print-OR_TOOLS_VERSION | tee -a build.log
local -r ROOT_DIR="$(cd -P -- "$(dirname -- "$0")/../.." && pwd -P)"
echo "ROOT_DIR: '${ROOT_DIR}'" | tee -a build.log
@@ -263,8 +271,11 @@ function main() {
local -r RELEASE_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
echo "RELEASE_DIR: '${RELEASE_DIR}'" | tee -a build.log
(cd "${ROOT_DIR}" && make print-OR_TOOLS_VERSION | tee -a build.log)
local -r ORTOOLS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
local -r ORTOOLS_SHA1=$(git rev-parse --verify HEAD)
mkdir -p export
case ${1} in
@@ -279,7 +290,7 @@ function main() {
build_examples
exit ;;
*)
>&2 echo "Target '${1}' unknown" | tee -a build.log
>&2 echo "Target '${1}' unknown"
exit 1
esac
exit 0

View File

@@ -22,11 +22,11 @@ function help() {
${BOLD}NAME${RESET}
\t$NAME - Build delivery using the ${BOLD}local host system${RESET}.
${BOLD}SYNOPSIS${RESET}
\t$NAME [-h|--help] [examples|dotnet|java|python|all|reset]
\t$NAME [-h|--help|help] [examples|dotnet|java|python|all|reset]
${BOLD}DESCRIPTION${RESET}
\tBuild Google OR-Tools deliveries.
\tYou ${BOLD}MUST${RESET} define the following variables before running this script:
\t* ORTOOLS_TOKEN: secret use to decrypt key to sign .Net and Java package.
\t* ORTOOLS_TOKEN: secret use to decrypt keys to sign .Net and Java packages.
${BOLD}OPTIONS${RESET}
\t-h --help: display this help text
@@ -85,9 +85,10 @@ function build_dotnet() {
cmake -S. -Btemp_dotnet -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOTNET=ON
cmake --build temp_dotnet -j8 -v
echo "DONE" | tee -a build.log
#cmake --build build --target test
#cmake --build temp_dotnet --target test
#echo "cmake test: DONE" | tee -a build.log
# copy nupkg to export
cp temp_dotnet/dotnet/packages/*nupkg export/
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/dotnet_build"
}
@@ -107,13 +108,9 @@ function build_java() {
exit 1
else
echo "JAVA_HOME: ${JAVA_HOME}" | tee -a build.log
command -v java
command -v java | xargs echo "java: " | tee -a build.log
command -v javac
command -v javac | xargs echo "javac: " | tee -a build.log
command -v jar
command -v jar | xargs echo "jar: " | tee -a build.log
command -v mvn
command -v mvn | xargs echo "mvn: " | tee -a build.log
java -version 2>&1 | head -n 1 | grep 1.8
fi
@@ -146,12 +143,14 @@ function build_java() {
echo "DONE" | tee -a build.log
echo -n "Build Java..." | tee -a build.log
cmake -S. -Btemp_java -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_JAVA=ON -DSKIP_GPG=OFF
cmake -S. -Btemp_java -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF \
-DBUILD_JAVA=ON -DSKIP_GPG=OFF
cmake --build temp_java -j8 -v
echo "DONE" | tee -a build.log
#cmake --build temp_java --target test
#echo "cmake test: DONE" | tee -a build.log
# copy jar to export
cp temp_java/java/ortools-darwin-x86-64/target/*.jar* export/
cp temp_java/java/ortools-java/target/*.jar* export/
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/java_build"
@@ -224,6 +223,7 @@ function build_archive() {
make archive_java
echo "DONE" | tee -a build.log
# move archive to export
mv or-tools_*.tar.gz export/
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/archive_build"
}
@@ -240,15 +240,16 @@ function build_examples() {
rm -rf temp ./*.tar.gz
echo -n "Build examples archives..." | tee -a build.log
echo -n " C++ examples archive..." | tee -a build.log
make cc_examples_archive UNIX_PYTHON_VER=3.9
make cc_examples_archive UNIX_PYTHON_VER=3
echo -n " Python examples archive..." | tee -a build.log
make python_examples_archive UNIX_PYTHON_VER=3.9
make python_examples_archive UNIX_PYTHON_VER=3
echo -n " Java examples archive..." | tee -a build.log
make java_examples_archive UNIX_PYTHON_VER=3.9
make java_examples_archive UNIX_PYTHON_VER=3
echo -n " .Net examples archive..." | tee -a build.log
make dotnet_examples_archive UNIX_PYTHON_VER=3.9
make dotnet_examples_archive UNIX_PYTHON_VER=3
echo "DONE" | tee -a build.log
# move example to export/
mv or-tools_*_examples_*.tar.gz export/
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/examples_build"
}
@@ -256,13 +257,12 @@ function build_examples() {
# Main
function main() {
case ${1} in
-h | --help)
-h | --help | help)
help; exit ;;
esac
assert_defined ORTOOLS_TOKEN
echo "ORTOOLS_TOKEN: FOUND" | tee build.log
make print-OR_TOOLS_VERSION | tee -a build.log
echo "ORTOOLS_TOKEN: FOUND" | tee -a build.log
local -r ROOT_DIR="$(cd -P -- "$(dirname -- "$0")/../.." && pwd -P)"
echo "ROOT_DIR: '${ROOT_DIR}'" | tee -a build.log
@@ -270,10 +270,13 @@ function main() {
local -r RELEASE_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
echo "RELEASE_DIR: '${RELEASE_DIR}'" | tee -a build.log
(cd "${ROOT_DIR}" && make print-OR_TOOLS_VERSION | tee -a build.log)
local -r ORTOOLS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
local -r ORTOOLS_SHA1=$(git rev-parse --verify HEAD)
mkdir -p export
case ${1} in
dotnet|java|python|archive|examples)
"build_$1"
@@ -286,7 +289,7 @@ function main() {
build_examples
exit ;;
*)
>&2 echo "Target '${1}' unknown" | tee -a build.log
>&2 echo "Target '${1}' unknown"
exit 1
esac
exit 0

View File

@@ -0,0 +1,243 @@
#!/usr/bin/env bash
# Copyright 2010-2022 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eo pipefail
function help() {
local -r NAME=$(basename "$0")
local -r BOLD="\e[1m"
local -r RESET="\e[0m"
local -r help=$(cat << EOF
${BOLD}NAME${RESET}
\t$NAME - Build delivery using an ${BOLD}manylinux2014 docker image${RESET}.
${BOLD}SYNOPSIS${RESET}
\t$NAME [-h|--help|help] [examples|dotnet|java|python|all|reset]
${BOLD}DESCRIPTION${RESET}
\tBuild Google OR-Tools deliveries.
\tYou ${BOLD}MUST${RESET} define the following variables before running this script:
\t* ORTOOLS_TOKEN: secret use to decrypt keys to sign .Net and Java packages.
${BOLD}OPTIONS${RESET}
\t-h --help: display this help text
\tdotnet: build all .Net packages
\tjava: build all Java packages
\tpython: build all Pyhon packages
\texamples: build examples archives
\tall: build everything (default)
${BOLD}EXAMPLES${RESET}
Using export to define the ${BOLD}ORTOOLS_TOKEN${RESET} env and only building the Java packages:
export ORTOOLS_TOKEN=SECRET
$0 java
note: the 'export ...' should be placed in your bashrc to avoid any leak
of the secret in your bash history
EOF
)
echo -e "$help"
}
function assert_defined(){
if [[ -z "${!1}" ]]; then
>&2 echo "Variable '${1}' must be defined"
exit 1
fi
}
function build_delivery() {
assert_defined ORTOOLS_BRANCH
assert_defined ORTOOLS_SHA1
assert_defined ORTOOLS_TOKEN
assert_defined ORTOOLS_DELIVERY
assert_defined DOCKERFILE
assert_defined ORTOOLS_IMG
# Clean
echo -n "Remove previous docker images..." | tee -a "${ROOT_DIR}/build.log"
docker image rm -f "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" 2>/dev/null
docker image rm -f "${ORTOOLS_IMG}":devel 2>/dev/null
docker image rm -f "${ORTOOLS_IMG}":env 2>/dev/null
echo "DONE" | tee -a "${ROOT_DIR}/build.log"
cd "${RELEASE_DIR}" || exit 2
# Build env
echo -n "Build ${ORTOOLS_IMG}:env..." | tee -a "${ROOT_DIR}/build.log"
docker build \
--tag "${ORTOOLS_IMG}":env \
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
--target=env \
-f "${DOCKERFILE}" .
echo "DONE" | tee -a "${ROOT_DIR}/build.log"
# Build devel
echo -n "Build ${ORTOOLS_IMG}:devel..." | tee -a "${ROOT_DIR}/build.log"
docker build \
--tag "${ORTOOLS_IMG}":devel \
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
--target=devel \
-f "${DOCKERFILE}" .
echo "DONE" | tee -a "${ROOT_DIR}/build.log"
# Build delivery
echo -n "Build ${ORTOOLS_IMG}:${ORTOOLS_DELIVERY}..." | tee -a "${ROOT_DIR}/build.log"
docker build \
--tag "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" \
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
--build-arg ORTOOLS_TOKEN="${ORTOOLS_TOKEN}" \
--build-arg ORTOOLS_DELIVERY="${ORTOOLS_DELIVERY}" \
--target=delivery \
-f "${DOCKERFILE}" .
echo "DONE" | tee -a "${ROOT_DIR}/build.log"
}
# .Net build
function build_dotnet() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/amd64_dotnet_build" -; then
echo "build .Net up to date!" | tee -a build.log
return 0
fi
assert_defined ORTOOLS_IMG
local -r ORTOOLS_DELIVERY=dotnet
build_delivery
# copy nupkg to export
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-u "$(id -u "${USER}")":"$(id -g "${USER}")" \
-t "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" "cp export/*nupkg /export/"
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/amd64_dotnet_build"
}
# Java build
function build_java() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/amd64_java_build" -; then
echo "build Java up to date!" | tee -a build.log
return 0
fi
assert_defined ORTOOLS_IMG
local -r ORTOOLS_DELIVERY=java
build_delivery
# copy .jar to export
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-u "$(id -u "${USER}")":"$(id -g "${USER}")" \
-t "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" "cp export/*.jar* /export/"
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/amd64_java_build"
}
# Python build
function build_python() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/amd64_python_build" -; then
echo "build python up to date!" | tee -a build.log
return 0
fi
local -r ORTOOLS_DELIVERY=python
build_delivery
# copy .whl to export
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-u "$(id -u "${USER}")":"$(id -g "${USER}")" \
-t "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" "cp export/*.whl /export/"
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/amd64_python_build"
}
# Create Archive
function build_archive() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/amd64_archive_build" -; then
echo "build archive up to date!" | tee -a build.log
return 0
fi
local -r ORTOOLS_DELIVERY=archive
build_delivery
# copy archive to export
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-u "$(id -u "${USER}")":"$(id -g "${USER}")" \
-t "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" "cp export/*.tar.gz /export/"
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/amd64_archive_build"
}
# Build Examples
function build_examples() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/amd64_examples_build" -; then
echo "build examples up to date!" | tee -a build.log
return 0
fi
local -r ORTOOLS_DELIVERY=examples
build_delivery
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/amd64_examples_build"
}
# Main
function main() {
case ${1} in
-h | --help | help)
help; exit ;;
esac
assert_defined ORTOOLS_TOKEN
echo "ORTOOLS_TOKEN: FOUND" | tee -a build.log
local -r ROOT_DIR="$(cd -P -- "$(dirname -- "$0")/../.." && pwd -P)"
echo "ROOT_DIR: '${ROOT_DIR}'" | tee -a build.log
local -r RELEASE_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
echo "RELEASE_DIR: '${RELEASE_DIR}'" | tee -a build.log
(cd "${ROOT_DIR}" && make print-OR_TOOLS_VERSION | tee -a build.log)
local -r ORTOOLS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
local -r ORTOOLS_SHA1=$(git rev-parse --verify HEAD)
local -r DOCKERFILE="amd64.Dockerfile"
local -r ORTOOLS_IMG="ortools/manylinux_delivery_amd64"
mkdir -p export
case ${1} in
dotnet|java|python|archive|examples)
"build_$1"
exit ;;
all)
build_dotnet
build_java
#build_python
#build_archive
build_examples
exit ;;
*)
>&2 echo "Target '${1}' unknown"
exit 1
esac
exit 0
}
main "${1:-all}"

View File

@@ -0,0 +1,246 @@
#!/usr/bin/env bash
# Copyright 2010-2022 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eo pipefail
function help() {
local -r NAME=$(basename "$0")
local -r BOLD="\e[1m"
local -r RESET="\e[0m"
local -r help=$(cat << EOF
${BOLD}NAME${RESET}
\t$NAME - Build delivery using an ${BOLD}Centos 7 docker image${RESET}.
${BOLD}SYNOPSIS${RESET}
\t$NAME [-h|--help|help] [examples|dotnet|java|python|all|reset]
${BOLD}DESCRIPTION${RESET}
\tBuild Google OR-Tools deliveries.
\tYou ${BOLD}MUST${RESET} define the following variables before running this script:
\t* ORTOOLS_TOKEN: secret use to decrypt keys to sign .Net and Java packages.
${BOLD}OPTIONS${RESET}
\t-h --help: display this help text
\tdotnet: build all .Net packages
\tjava: build all Java packages
\tpython: build all Pyhon packages
\texamples: build examples archives
\tall: build everything (default)
${BOLD}EXAMPLES${RESET}
Using export to define the ${BOLD}ORTOOLS_TOKEN${RESET} env and only building the Java packages:
export ORTOOLS_TOKEN=SECRET
$0 java
note: the 'export ...' should be placed in your bashrc to avoid any leak
of the secret in your bash history
EOF
)
echo -e "$help"
}
function assert_defined(){
if [[ -z "${!1}" ]]; then
>&2 echo "Variable '${1}' must be defined"
exit 1
fi
}
function build_delivery() {
assert_defined ORTOOLS_BRANCH
assert_defined ORTOOLS_SHA1
assert_defined ORTOOLS_TOKEN
assert_defined ORTOOLS_DELIVERY
assert_defined DOCKERFILE
assert_defined ORTOOLS_IMG
# Enable docker over QEMU support
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# Clean
echo -n "Remove previous docker images..." | tee -a "${ROOT_DIR}/build.log"
docker image rm -f "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" 2>/dev/null
docker image rm -f "${ORTOOLS_IMG}":devel 2>/dev/null
docker image rm -f "${ORTOOLS_IMG}":env 2>/dev/null
echo "DONE" | tee -a "${ROOT_DIR}/build.log"
cd "${RELEASE_DIR}" || exit 2
# Build env
echo -n "Build ${ORTOOLS_IMG}:env..." | tee -a "${ROOT_DIR}/build.log"
docker build --platform linux/arm64 \
--tag "${ORTOOLS_IMG}":env \
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
--target=env \
-f "${DOCKERFILE}" .
echo "DONE" | tee -a "${ROOT_DIR}/build.log"
# Build devel
echo -n "Build ${ORTOOLS_IMG}:devel..." | tee -a "${ROOT_DIR}/build.log"
docker build --platform linux/arm64 \
--tag "${ORTOOLS_IMG}":devel \
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
--target=devel \
-f "${DOCKERFILE}" .
echo "DONE" | tee -a "${ROOT_DIR}/build.log"
# Build delivery
echo -n "Build ${ORTOOLS_IMG}:${ORTOOLS_DELIVERY}..." | tee -a "${ROOT_DIR}/build.log"
docker build --platform linux/arm64 \
--tag "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" \
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
--build-arg ORTOOLS_TOKEN="${ORTOOLS_TOKEN}" \
--build-arg ORTOOLS_DELIVERY="${ORTOOLS_DELIVERY}" \
--target=delivery \
-f "${DOCKERFILE}" .
echo "DONE" | tee -a "${ROOT_DIR}/build.log"
}
# .Net build
function build_dotnet() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/arm64_dotnet_build" -; then
echo "build .Net up to date!" | tee -a build.log
return 0
fi
assert_defined ORTOOLS_IMG
local -r ORTOOLS_DELIVERY=dotnet
build_delivery
# copy nupkg to export
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-u "$(id -u "${USER}")":"$(id -g "${USER}")" \
-t "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" "cp export/*nupkg /export/"
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/arm64_dotnet_build"
}
# Java build
function build_java() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/arm64_java_build" -; then
echo "build Java up to date!" | tee -a build.log
return 0
fi
assert_defined ORTOOLS_IMG
local -r ORTOOLS_DELIVERY=java
build_delivery
# copy .jar to export
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-u "$(id -u "${USER}")":"$(id -g "${USER}")" \
-t "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" "cp export/*.jar* /export/"
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/arm64_java_build"
}
# Python build
function build_python() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/arm64_python_build" -; then
echo "build python up to date!" | tee -a build.log
return 0
fi
local -r ORTOOLS_DELIVERY=python
build_delivery
# copy .whl to export
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-u "$(id -u "${USER}")":"$(id -g "${USER}")" \
-t "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" "cp export/*.whl /export/"
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/arm64_python_build"
}
# Create Archive
function build_archive() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/arm64_archive_build" -; then
echo "build archive up to date!" | tee -a build.log
return 0
fi
local -r ORTOOLS_DELIVERY=archive
build_delivery
# copy archive to export
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-u "$(id -u "${USER}")":"$(id -g "${USER}")" \
-t "${ORTOOLS_IMG}":"${ORTOOLS_DELIVERY}" "cp export/*.tar.gz /export/"
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/arm64_archive_build"
}
# Build Examples
function build_examples() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/amd64_examples_build" -; then
echo "build examples up to date!" | tee -a build.log
return 0
fi
local -r ORTOOLS_DELIVERY=examples
build_delivery
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/arm64_examples_build"
}
# Main
function main() {
case ${1} in
-h | --help | help)
help; exit ;;
esac
assert_defined ORTOOLS_TOKEN
echo "ORTOOLS_TOKEN: FOUND" | tee -a build.log
local -r ROOT_DIR="$(cd -P -- "$(dirname -- "$0")/../.." && pwd -P)"
echo "ROOT_DIR: '${ROOT_DIR}'" | tee -a build.log
local -r RELEASE_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
echo "RELEASE_DIR: '${RELEASE_DIR}'" | tee -a build.log
(cd "${ROOT_DIR}" && make print-OR_TOOLS_VERSION | tee -a build.log)
local -r ORTOOLS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
local -r ORTOOLS_SHA1=$(git rev-parse --verify HEAD)
local -r DOCKERFILE="arm64.Dockerfile"
local -r ORTOOLS_IMG="ortools/manylinux_delivery_arm64"
mkdir -p export
case ${1} in
dotnet|java|python|archive|examples)
"build_$1"
exit ;;
all)
build_dotnet
build_java
#build_python
#build_archive
build_examples
exit ;;
*)
>&2 echo "Target '${1}' unknown"
exit 1
esac
exit 0
}
main "${1:-all}"

View File

@@ -1,168 +0,0 @@
#!/usr/bin/env bash
# Copyright 2010-2022 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eo pipefail
function help() {
local -r NAME=$(basename "$0")
local -r BOLD="\e[1m"
local -r RESET="\e[0m"
local -r help=$(cat << EOF
${BOLD}NAME${RESET}
\t$NAME - Build delivery using an ${BOLD}Centos 7 docker image${RESET}.
${BOLD}SYNOPSIS${RESET}
\t$NAME [-h|--help] [examples|dotnet|java|python|all|reset]
${BOLD}DESCRIPTION${RESET}
\tBuild Google OR-Tools deliveries.
\tYou ${BOLD}MUST${RESET} define the following variables before running this script:
\t* ORTOOLS_TOKEN: secret use to decrypt keys to sign .Net and Java packages.
${BOLD}OPTIONS${RESET}
\t-h --help: display this help text
\tdotnet: build all .Net packages
\tjava: build all Java packages
\tpython: build all Pyhon packages
\texamples: build examples archives
\tall: build everything (default)
${BOLD}EXAMPLES${RESET}
Using export to define the ${BOLD}ORTOOLS_TOKEN${RESET} env and only building the Java packages:
export ORTOOLS_TOKEN=SECRET
$0 java
note: the 'export ...' should be placed in your bashrc to avoid any leak
of the secret in your bash history
EOF
)
echo -e "$help"
}
function assert_defined(){
if [[ -z "${!1}" ]]; then
>&2 echo "Variable '${1}' must be defined"
exit 1
fi
}
function build_delivery() {
assert_defined ORTOOLS_BRANCH
assert_defined ORTOOLS_SHA1
assert_defined ORTOOLS_TOKEN
assert_defined ORTOOLS_DELIVERY
# Clean
docker image rm -f ortools:linux_delivery 2>/dev/null
cd "${RELEASE_DIR}" || exit 2
# Build env
docker build --tag ortools/linux_delivery:env \
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
--target=env \
-f Dockerfile .
# Build devel
docker build --tag ortools/linux_delivery:devel \
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
--target=devel \
-f Dockerfile .
# Build delivery
docker build --tag ortools/linux_delivery:"${ORTOOLS_DELIVERY}" \
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
--build-arg ORTOOLS_TOKEN="${ORTOOLS_TOKEN}" \
--build-arg ORTOOLS_DELIVERY="${ORTOOLS_DELIVERY}" \
--target=delivery \
-f Dockerfile .
}
# .Net build
function build_dotnet() {
local -r ORTOOLS_DELIVERY=dotnet
build_delivery
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-t ortools/linux_delivery:dotnet "cp export/*nupkg /export/"
}
# Java build
function build_java() {
local -r ORTOOLS_DELIVERY=java
build_delivery
docker run --rm --init \
-w /root/or-tools \
-v "${ROOT_DIR}/export":/export \
-t ortools/linux_delivery:java "cp export/*.jar* /export/"
}
# Python build
function build_python() {
local -r ORTOOLS_DELIVERY=python
build_delivery
}
function build_archive() {
local -r ORTOOLS_DELIVERY=archive
build_delivery
}
function build_examples() {
local -r ORTOOLS_DELIVERY=examples
build_delivery
}
# Main
function main() {
case ${1} in
-h | --help)
help; exit ;;
esac
assert_defined ORTOOLS_TOKEN
echo "ORTOOLS_TOKEN: FOUND"
local -r ROOT_DIR="$(cd -P -- "$(dirname -- "$0")/../.." && pwd -P)"
echo "ROOT_DIR: '${ROOT_DIR}'"
local -r RELEASE_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
echo "RELEASE_DIR: '${RELEASE_DIR}'"
local -r ORTOOLS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
local -r ORTOOLS_SHA1=$(git rev-parse --verify HEAD)
mkdir -p export
case ${1} in
dotnet|java|python|archive|examples)
"build_$1"
exit ;;
all)
build_dotnet
build_java
#build_python
build_examples
exit ;;
*)
>&2 echo "Target '${1}' unknown"
exit 1
esac
exit 0
}
main "${1:-all}"

View File

@@ -233,7 +233,7 @@ echo Make java archive... | tee.exe -a build.log
make.exe archive_java WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo DONE | tee.exe -a build.log
for %%i in (or-tools_*VisualStudio2019-64bit*.zip) do (
for %%i in (or-tools_*VisualStudio*-64bit*.zip) do (
echo Move %%i to export... | tee.exe -a build.log
move %%i export\.
echo Move %%i to export...DONE | tee.exe -a build.log

View File

@@ -81,7 +81,6 @@ function publish_java() {
command -v gpg | xargs echo "gpg: " | tee -a build.log
echo -n "Publish native Java..." | tee -a publish.log
cmake --build temp_java --target java_native_deploy -v
echo "DONE" | tee -a publish.log

View File

@@ -78,7 +78,6 @@ function publish_java() {
command -v gpg | xargs echo "gpg: " | tee -a publish.log
echo -n "Publish native Java..." | tee -a publish.log
cmake --build temp_java --target java_native_deploy -v
echo "DONE" | tee -a publish.log

View File

@@ -82,9 +82,9 @@ which.exe java | tee.exe -a publish.log
which.exe mvn || exit 1
which.exe mvn | tee.exe -a publish.log
echo make publish_java: ... | tee.exe -a publish.log
echo make publish_java_runtime: ... | tee.exe -a publish.log
make.exe publish_java_runtime WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make publish_java: DONE | tee.exe -a publish.log
echo make publish_java_runtime: DONE | tee.exe -a publish.log
exit /B 0
:PUBLISH_PYTHON