diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000..b48538b --- /dev/null +++ b/.mailmap @@ -0,0 +1,2 @@ +Jack Yuan <55564584+yongleyuan@users.noreply.github.com> +Tobias Pietzsch diff --git a/UNLICENSE b/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/check-branch.sh b/check-branch.sh index 5dc57fe..fdbfc4c 100755 --- a/check-branch.sh +++ b/check-branch.sh @@ -10,7 +10,7 @@ remote=${remote#refs/remotes/} remote=${remote%%/*} headBranch=$(git remote show "$remote" | grep HEAD | sed 's/ *HEAD branch: //') -test "$commits" || commits=$(git rev-list HEAD "^$headBranch" | sed '1!G;h;$!d') +test "$commits" || commits=$(git rev-list HEAD "^$remote/$headBranch" | sed '1!G;h;$!d') # NB: The sed line above reverses the order of the commits. # See: http://stackoverflow.com/a/744093 @@ -24,7 +24,15 @@ do prefix="$(printf %04d $count)" filename="tmp/$prefix-$commit" start=$(date +%s) - mvn clean verify > "$filename" 2>&1 && result=SUCCESS || result=FAILURE + if [ -f Makefile ] + then + make test > "$filename" 2>&1 && result=SUCCESS || result=FAILURE + elif [ -f pom.xml ] + then + mvn clean verify > "$filename" 2>&1 && result=SUCCESS || result=FAILURE + else + result=SKIPPED + fi end=$(date +%s) time=$(expr "$end" - "$start") echo "$prefix $commit $result $time" diff --git a/ci-build.sh b/ci-build.sh index 5b5c1ab..8d68269 100755 --- a/ci-build.sh +++ b/ci-build.sh @@ -9,16 +9,42 @@ dir="$(dirname "$0")" -MACOS= -case "$(uname -s)" in - Darwin) MACOS=1;; -esac +platform=$(uname -s) success=0 checkSuccess() { # Log non-zero exit code. test $1 -eq 0 || echo "==> FAILED: EXIT CODE $1" 1>&2 + if [ $1 -ne 0 -a -f "$2" ] + then + # The operation failed and a log file was provided. + # Do some heuristics, because we like being helpful! + javadocErrors=$(grep error: "$2") + generalErrors=$(grep -i '\b\(errors\?\|fail\|failures\?\)\b' "$2") + if [ "$javadocErrors" ] + then + echo + echo '/----------------------------------------------------------\' + echo '| ci-build.sh analysis: I noticed probable javadoc errors: |' + echo '\----------------------------------------------------------/' + echo "$javadocErrors" + elif [ "$generalErrors" ] + then + echo + echo '/-------------------------------------------------------\' + echo '| ci-build.sh analysis: I noticed the following errors: |' + echo '\-------------------------------------------------------/' + echo "$generalErrors" + else + echo + echo '/----------------------------------------------------------------------\' + echo '| ci-build.sh analysis: I see no problems in the operation log. Sorry! |' + echo '\----------------------------------------------------------------------/' + echo + fi + fi + # Record the first non-zero exit code. test $success -eq 0 && success=$1 } @@ -28,11 +54,78 @@ escapeXML() { echo "$1" | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g' } +mavenEvaluate() { + mvn -B -U -q -Denforcer.skip=true -Dexec.executable=echo -Dexec.args="$1" --non-recursive validate exec:exec 2>&1 +} + +# Output debugging info, for troubleshooting builds. +dump() { + if env | grep -q ^$1= + then + # Environment variable is set. + line=$(env | grep ^$1=) + if [ "$line" ] + then + # And it's non-empty. + if [ "$2" ] + then + # Secret value: emit only that it is present. + echo "$1=" + else + # Not a secret: emit in plaintext. + echo "$line" + fi + else + # But it is empty! + echo "$1=" + fi + else + # Environment variable is not set. + echo "$1=" + fi +} + +analyzeGitHubWorkflow() { + test -d .github/workflows || return + echo + echo '/--------------------------------------------------\' + echo '| ci-build.sh analysis: env vars + GitHub workflow |' + echo '\--------------------------------------------------/' + dump dir + dump platform + dump BUILD_REPOSITORY + dump NO_DEPLOY + echo '----------------------------------------------------' + dump GPG_KEY_NAME secret + dump GPG_PASSPHRASE secret + dump MAVEN_USER secret + dump MAVEN_PASS secret + dump CENTRAL_USER secret + dump CENTRAL_PASS secret + dump SIGNING_ASC secret + echo '----------------------------------------------------' + for var in \ + GPG_KEY_NAME \ + GPG_PASSPHRASE \ + MAVEN_USER \ + MAVEN_PASS \ + CENTRAL_USER \ + CENTRAL_PASS \ + SIGNING_ASC + do + grep -q "secrets.$var" .github/workflows/*.yml || + echo "Add \`$var: \${{ secrets.$var }}\` to GitHub workflow env section!" + done +} + # Build Maven projects. if [ -f pom.xml ]; then echo ::group::"= Maven build =" + + # --== MAVEN SETUP ==-- + echo - echo "== Configuring Maven ==" + echo '== Configuring Maven ==' # NB: Suppress "Downloading/Downloaded" messages. # See: https://stackoverflow.com/a/35653426/1207769 @@ -42,14 +135,22 @@ if [ -f pom.xml ]; then mkdir -p "$HOME/.m2" settingsFile="$HOME/.m2/settings.xml" customSettings=.ci/settings.xml - if [ -z "$MAVEN_PASS" -a -z "$OSSRH_PASS" ]; then - echo "[WARNING] Skipping settings.xml generation (no deployment credentials)." - elif [ -f "$customSettings" ]; then + if [ "$OSSRH_USER" -o "$OSSRH_PASS" ]; then + echo '[WARNING] Obsolete OSSRH vars detected. Secrets may need updating to deploy to Maven Central.' + fi + if [ -f "$customSettings" ]; then cp "$customSettings" "$settingsFile" + elif [ -z "$BUILD_REPOSITORY" ]; then + echo 'Skipping settings.xml generation (no BUILD_REPOSITORY; assuming we are running locally)' else + # settings.xml header cat >"$settingsFile" < +EOL + # settings.xml scijava servers + if [ "$MAVEN_USER" -a "$MAVEN_PASS" ]; then + cat >>"$settingsFile" < scijava.releases $MAVEN_USER @@ -60,12 +161,28 @@ if [ -f pom.xml ]; then $MAVEN_USER $(escapeXML "$MAVEN_PASS") +EOL + else + echo '[WARNING] Skipping settings.xml scijava servers (no MAVEN deployment credentials).' + fi + # settings.xml central server + if [ "$CENTRAL_USER" -a "$CENTRAL_PASS" ]; then + cat >>"$settingsFile" < - sonatype-nexus-releases - scijava-ci - $(escapeXML "$OSSRH_PASS") + central + $CENTRAL_USER + $(escapeXML "$CENTRAL_PASS") +EOL + else + echo '[WARNING] Skipping settings.xml central server (no CENTRAL deployment credentials).' + fi + cat >>"$settingsFile" < +EOL + # settings.xml GPG profile + if [ "$GPG_KEY_NAME" -a "$GPG_PASSPHRASE" ]; then + cat >>"$settingsFile" < gpg @@ -80,59 +197,147 @@ if [ -f pom.xml ]; then +EOL + else + echo '[WARNING] Skipping settings.xml gpg profile (no GPG credentials).' + fi + # settings.xml footer + cat >>"$settingsFile" < EOL fi - # Determine whether deploying will be possible. + # --== DEPLOYMENT CHECKS ==-- + + # Determine whether deploying is both possible and warranted. + echo 'Performing deployment checks' deployOK= - scmURL=$(mvn -q -Denforcer.skip=true -Dexec.executable=echo -Dexec.args='${project.scm.url}' --non-recursive validate exec:exec 2>&1) - scmURL=${scmURL%.git} - scmURL=${scmURL%/} - if [ $? -ne 0 ]; then - echo "No deploy -- could not extract ciManagement URL" - echo "Output of failed attempt follows:" + scmURL=$(mavenEvaluate '${project.scm.url}') + result=$? + checkSuccess $result + if [ $result -ne 0 ]; then + echo 'No deploy -- could not extract ciManagement URL' + echo 'Output of failed attempt follows:' echo "$scmURL" else - if [ ! "$SIGNING_ASC" ] || [ ! "$GPG_KEY_NAME" ] || [ ! "$GPG_PASSPHRASE" ] || [ ! "$MAVEN_PASS" ] || [ ! "$OSSRH_PASS" ]; then - echo "No deploy -- secure environment variables not available" + scmURL=${scmURL%.git} + scmURL=${scmURL%/} + if [ "$NO_DEPLOY" ]; then + echo 'No deploy -- the NO_DEPLOY flag is set' elif [ "$BUILD_REPOSITORY" -a "$BUILD_REPOSITORY" != "$scmURL" ]; then echo "No deploy -- repository fork: $BUILD_REPOSITORY != $scmURL" + elif [ "$BUILD_BASE_REF" -o "$BUILD_HEAD_REF" ]; then + echo "No deploy -- proposed change: $BUILD_HEAD_REF -> $BUILD_BASE_REF" else - echo "All checks passed for artifact deployment" - deployOK=1 + # Are we building a snapshot version, or a release version? + version=$(mavenEvaluate '${project.version}') + result=$? + checkSuccess $result + if [ $result -ne 0 ]; then + echo 'No deploy -- could not extract version string' + echo 'Output of failed attempt follows:' + echo "$version" + else + case "$version" in + *-SNAPSHOT) + # Snapshot version -- ensure release.properties not present. + if [ -f release.properties ]; then + echo '[ERROR] Spurious release.properties file is present' + echo 'Remove the file from version control and try again.' + exit 1 + fi + + # Check for SciJava Maven repository credentials. + if [ "$MAVEN_USER" -a "$MAVEN_PASS" ]; then + deployOK=1 + else + echo 'No deploy -- MAVEN environment variables not available' + analyzeGitHubWorkflow + fi + ;; + *) + # Release version -- ensure release.properties is present. + if [ ! -f release.properties ]; then + echo '[ERROR] Release version, but release.properties not found' + echo 'You must use release-version.sh to release -- see https://imagej.net/develop/releasing' + exit 1 + fi + + # To which repository are we releasing? + releaseProfiles=$(mavenEvaluate '${releaseProfiles}') + result=$? + checkSuccess $result + if [ $result -ne 0 ]; then + echo 'No deploy -- could not extract releaseProfiles string' + echo 'Output of failed attempt follows:' + echo "$releaseProfiles" + fi + case "$releaseProfiles" in + *deploy-to-scijava*) + # Check for SciJava Maven repository credentials. + if [ "$MAVEN_USER" -a "$MAVEN_PASS" ]; then + deployOK=1 + else + echo '[ERROR] Cannot deploy: MAVEN environment variables not available' + analyzeGitHubWorkflow + exit 1 + fi + ;; + *sonatype-oss-release*) + # Check for Central Portal deployment credentials. + # Deploy to Central requires GPG-signed artifacts. + if [ "$CENTRAL_USER" -a "$CENTRAL_PASS" -a "$SIGNING_ASC" -a "$GPG_KEY_NAME" -a "$GPG_PASSPHRASE" ]; then + deployOK=1 + else + echo '[ERROR] Cannot deploy: CENTRAL environment variables not available' + analyzeGitHubWorkflow + exit 1 + fi + ;; + *) + echo 'Unknown deploy target -- attempting to deploy anyway' + deployOK=1 + ;; + esac + ;; + esac + fi fi fi - - # Install GPG on macOS - if [ "$MACOS" ]; then - HOMEBREW_NO_AUTO_UPDATE=1 brew install gnupg2 + if [ "$deployOK" ]; then + echo 'All checks passed for artifact deployment' fi - # Avoid "signing failed: Inappropriate ioctl for device" error. - export GPG_TTY=$(tty) + # --== Maven build arguments ==-- - # Import the GPG signing key. - keyFile=.ci/signingkey.asc - if [ "$deployOK" ]; then - echo "== Importing GPG keypair ==" - mkdir -p .ci - echo "$SIGNING_ASC" > "$keyFile" - ls -la "$keyFile" - gpg --version - gpg --batch --fast-import "$keyFile" - checkSuccess $? - fi + BUILD_ARGS="$BUILD_ARGS -B -Djdk.tls.client.protocols=TLSv1,TLSv1.1,TLSv1.2" - # Run the build. - BUILD_ARGS='-B -Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"' - if [ "$deployOK" -a -f release.properties ]; then - echo - echo "== Cutting and deploying release version ==" + # --== GPG SETUP ==-- + + if [ "$GPG_KEY_NAME" -a "$GPG_PASSPHRASE" ]; then + # Install GPG on macOS + if [ "$platform" = Darwin ]; then + HOMEBREW_NO_AUTO_UPDATE=1 brew install gnupg2 + fi + + # Avoid "signing failed: Inappropriate ioctl for device" error. + export GPG_TTY=$(tty) + + # Import the GPG signing key. + keyFile=.ci/signingkey.asc + if [ "$deployOK" ]; then + echo '== Importing GPG keypair ==' + mkdir -p .ci + echo "$SIGNING_ASC" > "$keyFile" + ls -la "$keyFile" + gpg --version + gpg --batch --fast-import "$keyFile" + checkSuccess $? + fi # HACK: Use maven-gpg-plugin 3.0.1+. Avoids "signing failed: No such file or directory" error. - maven_gpg_plugin_version=$(mvn -q -Denforcer.skip=true -Dexec.executable=echo -Dexec.args='${maven-gpg-plugin.version}' --non-recursive validate exec:exec 2>&1) + maven_gpg_plugin_version=$(mavenEvaluate '${maven-gpg-plugin.version}') case "$maven_gpg_plugin_version" in 0.*|1.*|2.*|3.0.0) echo "--> Forcing maven-gpg-plugin version from $maven_gpg_plugin_version to 3.0.1" @@ -144,7 +349,7 @@ EOL esac # HACK: Install pinentry helper program if missing. Avoids "signing failed: No pinentry" error. - if which pinentry >/dev/null 2>&1; then + if ! which pinentry >/dev/null 2>&1; then echo '--> Installing missing pinentry helper for GPG' sudo apt-get install -y pinentry-tty # HACK: Restart the gpg agent, to notice the newly installed pinentry. @@ -154,31 +359,46 @@ EOL checkSuccess $? fi fi + else + echo '[WARNING] Skipping gpg setup (no GPG credentials).' + fi - mvn -B $BUILD_ARGS release:perform - checkSuccess $? + # --== BUILD EXECUTION ==-- - echo "== Invalidating SciJava Maven repository cache ==" - curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/bdd932af4c4816f88cb6a52cdd7449f175934634/maven-helper.sh && - gav=$(sh maven-helper.sh gav-from-pom pom.xml) && - ga=${gav%:*} && - echo "--> Artifact to invalidate = $ga" && - echo "machine maven.scijava.org" >"$HOME/.netrc" && - echo " login $MAVEN_USER" >>"$HOME/.netrc" && - echo " password $MAVEN_PASS" >>"$HOME/.netrc" && - sh maven-helper.sh invalidate-cache "$ga" - checkSuccess $? + # Run the build. + if [ "$deployOK" -a -f release.properties ]; then + echo + echo '== Cutting and deploying release version ==' + BUILD_ARGS="$BUILD_ARGS release:perform" elif [ "$deployOK" ]; then echo - echo "== Building and deploying main branch SNAPSHOT ==" - mvn -Pdeploy-to-scijava $BUILD_ARGS deploy - checkSuccess $? + echo '== Building and deploying main branch SNAPSHOT ==' + BUILD_ARGS="-Pdeploy-to-scijava $BUILD_ARGS deploy" else echo - echo "== Building the artifact locally only ==" - mvn $BUILD_ARGS install javadoc:javadoc - checkSuccess $? + echo '== Building the artifact locally only ==' + BUILD_ARGS="$BUILD_ARGS install javadoc:javadoc" fi + # Check the build result. + { (set -x; mvn $BUILD_ARGS); echo $? > exit-code; } | tee mvn-log + checkSuccess "$(cat exit-code)" mvn-log + + # --== POST-BUILD ACTIONS ==-- + + # Dump logs for any failing unit tests. + if [ -d target/surefire-reports ] + then + find target/surefire-reports -name '*.txt' | while read report + do + if grep -qF 'FAILURE!' "$report" + then + echo + echo "[$report]" + cat "$report" + fi + done + fi + echo ::endgroup:: fi diff --git a/ci-javadoc.sh b/ci-javadoc.sh deleted file mode 100755 index 3390402..0000000 --- a/ci-javadoc.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash - -# -# ci-javadoc.sh - A script to build the javadocs of SciJava-based projects -# automatically using a continuous integration service. -# - -# The following repositories are known to use this script: -# -# - bonej-org/bonej-javadoc -# - fiji/fiji-javadoc -# - flimlib/flimlib-javadoc -# - imagej/imagej-javadoc -# - imglib/imglib2-javadoc -# - scifio/scifio-javadoc -# - scenerygraphics/sciview-javadoc -# - scijava/java3d-javadoc -# - scijava/scijava-javadoc -# - uw-loci/loci-javadoc - -# Wait for a launched background command to complete, emitting -# an occasional message to avoid long periods without output. -# Return the same exit code as the launched command. -keep_alive() { - pid="$1" - if [ "$pid" = "" ] - then - echo "[ERROR] No PID given" - return - fi - i=0 - while kill -0 "$pid" 2>/dev/null; do - i=$((i+1)) - m=$((i/60)) - s=$((i%60)) - test $s -eq 0 && echo "[$m minutes elapsed]" - sleep 1 - done - wait "$pid" -} - -ciURL=$(mvn -q -Denforcer.skip=true -Dexec.executable=echo -Dexec.args='${project.ciManagement.url}' --non-recursive validate exec:exec 2>&1) -ciURL=${ciURL%/actions} -ciRepo=${ciURL##*/} -ciPrefix=${ciURL%/*} -ciOrg=${ciPrefix##*/} -gitBranch=$(git branch --show-current) # get current branch name -if [ "$gitBranch" = main -o "$gitBranch" = master ] -then - project=$1 - - # Populate the settings.xml configuration. - mkdir -p "$HOME/.m2" - settingsFile="$HOME/.m2/settings.xml" - customSettings=.github/settings.xml - if [ -f "$customSettings" ] - then - cp "$customSettings" "$settingsFile" - else - # NB: Use maven.scijava.org as sole mirror if defined in . - test -f pom.xml && grep -A 2 '' pom.xml | grep -q 'maven.scijava.org' && - cat >"$settingsFile" < - - - scijava-mirror - SciJava mirror - https://maven.scijava.org/content/groups/public/ - * - - - -EOL - fi - - # Emit some details useful for debugging. - # NB: We run once with -q to suppress the download messages, - # then again without it to emit the desired dependency tree. - mvn -B -q dependency:tree && - mvn -B dependency:tree && - - echo && - echo "== Generating javadoc ==" && - - # Build the javadocs. - (mvn -B -q -Pbuild-javadoc) & - keep_alive $! && - test -d target/apidocs && - # Strip out date stamps, to avoid spurious changes being committed. - sed -i'' -e '/\( Artifact to invalidate = $ga" && - echo "machine maven.scijava.org" > "$HOME/.netrc" && - echo " login travis" >> "$HOME/.netrc" && - echo " password $MAVEN_PASS" >> "$HOME/.netrc" && - sh maven-helper.sh invalidate-cache "$ga" - checkSuccess $? - else - echo - echo "== Building the artifact locally only ==" - mvn $BUILD_ARGS install javadoc:javadoc - checkSuccess $? - fi - echo travis_fold:end:scijava-maven -fi - -# Configure conda environment, if one is needed. -if [ -f environment.yml ] -then - echo travis_fold:start:scijava-conda - echo "= Conda setup =" - - condaDir=$HOME/miniconda - condaSh=$condaDir/etc/profile.d/conda.sh - if [ ! -f "$condaSh" ]; then - echo - echo "== Installing conda ==" - if [ "$TRAVIS_PYTHON_VERSION" = "2.7" ]; then - wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh - else - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - fi - rm -rf "$condaDir" - bash miniconda.sh -b -p "$condaDir" - checkSuccess $? - fi - - echo - echo "== Updating conda ==" - . "$condaSh" && - conda config --set always_yes yes --set changeps1 no && - conda update -q conda && - conda info -a - checkSuccess $? - - echo - echo "== Configuring environment ==" - condaEnv=travis-scijava - test -d "$condaDir/envs/$condaEnv" && condaAction=update || condaAction=create - conda env "$condaAction" -n "$condaEnv" -f environment.yml && - conda activate "$condaEnv" - checkSuccess $? - - echo travis_fold:end:scijava-conda -fi - -# Execute Jupyter notebooks. -if which jupyter >/dev/null 2>/dev/null -then - echo travis_fold:start:scijava-jupyter - echo "= Jupyter notebooks =" - # NB: This part is fiddly. We want to loop over files even with spaces, - # so we use the "find ... -print0 | while read $'\0' ..." idiom. - # However, that runs the piped expression in a subshell, which means - # that any updates to the success variable will not persist outside - # the loop. So we suppress all stdout inside the loop, echoing only - # the final value of success upon completion, and then capture the - # echoed value back into the parent shell's success variable. - success=$(find . -name '*.ipynb' -print0 | { - while read -d $'\0' nbf - do - echo 1>&2 - echo "== $nbf ==" 1>&2 - jupyter nbconvert --execute --stdout "$nbf" >/dev/null - checkSuccess $? - done - echo $success - }) - echo travis_fold:end:scijava-jupyter -fi - -exit $success diff --git a/travis-javadoc.sh b/travis-javadoc.sh deleted file mode 100644 index 7badbcb..0000000 --- a/travis-javadoc.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash - -# -# travis-javadoc.sh - A script to build the javadocs of a SciJava-based project. -# - -# The following repositories are known to use this script: -# -# bonej-org/bonej-javadoc -# fiji/fiji-javadoc -# imagej/imagej-javadoc -# imglib/imglib2-javadoc -# scifio/scifio-javadoc -# scijava/java3d-javadoc -# scijava/scijava-javadoc -# slim-curve/slim-javadoc -# uw-loci/loci-javadoc - -# Wait for a launched background command to complete, emitting -# an occasional message to avoid long periods without output. -# Return the same exit code as the launched command. -keep_alive() { - pid="$1" - if [ "$pid" = "" ] - then - echo "[ERROR] No PID given" - return - fi - i=0 - while kill -0 "$pid" 2>/dev/null; do - i=$((i+1)) - m=$((i/60)) - s=$((i%60)) - test $s -eq 0 && echo "[$m minutes elapsed]" - sleep 1 - done - wait "$pid" -} - -if [ "$TRAVIS_SECURE_ENV_VARS" = true \ - -a "$TRAVIS_PULL_REQUEST" = false \ - -a "$TRAVIS_BRANCH" = master ] -then - project=$1 - openssl_key=$2 - openssl_iv=$3 - - # Populate the settings.xml configuration. - mkdir -p "$HOME/.m2" - settingsFile="$HOME/.m2/settings.xml" - customSettings=.travis/settings.xml - if [ -f "$customSettings" ] - then - cp "$customSettings" "$settingsFile" - else - # NB: Use maven.scijava.org as sole mirror if defined in . - # This hopefully avoids intermittent "ReasonPhrase:Forbidden" errors - # when the Travis build pings Maven Central; see travis-ci/travis-ci#6593. - test -f pom.xml && grep -A 2 '' pom.xml | grep -q 'maven.scijava.org' && - cat >"$settingsFile" < - - - scijava-mirror - SciJava mirror - https://maven.scijava.org/content/groups/public/ - * - - - -EOL - fi - - # Emit some details useful for debugging. - # NB: We run once with -q to suppress the download messages, - # then again without it to emit the desired dependency tree. - mvn -B -q dependency:tree && - mvn -B dependency:tree && - - echo && - echo "== Generating javadoc ==" && - - # Build the javadocs. - (mvn -B -q -Pbuild-javadoc) & - keep_alive $! && - test -d target/apidocs && - # Strip out date stamps, to avoid spurious changes being committed. - sed -i'' -e '/\(\n\t\tdeploy-to-scijava<\/releaseProfiles>\1/igs' "$tmpFile" - update pom.xml 'POM: deploy releases to the SciJava repository' - fi - - # update the README - if grep -q "travis-ci\.[a-zA-Z0-9/_-]*\.svg" README.md >/dev/null 2>&1 - then - info "Updating README.md Travis badge" - sed "s|travis-ci\.[a-zA-Z0-9/_-]*|$domain/$repoSlug|g" README.md >"$tmpFile" - update README.md 'Travis: fix README.md badge link' - else - info "Adding Travis badge to README.md" - echo "[![](https://$domain/$repoSlug.svg?branch=$defaultBranch)](https://$domain/$repoSlug)" >"$tmpFile" - echo >>"$tmpFile" - test -f README.md && cat README.md >>"$tmpFile" - update README.md 'Travis: add badge to README.md' - fi - - # encrypt key/value pairs in variables file - if [ -f "$varsFile" ] - then - while read p; do - # Skip comments. (Cannot use ${p:0:1} because it's bash-specific.) - case "$p" in - '#'*) continue;; - esac - info "Encrypting ${p%%=*}" - yes | $EXEC travis encrypt --$mode "$p" --add env.global --repo "$repoSlug" - test $? -eq 0 || die "Failed to encrypt variable '$p'" - done <"$varsFile" - $EXEC git commit "$travisConfig" -m "Travis: add encrypted environment variables" - else - warn "No $varsFile found. Travis will not have any environment variables set!" - fi - - # encrypt GPG keypair - if [ -f "$signingKeySourceFile" ] - then - info "Encrypting $signingKeyDestFile" - if [ -z "$EXEC" ] - then - rm -f "$signingKeyDestFile.enc" - encryptOutput=$(travis encrypt-file --$mode "$signingKeySourceFile" "$signingKeyDestFile.enc" --repo "$repoSlug") - test $? -eq 0 || die "Failed to encrypt signing key." - encryptResult=$(echo "$encryptOutput" | grep openssl) - test "$encryptResult" || die "No openssl variables emitted." - key=$(echo "$encryptResult" | cut -d' ' -f4) - iv=$(echo "$encryptResult" | cut -d' ' -f6) - sed -i.bak "s/\(sh travis-build.sh\)/\1 $key $iv/" "$travisBuildScript" - rm -f "$travisBuildScript.bak" - git add "$travisBuildScript" "$signingKeyDestFile.enc" - git commit -m "Travis: add encrypted GPG signing keypair" - fi - else - warn "No $signingKeySourceFile found. Travis will not be able to do GPG signing!" - fi -} - -test -d "$credentialsDir" || - die "This script requires configuration stored in $credentialsDir,\n" \ - "including $varsFile for needed environment variables,\n" \ - "and $signingKeySourceFile for signing of artifacts.\n" \ - "Please contact a SciJava administrator to receive a copy of this content." - -# check prerequisites -check git sed cut perl xmllint travis - -# parse arguments -EXEC=: -SKIP_PARENT_CHECK= -while test $# -gt 0 -do - case "$1" in - -f) EXEC=;; - -p) SKIP_PARENT_CHECK=true;; - --) break;; - -*) echo "Ignoring unknown option: $1" >&2; break;; - *) break;; - esac - shift -done - -test "$EXEC" && warn "Simulation only. Run with -f flag to go for real." - -# process arguments -if [ $# -gt 0 ] -then - for d in $@ - do ( - echo "[$d]" - process "$d" - ) done -else - process . -fi