|
@@ -21,16 +21,6 @@ autoload -Uz is-at-least && if ! is-at-least 5.2; then
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
-TRAPEXIT() {
|
|
|
- local return_value=$?
|
|
|
-
|
|
|
- if (( ${+CI} )) {
|
|
|
- unset NSUnbufferedIO
|
|
|
- }
|
|
|
-
|
|
|
- return ${return_value}
|
|
|
-}
|
|
|
-
|
|
|
TRAPZERR() {
|
|
|
if (( ${_loglevel:-3} > 2 )) {
|
|
|
print -u2 -PR "${CI:+::error::}%F{1} ✖︎ script execution error%f"
|
|
@@ -45,7 +35,7 @@ TRAPZERR() {
|
|
|
|
|
|
package() {
|
|
|
if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h}
|
|
|
- local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]}
|
|
|
+ local host_os='ubuntu'
|
|
|
local project_root=${SCRIPT_HOME:A:h:h}
|
|
|
local buildspec_file=${project_root}/buildspec.json
|
|
|
|
|
@@ -58,11 +48,11 @@ package() {
|
|
|
return 2
|
|
|
}
|
|
|
|
|
|
+ local -i debug=0
|
|
|
local -i verbosity=1
|
|
|
local -r _version='2.0.0'
|
|
|
local -r -a _valid_targets=(
|
|
|
- macos-universal
|
|
|
- linux-x86_64
|
|
|
+ ubuntu-x86_64
|
|
|
)
|
|
|
local target
|
|
|
local config='RelWithDebInfo'
|
|
@@ -72,15 +62,6 @@ package() {
|
|
|
local -i package=0
|
|
|
local -i skip_deps=0
|
|
|
|
|
|
- if [[ ${host_os} == macos ]] {
|
|
|
- local -r _usage_host="
|
|
|
-%F{yellow} Additional options for macOS builds%f
|
|
|
- -----------------------------------------------------------------------------
|
|
|
- %B-s | --codesign%b Enable codesigning (macOS only)
|
|
|
- %B-n | --notarize%b Enable notarization (macOS only)
|
|
|
- %B-p | --package%b Create package installer (macOS only)"
|
|
|
- }
|
|
|
-
|
|
|
local -r _usage="
|
|
|
Usage: %B${functrace[1]%:*}%b <option> [<options>]
|
|
|
|
|
@@ -166,104 +147,30 @@ ${_usage_host:-}"
|
|
|
read -r product_name product_version <<< \
|
|
|
"$(jq -r '. | {name, version} | join(" ")' ${buildspec_file})"
|
|
|
|
|
|
- if [[ ${host_os} == macos ]] {
|
|
|
- autoload -Uz check_packages read_codesign read_codesign_installer read_codesign_pass
|
|
|
-
|
|
|
- local output_name="${product_name}-${product_version}-${host_os}-universal"
|
|
|
-
|
|
|
- if [[ ! -d ${project_root}/release/${config}/${product_name}.plugin ]] {
|
|
|
- log_error 'No release artifact found. Run the build script or the CMake install procedure first.'
|
|
|
- return 2
|
|
|
- }
|
|
|
-
|
|
|
- local _tarflags='cJf'
|
|
|
- if (( _loglevel > 1 || ${+CI} )) _tarflags="v${_tarflags}"
|
|
|
-
|
|
|
- if (( package )) {
|
|
|
- if [[ ! -f ${project_root}/release/${config}/${product_name}.pkg ]] {
|
|
|
- log_error 'Installer Package not found. Run the build script or the CMake build and install procedures first.'
|
|
|
- return 2
|
|
|
- }
|
|
|
-
|
|
|
- log_group "Packaging ${product_name}..."
|
|
|
- pushd ${project_root}
|
|
|
-
|
|
|
- if (( codesign )) {
|
|
|
- read_codesign_installer
|
|
|
- productsign \
|
|
|
- --sign "${CODESIGN_IDENT_INSTALLER}" \
|
|
|
- ${project_root}/release/${config}/${product_name}.pkg \
|
|
|
- ${project_root}/release/${output_name}.pkg
|
|
|
+ local -a cmake_args=()
|
|
|
+ if (( _loglevel > 1 )) cmake_args+=(--verbose)
|
|
|
|
|
|
- rm ${project_root}/release/${config}/${product_name}.pkg
|
|
|
- } else {
|
|
|
- mv ${project_root}/release/${config}/${product_name}.pkg \
|
|
|
- ${project_root}/release/${output_name}.pkg
|
|
|
- }
|
|
|
+ log_group "Creating source tarball for ${product_name}..."
|
|
|
+ pushd ${project_root}
|
|
|
+ cmake --build build_${target##*-} --config ${config} -t package_source ${cmake_args}
|
|
|
+ popd
|
|
|
|
|
|
- if (( codesign && notarize )) {
|
|
|
- if [[ ! -f ${project_root}/release/${output_name}.pkg ]] {
|
|
|
- log_error "No package for notarization found."
|
|
|
- return 2
|
|
|
- }
|
|
|
-
|
|
|
- read_codesign_installer
|
|
|
- read_codesign_pass
|
|
|
-
|
|
|
- xcrun notarytool submit ${project_root}/release/${output_name}.pkg \
|
|
|
- --keychain-profile "OBS-Codesign-Password" --wait
|
|
|
-
|
|
|
- local -i _status=0
|
|
|
-
|
|
|
- xcrun stapler staple ${project_root}/release/${output_name}.pkg || _status=1
|
|
|
-
|
|
|
- if (( _status )) {
|
|
|
- log_error "Notarization failed. Use 'xcrun notarytool log <submission ID>' to check for errors."
|
|
|
- return 2
|
|
|
- }
|
|
|
- }
|
|
|
- popd
|
|
|
- } else {
|
|
|
- log_group "Archiving ${product_name}..."
|
|
|
- pushd ${project_root}/release/${config}
|
|
|
- XZ_OPT=-T0 tar "-${_tarflags}" ${project_root}/release/${output_name}.tar.xz ${product_name}.plugin
|
|
|
- popd
|
|
|
- }
|
|
|
-
|
|
|
- if [[ ${config} == Release ]] {
|
|
|
- log_group "Archiving ${product_name} Debug Symbols..."
|
|
|
- pushd ${project_root}/release/${config}
|
|
|
- XZ_OPT=-T0 tar "-${_tarflags}" ${project_root}/release/${output_name}-dSYMs.tar.xz ${product_name}.plugin.dSYM
|
|
|
- popd
|
|
|
- }
|
|
|
-
|
|
|
- log_group
|
|
|
- } elif [[ ${host_os} == linux ]] {
|
|
|
- local -a cmake_args=()
|
|
|
- if (( _loglevel > 1 )) cmake_args+=(--verbose)
|
|
|
-
|
|
|
- log_group "Creating source tarball for ${product_name}..."
|
|
|
+ if (( package )) {
|
|
|
+ log_group "Packaging ${product_name}..."
|
|
|
pushd ${project_root}
|
|
|
- cmake --build build_${target##*-} --config ${config} -t package_source ${cmake_args}
|
|
|
+ cmake --build build_${target##*-} --config ${config} -t package ${cmake_args}
|
|
|
popd
|
|
|
+ } else {
|
|
|
+ log_group "Archiving ${product_name}..."
|
|
|
+ local output_name="${product_name}-${product_version}-${target##*-}-ubuntu-gnu"
|
|
|
+ local _tarflags='cJf'
|
|
|
+ if (( _loglevel > 1 || ${+CI} )) _tarflags="v${_tarflags}"
|
|
|
|
|
|
- if (( package )) {
|
|
|
- log_group "Packaging ${product_name}..."
|
|
|
- pushd ${project_root}
|
|
|
- cmake --build build_${target##*-} --config ${config} -t package ${cmake_args}
|
|
|
- popd
|
|
|
- } else {
|
|
|
- log_group "Archiving ${product_name}..."
|
|
|
- local output_name="${product_name}-${product_version}-${target##*-}-linux-gnu"
|
|
|
- local _tarflags='cJf'
|
|
|
- if (( _loglevel > 1 || ${+CI} )) _tarflags="v${_tarflags}"
|
|
|
-
|
|
|
- pushd ${project_root}/release/${config}
|
|
|
- XZ_OPT=-T0 tar "-${_tarflags}" ${project_root}/release/${output_name}.tar.xz (lib|share)
|
|
|
- popd
|
|
|
- }
|
|
|
- log_group
|
|
|
+ pushd ${project_root}/release/${config}
|
|
|
+ XZ_OPT=-T0 tar "-${_tarflags}" ${project_root}/release/${output_name}.tar.xz (lib|share)
|
|
|
+ popd
|
|
|
}
|
|
|
+ log_group
|
|
|
}
|
|
|
|
|
|
package ${@}
|