TRAVIS DEPLOYER: Improve trigger conditions

* DPL_DEPLOY_TAG -- Control whether to trigger on release tag
* DPL_UPLOAD_{package}_{target} -- Toggle per target whether to upload a package
* Actually make negation accurate with target-specific vars
This commit is contained in:
mazmazz 2020-06-08 16:04:20 -04:00
parent 8c4930ca35
commit 06ddf5b7f7
4 changed files with 215 additions and 43 deletions

View file

@ -15,9 +15,9 @@ matrix:
- os: osx
osx_image: xcode11.5
env:
- DPL_UPLOAD_INSTALLER=1
- CFLAGS="-march=core2 -mtune=haswell"
- CXXFLAGS="-march=core2 -mtune=haswell"
- DPL_UPLOAD_INSTALLER_FTP="${DPL_UPLOAD_INSTALLER_FTP:-1}"
cache:
directories:
# Note: brew update cache (/usr/local/Homebrew) does not appear to be effective.
@ -49,29 +49,35 @@ matrix:
skip_cleanup: true
api_key: $DPL_GITHUB_TOKEN
file_glob: true
file: $TRAVIS_BUILD_DIR/build/deploy/**/*
file: $TRAVIS_BUILD_DIR/build/deploy-github/**/*
draft: true
on:
all_branches: true
condition: '"$__DPL_ENABLED" == "1"'
condition: >
"$__DPL_DISABLED" != "1" &&
"$__DPL_DISABLED_GITHUB" != "1" &&
("$__DPL_TRIGGERED" == "1" || "$DPL_FORCE_ON_GITHUB" == "1")
- provider: script
skip_cleanup: true
# relative to {repo_root}/build
script: bash ../travis/deployer_ftp.sh
on:
all_branches: true
condition: '"$__DPL_ENABLED" == "1"'
condition: >
"$__DPL_DISABLED" != "1" &&
"$__DPL_DISABLED_FTP" != "1" &&
("$__DPL_TRIGGERED" == "1" || "$DPL_FORCE_ON_FTP" == "1")
#Default: macOS 10.13 and Xcode 9.4.1
- os: windows
compiler: gcc
env:
- DPL_UPLOAD_ASSETS=1
- DPL_UPLOAD_INSTALLER=1
- CFLAGS="-march=nocona -mtune=haswell"
- CXXFLAGS="-march=nocona -mtune=haswell"
- WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow -Wno-error=format-truncation -Wno-error=stringop-overflow -Wno-error=stringop-truncation"
- GCC91=1
- PROGRAM_FILENAME=srb2win
- DPL_UPLOAD_ASSETS_FTP="${DPL_UPLOAD_ASSETS_FTP:-1}"
- DPL_UPLOAD_INSTALLER_FTP="${DPL_UPLOAD_INSTALLER_FTP:-1}"
cache:
directories:
- $HOME/AppData/Local/Temp/chocolatey
@ -82,22 +88,29 @@ matrix:
# https://unix.stackexchange.com/a/137322/107554
- $msys2 pacman --sync --clean --noconfirm
deploy:
- provider: releases
skip_cleanup: true
api_key: $DPL_GITHUB_TOKEN
file_glob: true
file: $TRAVIS_BUILD_DIR/build/deploy/**/*
draft: true
on:
all_branches: true
condition: '"$__DPL_ENABLED" == "1"'
# currently not supported on travis windows
# - provider: releases
# skip_cleanup: true
# api_key: $DPL_GITHUB_TOKEN
# file_glob: true
# file: $TRAVIS_BUILD_DIR/build/deploy-github/**/*
# draft: true
# on:
# all_branches: true
# condition: >
# "$__DPL_DISABLED" != "1" &&
# "$__DPL_DISABLED_GITHUB" != "1" &&
# ("$__DPL_TRIGGERED" == "1" || "$DPL_FORCE_ON_GITHUB" == "1")
- provider: script
skip_cleanup: true
# relative to {repo_root}/build
script: bash ../travis/deployer_ftp.sh
on:
all_branches: true
condition: '"$__DPL_ENABLED" == "1"'
condition: >
"$__DPL_DISABLED" != "1" &&
"$__DPL_DISABLED_FTP" != "1" &&
("$__DPL_TRIGGERED" == "1" || "$DPL_FORCE_ON_FTP" == "1")
#Windows Server version 1809, mingw-w64-i686-gcc-10.1.0-3
- os: linux
addons:
@ -119,23 +132,30 @@ matrix:
- CXXFLAGS="-march=nocona -mtune=haswell"
- WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow -Wno-error=format-truncation"
- GCC81=1
- DPL_UPLOAD_ASSETS_FTP="${DPL_UPLOAD_ASSETS_FTP:-1}"
deploy:
- provider: releases
skip_cleanup: true
api_key: $DPL_GITHUB_TOKEN
file_glob: true
file: $TRAVIS_BUILD_DIR/build/deploy/**/*
file: $TRAVIS_BUILD_DIR/build/deploy-github/**/*
draft: true
on:
all_branches: true
condition: '"$__DPL_ENABLED" == "1"'
condition: >
"$__DPL_DISABLED" != "1" &&
"$__DPL_DISABLED_GITHUB" != "1" &&
("$__DPL_TRIGGERED" == "1" || "$DPL_FORCE_ON_GITHUB" == "1")
- provider: script
skip_cleanup: true
# relative to {repo_root}/build
script: bash ../travis/deployer_ftp.sh
on:
all_branches: true
condition: '"$__DPL_ENABLED" == "1"'
condition: >
"$__DPL_DISABLED" != "1" &&
"$__DPL_DISABLED_FTP" != "1" &&
("$__DPL_TRIGGERED" == "1" || "$DPL_FORCE_ON_FTP" == "1")
#gcc-8 (Ubuntu 7.2.0-1ubuntu1~14.04) 8.1.0
################################
# Non-Deploying Buildbots

