diff --git a/.bumpversion.cfg b/.bumpversion.cfg index dbdfad7461fc18d0dbfdccda4a2611aa7edd452b..5883af8b18f3e245d457b921747eee4be0b10248 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -11,4 +11,3 @@ search = <version>{current_version}</version><!-- BUMP_VERSION --> replace = <version>{new_version}</version><!-- BUMP_VERSION --> [bumpversion:file:hbp.yml] - diff --git a/build.sh b/build.sh index 927b578b1d058e544dcff2884db810707aa95eb9..3a35bac2bf4f9066a99427cfad86ddd2d8db1e29 100755 --- a/build.sh +++ b/build.sh @@ -18,6 +18,11 @@ get_script_dir () { cd "$(get_script_dir)" +if pgrep -lf sshuttle > /dev/null ; then + echo "sshuttle detected. Please close this program as it messes with networking and prevents builds inside Docker to work" + exit 1 +fi + if [[ $NO_SUDO || -n "$CIRCLECI" ]]; then CAPTAIN="captain" elif groups $USER | grep &>/dev/null '\bdocker\b'; then diff --git a/publish.sh b/publish.sh index d1d942262c22445b5863c8040aa502b141d64112..353a9a146d0a2aa0321655606d5c482789d977dd 100755 --- a/publish.sh +++ b/publish.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash -set -e + +set -o pipefail # trace ERR through pipes +set -o errtrace # trace ERR through 'time command' and other functions +set -o errexit ## set -e : exit the script if any statement returns a non-true return value get_script_dir () { SOURCE="${BASH_SOURCE[0]}" @@ -20,15 +23,21 @@ if pgrep -lf sshuttle > /dev/null ; then exit 1 fi -if groups $USER | grep &>/dev/null '\bdocker\b'; then +if [ $NO_SUDO ]; then + CAPTAIN="captain" + DOCKER="docker" +elif groups $USER | grep &>/dev/null '\bdocker\b'; then CAPTAIN="captain" + DOCKER="docker" else CAPTAIN="sudo captain" + DOCKER="sudo docker" fi # Build echo "Build the project..." ./build.sh +./test.sh echo "[ok] Done" count=$(git status --porcelain | wc -l) @@ -59,8 +68,8 @@ select_part() { git pull --tags # Look for a version tag in Git. If not found, ask the user to provide one -[ $(git tag --points-at HEAD | wc -l) == 1 ] || ( - latest_version=$( (bumpversion --dry-run --list patch | grep current_version | sed -r s,"^.*=",,) || echo '0.0.1') +[ $(git tag --points-at HEAD | grep portal-backend | wc -l) == 1 ] || ( + latest_version=$(bumpversion --dry-run --list patch | grep current_version | sed -r s,"^.*=",, || echo '0.0.1') echo echo "Current commit has not been tagged with a version. Latest known version is $latest_version." echo @@ -85,14 +94,13 @@ updated_version=$(bumpversion --dry-run --list patch | grep current_version | se # Build again to update the version echo "Build the project for distribution..." ./build.sh -echo "[ok] Done" git push git push --tags # Push on Docker Hub # WARNING: Requires captain 1.1.0 to push user tags -BUILD_DATE=$(date --iso-8601=seconds) \ +BUILD_DATE=$(date -Iseconds) \ VCS_REF=$updated_version \ VERSION=$updated_version \ WORKSPACE=$WORKSPACE \