Bug 1411559 - Snap: Add upload on mozilla-release and restrict channels r=sfraser draft
authorJohan Lorenzo <jlorenzo@mozilla.com>
Wed, 28 Feb 2018 14:50:28 +0100
changeset 761038 1b8954fb96c1e5fbedbdd4f58f65e26be1a4ba29
parent 760914 9b1228043619f2f80b5fc60d4c081950bd21e9e9
push id100826
push userbmo:jlorenzo@mozilla.com
push dateWed, 28 Feb 2018 15:47:20 +0000
reviewerssfraser
bugs1411559
milestone60.0a1
Bug 1411559 - Snap: Add upload on mozilla-release and restrict channels r=sfraser MozReview-Commit-ID: DHszbMhpFKI
taskcluster/ci/release-snap/kind.yml
taskcluster/docker/firefox-snap/runme.sh
--- a/taskcluster/ci/release-snap/kind.yml
+++ b/taskcluster/ci/release-snap/kind.yml
@@ -46,17 +46,22 @@ job-defaults:
            tar xvfj scripts.tar.bz2 -C scripts --strip-components 4 &&
            cd scripts &&
            ./runme.sh
       env:
          VERSION: "{release_config[version]}"
          BUILD_NUMBER: "{release_config[build_number]}"
          PUSH_TO_CHANNEL:
             by-project:
-               mozilla-beta: "edge"
+               # The snap stores exposes 4 channels: edge, beta, candidate, release.
+               # Let's use edge and candidate for QE to test. Then, on the Snap Store UI,
+               # we can promote builds to beta and release, respectively.
+               # For more info: https://docs.snapcraft.io/reference/channels
+               mozilla-beta: edge
+               mozilla-release: candidate
                default: ""
          CANDIDATES_DIR:
             by-project:
                maple:
                   https://net-mozaws-stage-delivery-firefox.s3.amazonaws.com/pub/{task[shipping-product]}/candidates
                default:
                   https://net-mozaws-prod-delivery-firefox.s3.amazonaws.com/pub/{task[shipping-product]}/candidates
          LC_ALL: C.UTF-8
--- a/taskcluster/docker/firefox-snap/runme.sh
+++ b/taskcluster/docker/firefox-snap/runme.sh
@@ -6,16 +6,17 @@ set -xe
 test "$VERSION"
 test "$BUILD_NUMBER"
 test "$CANDIDATES_DIR"
 test "$L10N_CHANGESETS"
 
 # Optional env variables
 : WORKSPACE                     "${WORKSPACE:=/home/worker/workspace}"
 : ARTIFACTS_DIR                 "${ARTIFACTS_DIR:=/home/worker/artifacts}"
+: PUSH_TO_CHANNEL               ""
 
 SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
 TARGET="firefox-${VERSION}.snap"
 TARGET_FULL_PATH="$ARTIFACTS_DIR/$TARGET"
 SOURCE_DEST="${WORKSPACE}/source"
 
 mkdir -p "$ARTIFACTS_DIR"
@@ -68,20 +69,17 @@ cat << EOF > signing_manifest.json
 EOF
 
 # For posterity
 find . -ls
 cat "$TARGET.checksums"
 cat signing_manifest.json
 
 
-# Upload Beta snaps to Ubuntu Snap Store (No channel)
-# TODO: Add a release channel once ready for broader audience
-# TODO: Don't filter out non-beta releases
-# TODO: Parametrize channel depending on beta vs release
+# Upload snaps to Ubuntu Snap Store
 # TODO: Make this part an independent task
-if [ "$PUSH_TO_CHANNEL" != "" ]; then
-  echo "Beta version detected. Uploading to Ubuntu Store (no channel)..."
+if [[ "$PUSH_TO_CHANNEL" =~ (^(edge|candidate)$)  ]]; then
+  echo "Uploading to Ubuntu Store on channel $PUSH_TO_CHANNEL"
   bash "$SCRIPT_DIRECTORY/fetch_macaroons.sh" "http://taskcluster/secrets/v1/secret/project/releng/snapcraft/firefox/$PUSH_TO_CHANNEL"
-  snapcraft push "$TARGET_FULL_PATH"
+  snapcraft push --release "$PUSH_TO_CHANNEL" "$TARGET_FULL_PATH"
 else
-  echo "Non-beta version detected. Nothing else to do."
+  echo "No upload done: PUSH_TO_CHANNEL value \"$PUSH_TO_CHANNEL\" doesn't match a known channel."
 fi