View file

@ -13,11 +13,18 @@
: ${DPL_FORCE_OFF} # Force-disable Deployer for tags
: ${DPL_FORCE_OFF_GITHUB} # Force-disable Deployer for GitHub Releases
: ${DPL_FORCE_OFF_FTP} # Force-disable Deployer for FTP
: ${DPL_DEPLOY_TAG:=1} # Trigger Deployer on a release tag
: ${DPL_BRANCH_TRIGGER:=deployer} # Use a word in the branch name to trigger Deployer
: ${DPL_COMMIT_TRIGGER:=deployer} # Use a [word] in the commit message to trigger Deployer
: ${DPL_UPLOAD_BINARY:=1} # Upload an archive containing the binary file plus $ASSET_FILES_DOCS
: ${DPL_UPLOAD_BINARY_GITHUB} # Upload an archive containing the binary file plus $ASSET_FILES_DOCS for GitHub Releases
: ${DPL_UPLOAD_BINARY_FTP} # Upload an archive containing the binary file plus $ASSET_FILES_DOCS for FTP
: ${DPL_UPLOAD_ASSETS} # Upload an archive containing the binary file plus $ASSET_FILES_DOCS plus all other assets
: ${DPL_UPLOAD_ASSETS_GITHUB} # Upload an archive containing the binary file plus $ASSET_FILES_DOCS plus all other assets for GitHub Releases
: ${DPL_UPLOAD_ASSETS_FTP} # Upload an archive containing the binary file plus $ASSET_FILES_DOCS plus all other assets for FTP
: ${DPL_UPLOAD_INSTALLER} # Upload an archive containing an installer
: ${DPL_UPLOAD_INSTALLER_GITHUB} # Upload an archive containing an installer for GitHub Releases
: ${DPL_UPLOAD_INSTALLER_FTP} # Upload an archive containing an installer for FTP
: ${DPL_ARCHIVE_NAME} # Name to use for deployed archives. Defaults to $TRAVIS_TAG-$TRAVIS_OS_NAME or "srb2$TRAVIS_OS_NAME-$TRAVIS_BRANCH-${TRAVIS_COMMIT:0:8}-${TRAVIS_JOB_ID}"
# Asset File Parameters

View file

