tools/release: cleanup

This commit is contained in:
Corentin Le Molgat
2025-06-11 08:13:52 +02:00
parent 03ef7e19a4
commit 92f78981b7
5 changed files with 136 additions and 8 deletions

View File

@@ -76,9 +76,9 @@ function publish_java() {
if [[ -x "$(command -v openssl11)" ]]; then
OPENSSL_PRG=openssl11
fi
command -v $OPENSSL_PRG | xargs echo "openssl: " | tee -a build.log
command -v $OPENSSL_PRG | xargs echo "openssl: " | tee -a publish.log
command -v gpg
command -v gpg | xargs echo "gpg: " | tee -a build.log
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

View File

@@ -109,7 +109,7 @@ function main() {
local -r RELEASE_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
echo "RELEASE_DIR: '${RELEASE_DIR}'" | tee -a publish.log
(cd "${ROOT_DIR}" && make print-OR_TOOLS_VERSION | tee -a build.log)
(cd "${ROOT_DIR}" && make print-OR_TOOLS_VERSION | tee -a publish.log)
local -r ORTOOLS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
local -r ORTOOLS_SHA1=$(git rev-parse --verify HEAD)
@@ -124,8 +124,9 @@ function main() {
"publish_$1"
exit ;;
all)
#publish_dotnet
publish_java
publish_python
#publish_python
exit ;;
*)
>&2 echo "Target '${1}' unknown"

View File

@@ -109,7 +109,7 @@ function main() {
local -r RELEASE_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
echo "RELEASE_DIR: '${RELEASE_DIR}'" | tee -a publish.log
(cd "${ROOT_DIR}" && make print-OR_TOOLS_VERSION | tee -a build.log)
(cd "${ROOT_DIR}" && make print-OR_TOOLS_VERSION | tee -a publish.log)
local -r ORTOOLS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
local -r ORTOOLS_SHA1=$(git rev-parse --verify HEAD)
@@ -124,8 +124,9 @@ function main() {
"publish_$1"
exit ;;
all)
#publish_dotnet
publish_java
publish_python
#publish_python
exit ;;
*)
>&2 echo "Target '${1}' unknown"

View File

@@ -0,0 +1,126 @@
#!/usr/bin/env bash
# Copyright 2010-2025 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 - Publish delivery using the ${BOLD}local host system${RESET}.
${BOLD}SYNOPSIS${RESET}
\t$NAME [-h|--help] [java]
${BOLD}DESCRIPTION${RESET}
\tPublish 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 Java package.
${BOLD}OPTIONS${RESET}
\t-h --help: display this help text
\tjava: publish the Java runtime packages
\tall: publish everything (default)
${BOLD}EXAMPLES${RESET}
Using export to define the ${BOLD}ORTOOLS_TOKEN${RESET} env and only publishing the Java packages:
export ORTOOLS_TOKEN=SECRET
$0 java
note: the 'export ORTOOLS_TOKEN=...' 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
}
# Java publish
function publish_java() {
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export_meta/meta_java_publish" -; then
echo "publish Java up to date!"
return 0
fi
# maven require JAVA_HOME
if [[ -z "${JAVA_HOME}" ]]; then
echo "JAVA_HOME: not found !" | tee publish.log
exit 1
else
echo "JAVA_HOME: ${JAVA_HOME}" | tee -a publish.log
command -v mvn
command -v mvn | xargs echo "mvn: " | tee -a publish.log
java -version 2>&1 | tee -a publish.log
java -version 2>&1 | head -n 1 | grep -q "1.8"
fi
# Maven central need gpg sign and we store the release key encoded using openssl
local OPENSSL_PRG=openssl
if [[ -x "$(command -v openssl11)" ]]; then
OPENSSL_PRG=openssl11
fi
command -v $OPENSSL_PRG | xargs echo "openssl: " | tee -a publish.log
command -v gpg
command -v gpg | xargs echo "gpg: " | tee -a publish.log
echo -n "Publish native Java..." | tee -a publish.log
cmake --build temp_meta_java --config Release --target java_deploy -v
echo "DONE" | tee -a publish.log
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export_meta/meta_java_publish"
}
# Main
function main() {
case ${1} in
-h | --help)
help; exit ;;
esac
assert_defined ORTOOLS_TOKEN
echo "ORTOOLS_TOKEN: FOUND" | tee publish.log
make print-OR_TOOLS_VERSION | tee -a publish.log
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)
local -r PLATFORM=$(uname -m)
mkdir -p export
case ${1} in
java)
"publish_$1"
exit ;;
all)
publish_java
exit ;;
*)
>&2 echo "Target '${1}' unknown"
exit 1
esac
exit 0
}
main "${1:-all}"

View File

@@ -83,9 +83,9 @@ which.exe mvn || exit 1
which.exe mvn | tee.exe -a publish.log
which.exe gpg || exit 1
which.exe gpg | tee.exe -a build.log
which.exe gpg | tee.exe -a publish.log
which.exe openssl || exit 1
which.exe openssl | tee.exe -a build.log
which.exe openssl | tee.exe -a publish.log
echo Publish native Java... | tee.exe -a publish.log
cmake --build temp_java --config Release --target java_native_deploy -v