Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release channels and staged releases for the manager #736

Merged
merged 14 commits into from Oct 1, 2020
9 changes: 8 additions & 1 deletion src/server_manager/electron_app/package_linux_action.sh
Expand Up @@ -14,15 +14,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

source src/server_manager/scripts/fill_packaging_opts.sh $0 $@

yarn do server_manager/electron_app/build

readonly BUILD_DIR=build/server_manager/electron_app/static

$ROOT_DIR/src/server_manager/node_modules/.bin/electron-builder \
--projectDir=build/server_manager/electron_app/static \
--projectDir="${BUILD_DIR}" \
--config.asarUnpack=server_manager/web_app/images \
--config.generateUpdatesFilesForAllChannels=true \
--publish=never \
--config.publish.provider=generic \
--config.publish.url=https://raw.githubusercontent.com/Jigsaw-Code/outline-releases/master/manager/ \
--linux AppImage \
--config.linux.icon=icons/png \
--config.linux.category=Network \
--config.artifactName='Outline-Manager.${ext}'

src/server_manager/scripts/finish_info_files.sh linux $STAGING_PERCENTAGE
9 changes: 8 additions & 1 deletion src/server_manager/electron_app/package_macos_action.sh
Expand Up @@ -14,15 +14,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

source src/server_manager/scripts/fill_packaging_opts.sh $0 $@

yarn do server_manager/electron_app/build

readonly BUILD_DIR=build/server_manager/electron_app/static

# Produces dmg and zip images. The latter is required for auto-update.
$ROOT_DIR/src/server_manager/node_modules/.bin/electron-builder \
--projectDir=build/server_manager/electron_app/static \
--projectDir="${BUILD_DIR}" \
--config.asarUnpack=server_manager/web_app/images \
--config.generateUpdatesFilesForAllChannels=true \
--publish=never \
--config.publish.provider=generic \
--config.publish.url=https://raw.githubusercontent.com/Jigsaw-Code/outline-releases/master/manager/ \
--mac default \
--config.mac.icon=icons/mac/icon.icns \
--config.artifactName='Outline-Manager.${ext}'

src/server_manager/scripts/finish_info_files.sh mac $STAGING_PERCENTAGE
Expand Up @@ -21,6 +21,7 @@
$ROOT_DIR/src/server_manager/node_modules/.bin/electron-builder \
--projectDir=build/server_manager/electron_app/static \
--config.asarUnpack=server_manager/web_app/images \
--config.generateUpdatesFilesForAllChannels=true \
--publish=never \
--config.publish.provider=generic \
--config.publish.url=https://raw.githubusercontent.com/Jigsaw-Code/outline-releases/master/manager/ \
Expand Down
9 changes: 8 additions & 1 deletion src/server_manager/electron_app/release_linux_action.sh
Expand Up @@ -14,16 +14,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

source src/server_manager/scripts/fill_packaging_opts.sh $0 $@

yarn do server_manager/electron_app/build
yarn do server_manager/electron_app/write_production_environment

readonly BUILD_DIR=build/server_manager/electron_app/static

$ROOT_DIR/src/server_manager/node_modules/.bin/electron-builder \
--projectDir=build/server_manager/electron_app/static \
--projectDir="${BUILD_DIR}" \
--config.asarUnpack=server_manager/web_app/images \
--config.generateUpdatesFißlesForAllChannels=true \
--publish=never \
--config.publish.provider=generic \
--config.publish.url=https://raw.githubusercontent.com/Jigsaw-Code/outline-releases/master/manager/ \
--linux AppImage \
--config.linux.icon=icons/png \
--config.linux.category=Network \
--config.artifactName='Outline-Manager.${ext}'

src/server_manager/scripts/finish_info_files.sh linux $STAGING_PERCENTAGE
9 changes: 8 additions & 1 deletion src/server_manager/electron_app/release_macos_action.sh
Expand Up @@ -21,16 +21,23 @@ if [ "$CSC_LINK" == "unset" ]; then
exit 1
fi

source src/server_manager/scripts/fill_packaging_opts.sh $0 $@

yarn do server_manager/electron_app/build
yarn do server_manager/electron_app/write_production_environment

readonly BUILD_DIR=build/server_manager/electron_app/static

# Produces dmg and zip images. The latter is required for auto-update.
$ROOT_DIR/src/server_manager/node_modules/.bin/electron-builder \
--projectDir=build/server_manager/electron_app/static \
--projectDir="${BUILD_DIR}" \
--config.asarUnpack=server_manager/web_app/images \
--config.generateUpdatesFilesForAllChannels=true \
--publish=never \
--config.publish.provider=generic \
--config.publish.url=https://raw.githubusercontent.com/Jigsaw-Code/outline-releases/master/manager/ \
--mac default \
--config.mac.icon=icons/mac/icon.icns \
--config.artifactName='Outline-Manager.${ext}'

src/server_manager/scripts/finish_info_files.sh mac $STAGING_PERCENTAGE
9 changes: 8 additions & 1 deletion src/server_manager/electron_app/release_windows_action.sh
Expand Up @@ -14,12 +14,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