@ -4,32 +4,161 @@
# Pre-Deployment Script
# Determine whether we are deploying this job.
if [[ ("$DPL_GITHUB_TOKEN" != "" &&
"$TRAVIS_PULL_REQUEST" == "false" &&
"$DPL_FORCE_OFF" != "1" &&
!("$DPL_FORCE_OFF_GITHUB" == "1" &&
"$DPL_FORCE_OFF_FTP" == "1") &&
(
"$DPL_FORCE_ON" = "1" ||
"$DPL_FORCE_ON_GITHUB" = "1" ||
"$DPL_FORCE_ON_FTP" = "1" ||
"$TRAVIS_TAG" != "" ||
"$TRAVIS_BRANCH" =~ ^.*$DPL_BRANCH_TRIGGER.*$ ||
"$TRAVIS_COMMIT_MESSAGE" =~ ^.*\[$DPL_COMMIT_TRIGGER\].*$
)) ]]; then
__DPL_ENABLED=1;
# This does not include target-specific conditions.
#
# The concept is:
# DPL_DISABLED conditions take highest priority.
# DPL_TRIGGERED indicates whether a deployment is triggered by tag, branch, or message
# DPL_FORCE_ENABLED can be true if the user specifies DPL_FORCE_ON despite a trigger not occurring
########################################
# DPL_DISABLED Conditions
########################################
if [[ ("$DPL_GITHUB_TOKEN" == "" || "$DPL_FORCE_OFF_GITHUB" == "1" ) ]]; then
__DPL_DISABLED_GITHUB=1;
DPL_UPLOAD_BINARY_GITHUB=0;
DPL_UPLOAD_ASSETS_GITHUB=0;
DPL_UPLOAD_INSTALLER_GITHUB=0;
DPL_FORCE_ON_GITHUB=0;
fi;
if [[ ("$DPL_FTP_USER" == "" ||
"$DPL_FTP_PASS" == "" ||
"$DPL_FTP_HOSTNAME" == "" ||
"$DPL_FORCE_OFF_FTP" == "1"
) ]]; then
__DPL_DISABLED_FTP=1;
DPL_UPLOAD_BINARY_FTP=0;
DPL_UPLOAD_ASSETS_FTP=0;
DPL_UPLOAD_INSTALLER_FTP=0;
DPL_FORCE_ON_FTP=0;
fi;
if [[ ("$DPL_FORCE_OFF" == "1" || "$TRAVIS_PULL_REQUEST" != "false" ||
("$__DPL_DISABLED_FTP" == "1" && "$__DPL_DISABLED_GITHUB" == "1")
) ]]; then
__DPL_DISABLED=1;
fi;
########################################
# DPL_TRIGGERED Conditions
########################################
if [[ ("$DPL_DISABLED" != "1" &&
("$DPL_FORCE_ON" == "1" ||
("$TRAVIS_TAG" != "" && "$DPL_DEPLOY_TAG" != "1") ||
"$TRAVIS_BRANCH" =~ ^.*$DPL_BRANCH_TRIGGER.*$ ||
"$TRAVIS_COMMIT_MESSAGE" =~ ^.*\[$DPL_COMMIT_TRIGGER\].*$
)
) ]]; then
__DPL_TRIGGERED=1;
fi;
########################################
# DPL_FORCE_ENABLED Conditions
########################################
if [[ ("$DPL_DISABLED" != "1" &&
("$DPL_FORCE_ON" == "1" || "$DPL_FORCE_ON_GITHUB" == "1" || "$DPL_FORCE_ON_FTP" == "1")
) ]]; then
__DPL_FORCE_ENABLED=1;
fi;
if [[ ("$__DPL_TRIGGERED" == "1" || "$__DPL_FORCE_ENABLED" == "1") ]]; then
__DPL_TRIGGERED_OR_FORCED=1;
fi;
########################################
# Package Generation Rules
########################################
# This monstrosity accounts for negating rules when, e.g.,
# DPL_UPLOAD_BINARY is true but DPL_UPLOAD_BINARY_GITHUB and/or DPL_UPLOAD_BINARY_FTP are explicitly false.
#
# DPL_UPLOAD_BINARY=1 applies to all targets, but you can negate the target by setting 0.
# DPL_UPLOAD_BINARY=0 can be overridden by setting the target to 1.
# An empty target setting means "do not override".
if [[ ("$__DPL_TRIGGERED_OR_FORCED" == "1" &&
("$DPL_UPLOAD_BINARY_GITHUB" == "1" ||
"$DPL_UPLOAD_BINARY_FTP" == "1" ||
("$DPL_UPLOAD_BINARY" == "1" &&
! ("$DPL_UPLOAD_BINARY_GITHUB" == "0" && "$DPL_UPLOAD_BINARY_FTP" == "0")
)
)
) ]]; then
__DPL_UPLOAD_BINARY=1;
if [[ ("$DPL_UPLOAD_BINARY_GITHUB" == "1" ||
("$DPL_UPLOAD_BINARY" == "1" && "$DPL_UPLOAD_BINARY_GITHUB" != "0")
) ]]; then
__DPL_UPLOAD_BINARY_GITHUB=1;
fi;
if [[ ("$DPL_UPLOAD_BINARY_FTP" == "1" ||
("$DPL_UPLOAD_BINARY" == "1" && "$DPL_UPLOAD_BINARY_FTP" != "0")
) ]]; then
__DPL_UPLOAD_BINARY_FTP=1;
fi;
fi;
if [[ ("$__DPL_TRIGGERED_OR_FORCED" == "1" &&
("$DPL_UPLOAD_ASSETS_GITHUB" == "1" ||
"$DPL_UPLOAD_ASSETS_FTP" == "1" ||
("$DPL_UPLOAD_ASSETS" == "1" &&
! ("$DPL_UPLOAD_ASSETS_GITHUB" == "0" && "$DPL_UPLOAD_ASSETS_FTP" == "0")
)
)
) ]]; then
__DPL_UPLOAD_ASSETS=1;
if [[ ("$DPL_UPLOAD_ASSETS_GITHUB" == "1" ||
("$DPL_UPLOAD_ASSETS" == "1" && "$DPL_UPLOAD_ASSETS_GITHUB" != "0")
) ]]; then
__DPL_UPLOAD_ASSETS_GITHUB=1;
fi;
if [[ ("$DPL_UPLOAD_ASSETS_FTP" == "1" ||
("$DPL_UPLOAD_ASSETS" == "1" && "$DPL_UPLOAD_ASSETS_FTP" != "0")
) ]]; then
__DPL_UPLOAD_ASSETS_FTP=1;
fi;
fi;
if [[ ("$__DPL_TRIGGERED_OR_FORCED" == "1" &&
("$DPL_UPLOAD_INSTALLER_GITHUB" == "1" ||
"$DPL_UPLOAD_INSTALLER_FTP" == "1" ||
("$DPL_UPLOAD_INSTALLER" == "1" &&
! ("$DPL_UPLOAD_INSTALLER_GITHUB" == "0" && "$DPL_UPLOAD_INSTALLER_FTP" == "0")
)
)
) ]]; then
__DPL_UPLOAD_INSTALLER=1;
if [[ ("$DPL_UPLOAD_INSTALLER_GITHUB" == "1" ||
("$DPL_UPLOAD_INSTALLER" == "1" && "$DPL_UPLOAD_INSTALLER_GITHUB" != "0")
) ]]; then
__DPL_UPLOAD_INSTALLER_GITHUB=1;
fi;
if [[ ("$DPL_UPLOAD_INSTALLER_FTP" == "1" ||
("$DPL_UPLOAD_INSTALLER" == "1" && "$DPL_UPLOAD_INSTALLER_FTP" != "0")
) ]]; then
__DPL_UPLOAD_INSTALLER_FTP=1;
fi;
fi;
########################################
# Procedure
########################################
# On OSX, use sudo to make packages
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
__MAKE="sudo make";
__RM="sudo rm";
__MV="sudo mv";
__CP="sudo cp";
else
__RM="rm";
__MV="mv";
__CP="cp";
fi;
mkdir deploy-github;
mkdir deploy-ftp;
# Construct our package name
if [[ "$DPL_PACKAGE_NAME" == "" ]]; then
if [[ "$TRAVIS_TAG" != "" ]]; then
@ -41,11 +170,9 @@ fi;
# As-is tradition, generate 7Z archives for Windows.
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
__CPACK_GENERATOR="7Z"
__CPACK_GENERATOR="7Z";
fi;
mkdir deploy;
# Use CMAKE to build no-asset and asset packages.
# NOTE: When specifying an archive generator (ZIP, TGZ, 7Z), the filename
# should be specified by CPACK_ARCHIVE_FILE_NAME, but currently the effective
@ -53,36 +180,54 @@ mkdir deploy;
# https://gitlab.kitware.com/cmake/cmake/-/issues/20419
# Build no-asset package
if [[ "$__DPL_ENABLED" == "1" ]] && [[ "$DPL_UPLOAD_BINARY" == "1" ]]; then
if [[ "$__DPL_UPLOAD_BINARY" == "1" ]]; then
cmake .. -DSRB2_ASSET_INSTALL=OFF -DSRB2_DEBUG_INSTALL=ON -DSRB2_CPACK_GENERATOR="${__CPACK_GENERATOR}" -DCPACK_PACKAGE_FILE_NAME="${DPL_PACKAGE_NAME}-no-assets";
$__MAKE -k package;
if [ -d "package/_CPack_Packages" ]; then
$__RM -r package/_CPack_Packages;
fi;
$__MV package/* deploy/;
if [[ "$__DPL_UPLOAD_BINARY_GITHUB" == "1" ]]; then
$__CP package/* deploy-github/;
fi;
if [[ "$__DPL_UPLOAD_BINARY_FTP" == "1" ]]; then
$__CP package/* deploy-ftp/;
fi;
$__RM -r package;
fi;
# Build package including binary and assets
if [[ "$__DPL_ENABLED" == "1" ]] && [[ "$DPL_UPLOAD_ASSETS" == "1" ]]; then
if [[ "$__DPL_UPLOAD_ASSETS" == "1" ]]; then
cmake .. -DSRB2_ASSET_INSTALL=ON -DSRB2_DEBUG_INSTALL=ON -DSRB2_CPACK_GENERATOR="${__CPACK_GENERATOR}" -DCPACK_PACKAGE_FILE_NAME="${DPL_PACKAGE_NAME}";
$__MAKE -k package;
if [ -d "package/_CPack_Packages" ]; then
$__RM -r package/_CPack_Packages;
fi;
$__MV package/* deploy/;
if [[ "$__DPL_UPLOAD_ASSETS_GITHUB" == "1" ]]; then
$__CP package/* deploy-github/;
fi;
if [[ "$__DPL_UPLOAD_ASSETS_FTP" == "1" ]]; then
$__CP package/* deploy-ftp/;
fi;
$__RM -r package;
fi;
# Build installer
# We expect the filetype to be different than the asset package, above.
# For now, only build for OSX.
if [[ "$__DPL_ENABLED" == "1" ]] && [[ "$DPL_UPLOAD_INSTALLER" == "1" ]]; then
if [[ "$__DPL_UPLOAD_INSTALLER" == "1" ]]; then
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
cmake .. -DSRB2_ASSET_INSTALL=ON -DSRB2_DEBUG_INSTALL=OFF -DSRB2_CPACK_GENERATOR=DragNDrop -DCPACK_PACKAGE_FILE_NAME="${DPL_PACKAGE_NAME}";
$__MAKE -k package;
if [ -d "package/_CPack_Packages" ]; then
$__RM -r package/_CPack_Packages;
fi;
$__MV package/* deploy/;
if [[ "$__DPL_UPLOAD_INSTALLER_GITHUB" == "1" ]]; then
$__CP package/* deploy-github/;
fi;
if [[ "$__DPL_UPLOAD_INSTALLER_FTP" == "1" ]]; then
$__CP package/* deploy-ftp/;
fi;
$__RM -r package;
else
echo "Building an installer is not supported on $TRAVIS_OS_NAME.";
fi;

View file

@ -48,7 +48,7 @@ echo "Uploading to FTP...";
curl --ftp-create-dirs -T "commit.txt" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/commit.txt";
if [[ "$__DPL_DEBIAN_ACTIVE" != "1" ]]; then
find deploy -type f -exec curl -u $DPL_FTP_USER:$DPL_FTP_PASS --ftp-create-dirs -T {} $__DPL_FTP_LOCATION/{} \;;
find deploy-ftp -type f -exec curl -u $DPL_FTP_USER:$DPL_FTP_PASS --ftp-create-dirs -T {} $__DPL_FTP_LOCATION/ \;;
else
if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then
PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};