#!/usr/bin/env bash set -euxo pipefail help_info() { echo " Usage: ${0##*/} [options] Build zed.snap from the tarball produced by script/bundle-linux (target/release/zed-linux-.tar.gz), for the channel in crates/zed/RELEASE_CHANNEL. Options: -h, --help Display this help and exit. --publish Upload the snap to the Snap Store channel matching the release channel. " } publish=false while [[ $# -gt 0 ]]; do case $1 in -h|--help) help_info exit 0 ;; --publish) publish=true shift ;; *) help_info exit 1 ;; esac done channel=$( snap/snapcraft.yaml # Clean seems to be needed to actually check that the snapcraft.yaml # works. For example, when a `stage-package` is removed, it will # still remain on rebuild. snapcraft clean snapcraft pack --output zed.snap if [[ "$publish" == "true" ]]; then snapcraft upload --release="$store_channel" zed.snap fi