source src/server_manager/scripts/fill_packaging_opts.sh $0 $@

yarn do server_manager/electron_app/build
yarn do server_manager/electron_app/write_production_environment

readonly BUILD_DIR=build/server_manager/electron_app/static

$ROOT_DIR/src/server_manager/node_modules/.bin/electron-builder \
--projectDir=build/server_manager/electron_app/static \
--projectDir="${BUILD_DIR}" \
--config.asarUnpack=server_manager/web_app/images \
--config.generateUpdatesFilesForAllChannels=true \
--publish=never \
--config.publish.provider=generic \
--config.publish.url=https://raw.githubusercontent.com/Jigsaw-Code/outline-releases/master/manager/ \
Expand All @@ -28,3 +33,5 @@ $ROOT_DIR/src/server_manager/node_modules/.bin/electron-builder \
--config.win.icon=icons/win/icon.ico \
--config.win.certificateSubjectName='Jigsaw Operations LLC' \
--config.artifactName='Outline-Manager.${ext}'

src/server_manager/scripts/finish_info_files.sh win $STAGING_PERCENTAGE
1 change: 1 addition & 0 deletions src/server_manager/package.json
Expand Up @@ -75,6 +75,7 @@
"gulp-posthtml": "^3.0.4",
"gulp-replace": "^1.0.0",
"html-webpack-plugin": "^4.2.1",
"node-jq": "^1.11.2",
"postcss": "^7.0.29",
"postcss-rtl": "^1.7.3",
"posthtml-postcss": "^0.2.6",
Expand Down
53 changes: 53 additions & 0 deletions src/server_manager/scripts/fill_packaging_opts.sh
@@ -0,0 +1,53 @@
#!/bin/bash -eu
#
# Copyright 2020 The Outline Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Collects common packaging options. Meant to be called from the diffrent package_foo and
# release_foo scripts.
# Usage from a packaging script:
# source src/server_manager/electron_app/package_$PLATFORM $0 $@
#
# Note that you MUST use "source" in order to run the script in the same process as the calling
# script, allowing fill_packaging_opts.sh to fill variables for the caller.

readonly YARN_COMMAND="yarn do $(echo "${1}" | sed 's:.*\(src/server_manager/electron_app/.*\)_action.sh:\1:')"
shift

function usage () {
echo "Usage:" 1>&2
echo "${YARN_COMMAND} [-s stagingPercentage]" 1>&2
echo " -s: The staged rollout percentage for this release. Must be in the interval (0, 100]. Defaults to 100" 1>&2
echo " -h: this help message" 1>&2
echo 1>&2
echo "Examples:" 1>&2
echo "Releases the beta of version 1.2.3 to 10% of users listening on the beta channel" 1>&2
echo '$ '"jq -r '.version' src/server_manager/package.json'" 1>&2
echo "1.2.3-beta" 1>&2
echo '$ '"${YARN_COMMAND} -s 10" 1>&2
exit 1
}

STAGING_PERCENTAGE=100
while getopts s:? opt; do
case $opt in
s) STAGING_PERCENTAGE=$OPTARG ;;
*) usage ;;
esac
done

if ((STAGING_PERCENTAGE <= 0)) || ((STAGING_PERCENTAGE > 100)); then
echo "Staging percentage must be greater than 0 and no more than 100" 1>&2
exit 1
fi
33 changes: 33 additions & 0 deletions src/server_manager/scripts/finish_info_files.sh
@@ -0,0 +1,33 @@
#!/bin/bash -eu
#
# Copyright 2018 The Outline Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PLATFORM="-$1"
if [[ "${PLATFORM}" = "-win" ]]; then
PLATFORM=""
fi
readonly STAGING_PERCENTAGE="${2}"
readonly BUILD_DIR=build/server_manager/electron_app/static

INFO_FILE_CHANNEL=$(src/server_manager/scripts/get_manager_release_channel.sh)
echo "stagingPercentage: $STAGING_PERCENTAGE" >> "${BUILD_DIR}"/dist/"${INFO_FILE_CHANNEL}${PLATFORM}".yml

# If we cut a staged mainline release, beta testers will take the update as well.
if [[ "${INFO_FILE_CHANNEL}" = "latest" ]]; then
echo "stagingPercentage: $STAGING_PERCENTAGE" >> "${BUILD_DIR}"/dist/beta"${PLATFORM}".yml
fi

# We don't support alpha releases
rm -f "${BUILD_DIR}"/dist/alpha"${PLATFORM}".yml
22 changes: 22 additions & 0 deletions src/server_manager/scripts/get_manager_release_channel.sh
@@ -0,0 +1,22 @@
#!/bin/bash -eu
#
# Copyright 2020 The Outline Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# If this isn't an alpha or beta build, `cut -s` will return an empty string
INFO_FILE_CHANNEL=$(node_modules/node-jq/bin/jq -r '.version' src/server_manager/package.json | cut -s -d'-' -f2)
if [[ -z "${INFO_FILE_CHANNEL}" ]]; then
INFO_FILE_CHANNEL=latest
fi
echo "${INFO_FILE_CHANNEL}"