diff --git a/.travis.yml b/.travis.yml index de7d7a5171..8387d9359f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -107,7 +107,6 @@ jobs: - sudo /snap/bin/lxd.migrate -yes - sudo /snap/bin/lxd waitready - sudo /snap/bin/lxd init --auto - - git fetch --tags script: - ./scripts/build_snap.sh after_failure: @@ -158,6 +157,14 @@ deploy: script: "(echo $SNAP_TOKEN | snapcraft login --with -) && timeout 600 snapcraft push dvc_*.snap --release $SNAP_CHANNEL || echo timed out" on: all_branches: true - condition: "$(./scripts/ci/deploy_condition.sh dvc_*.snap) && ($TRAVIS_BRANCH = master || -n $TRAVIS_TAG)" + condition: "$(./scripts/ci/deploy_condition.sh dvc_*.snap) && ($TRAVIS_BRANCH = master || -n $TRAVIS_TAG) && -n $SNAP_CHANNEL" + repo: iterative/dvc + stage: build + - provider: script + skip_cleanup: true + script: "(echo $SNAP_TOKEN | snapcraft login --with -) && timeout 600 snapcraft push dvc_*.snap --release $SNAP_CHANNEL_MAJOR || echo timed out" + on: + all_branches: true + condition: "$(./scripts/ci/deploy_condition.sh dvc_*.snap) && ($TRAVIS_BRANCH = master || -n $TRAVIS_TAG) && -n $SNAP_CHANNEL_MAJOR" repo: iterative/dvc stage: build diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index b16a581052..a2a1070883 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -51,12 +51,27 @@ elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip fi -if [[ -n "$TRAVIS_TAG" ]]; then - if [[ $(echo "$TRAVIS_TAG" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$') ]]; then - echo "export SNAP_CHANNEL=stable,v1/stable" >>env.sh +if [ "$TRAVIS_OS_NAME" == "linux" ]; then + # fetch tags for `git-describe`, since + # - can't rely on $TRAVIS_TAG for snapcraft `edge` (master) releases, and + # - `snapcraft` also uses `git-describe` for version detection + git fetch --tags + TAG_MAJOR="$(git describe --tags | sed -r 's/^v?([0-9]+)\.[0-9]+\.[0-9]+.*/\1/')" + [[ -n "$TAG_MAJOR" ]] || exit 1 # failed to detect major version + + if [[ -n "$TRAVIS_TAG" ]]; then + if [[ $(echo "$TRAVIS_TAG" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$') ]]; then + echo "export SNAP_CHANNEL=stable" >>env.sh + echo "export SNAP_CHANNEL_MAJOR=v$TAG_MAJOR/stable" >>env.sh + else + echo "export SNAP_CHANNEL=beta" >>env.sh + echo "export SNAP_CHANNEL_MAJOR=v$TAG_MAJOR/beta" >>env.sh + fi else - echo "export SNAP_CHANNEL=beta,v1/beta" >>env.sh + echo "export SNAP_CHANNEL=edge" >>env.sh + echo "export SNAP_CHANNEL_MAJOR=v$TAG_MAJOR/edge" >>env.sh fi -else - echo "export SNAP_CHANNEL=edge,v1/edge" >>env.sh + + # NOTE: after deprecating this major version branch, uncomment this line + # echo "unset SNAP_CHANNEL" >>env.sh fi