Skip to content

Commit

Permalink
snap: make future major version upgrades easier (iterative#4038)
Browse files Browse the repository at this point in the history
Related: iterative#3999
Related: iterative#4037
  • Loading branch information
casperdcl authored Jun 13, 2020
1 parent 7a31a35 commit 2ba73da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
27 changes: 21 additions & 6 deletions scripts/ci/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2ba73da

Please sign in to comment.