Skip to content

Instantly share code, notes, and snippets.

@lurch
Last active December 7, 2017 04:07
Show Gist options
  • Save lurch/88879362a9a106cf5516a10ba5dbdbcd to your computer and use it in GitHub Desktop.
Save lurch/88879362a9a106cf5516a10ba5dbdbcd to your computer and use it in GitHub Desktop.
Handy scripts to automate part of the Etcher release process
#!/bin/bash
###
# Copyright 2017 resin.io
#
# 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.
###
set -e
set -u
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function usage() {
echo "Usage: $0"
exit 1
}
PLATFORM=$("$HERE/platform-detect.sh")
RESULT=""
set +u
if [ "$PLATFORM" == "win32" ]; then
if [ "$PROCESSOR_ARCHITEW6432" == "AMD64" ] || [ "$PROCESSOR_ARCHITECTURE" == "AMD64" ]; then
RESULT=x64
elif [ "$PROCESSOR_ARCHITECTURE" == "x86" ]; then
RESULT=x86
fi
else
set -u
UNAME_MACHINE=$(uname -m)
if [ "$PLATFORM" == "linux" ]; then
if [ "$UNAME_MACHINE" == "x86_64" ]; then
RESULT=x64
elif [[ "$UNAME_MACHINE" = *86 ]]; then
RESULT=x86
elif [ "$UNAME_MACHINE" == "armv7l" ]; then
RESULT=armv7hf
fi
elif ["$PLATFORM" == "darwin" ]; then
if [ "$UNAME_MACHINE" == "x86_64" ]; then
RESULT=x64
fi
fi
fi
if [ -z "$RESULT" ]; then
echo "Couldn't determine host architecture" 1>&2
exit 1
fi
echo "$RESULT"
#!/bin/bash
###
# Copyright 2017 resin.io
#
# 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.
###
set -e
set -u
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function usage() {
echo "Usage: $0"
exit 1
}
function run_make_target() {
ARCH=$1
TARGET=$2
if [ -z "$ARCH" ]; then
echo "run_make_target called with no architecture" 1>&2
exit 1
fi
if [ -z "$TARGET" ]; then
echo "run_make_target called with no target" 1>&2
exit 1
fi
if [ "$PLATFORM" == "linux" ]; then
"$HERE/docker/run-command.sh" -r "$ARCH" -s . -c "make TARGET_ARCH=\"$ARCH\" RELEASE_TYPE=production \"$TARGET\""
else
make TARGET_ARCH="$ARCH" RELEASE_TYPE=production "$TARGET"
fi
}
PLATFORM=$("$HERE/platform-detect.sh")
HOST_ARCH=$("$HERE/architecture-detect.sh")
# Check analytics env-vars are set
set +u
if [ -z "$ANALYTICS_SENTRY_TOKEN" ]; then
echo "ANALYTICS_SENTRY_TOKEN is not set - this is required for release builds" 1>&2
exit 1
fi
if [ -z "$ANALYTICS_MIXPANEL_TOKEN" ]; then
echo "ANALYTICS_MIXPANEL_TOKEN is not set - this is required for release builds" 1>&2
exit 1
fi
# Check code-signing env-vars are set
if [ "$PLATFORM" == "darwin" ]; then
if [ -z "$CSC_NAME" ]; then
echo "CSC_NAME is not set - this is required for release builds on $PLATFORM" 1>&2
exit 1
fi
elif [ "$PLATFORM" == "win32" ]; then
if [ -z "$CSC_LINK" ]; then
echo "CSC_LINK is not set - this is required for release builds on $PLATFORM" 1>&2
exit 1
fi
if [ -z "$CSC_KEY_PASSWORD" ]; then
echo "CSC_KEY_PASSWORD is not set - this is required for release builds on $PLATFORM" 1>&2
exit 1
fi
fi
# Check updates haven't been disabled
if [ -n "$DISABLE_UPDATES" ]; then
echo "DISABLE_UPDATES shouldn't be set for release builds" 1>&2
exit 1
fi
set -u
"$HERE/check-dependency.sh" jq
ETCHER_VERSION=$(jq -r '.version' package.json)
TARGET_ARCHES="$HOST_ARCH"
if [ "$HOST_ARCH" == "x64" ]; then
if [ "$PLATFORM" == "linux" ] || [ "$PLATFORM" == "win32" ]; then
TARGET_ARCHES="$TARGET_ARCHES x86"
fi
fi
if [ "$PLATFORM" != "linux" ]; then
"$HERE/check-dependency.sh" make
fi
run_make_target "$HOST_ARCH" distclean
for ARCH in $TARGET_ARCHES; do
echo "Building Etcher v$ETCHER_VERSION production release for $PLATFORM/$ARCH"
run_make_target "$ARCH" info
run_make_target "$ARCH" electron-develop
run_make_target "$ARCH" installers-all
done
#!/bin/bash
###
# Copyright 2017 resin.io
#
# 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.
###
set -e
set -u
function usage() {
echo "Usage: $0"
exit 1
}
RESULT=""
set +u
# http://stackoverflow.com/a/12099167
if [ "$OS" == "Windows_NT" ]; then
RESULT=win32
else
set -u
UNAME_KERNEL=$(uname -s)
if [ "$UNAME_KERNEL" == "Linux" ]; then
RESULT=linux
elif ["$UNAME_KERNEL" == "Darwin" ]; then
RESULT=darwin
fi
fi
if [ -z "$RESULT" ]; then
echo "Couldn't determine host platform" 1>&2
exit 1
fi
echo "$RESULT"
#!/bin/bash
###
# Copyright 2017 resin.io
#
# 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.
###
set -e
set -u
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function usage() {
echo "Usage: $0"
exit 1
}
function run_make_target() {
ARCH=$1
TARGET=$2
if [ -z "$ARCH" ]; then
echo "run_make_target called with no architecture" 1>&2
exit 1
fi
if [ -z "$TARGET" ]; then
echo "run_make_target called with no target" 1>&2
exit 1
fi
if [ "$PLATFORM" == "linux" ]; then
"$HERE/docker/run-command.sh" -r "$ARCH" -s . -c "make TARGET_ARCH=\"$ARCH\" RELEASE_TYPE=production \"$TARGET\""
else
make TARGET_ARCH="$ARCH" RELEASE_TYPE=production "$TARGET"
fi
}
PLATFORM=$("$HERE/platform-detect.sh")
HOST_ARCH=$("$HERE/architecture-detect.sh")
# check commands needed for AWS publishing
"$HERE/check-dependency.sh" aws
if [ "$PLATFORM" == "linux" ]; then
# check commands needed for BinTray publishing
"$HERE/check-dependency.sh" curl
# check env-vars needed for BinTray publishing
set +u
if [ -z "$BINTRAY_USER" ] || [ -z "$BINTRAY_API_KEY" ]; then
echo "Please define the following environment variables:" 1>&2
echo "" 1>&2
echo " BINTRAY_USER" 1>&2
echo " BINTRAY_API_KEY" 1>&2
exit 1
fi
set -u
fi
"$HERE/check-dependency.sh" jq
ETCHER_VERSION=$(jq -r '.version' package.json)
TARGET_ARCHES="$HOST_ARCH"
if [ "$HOST_ARCH" == "x64" ]; then
if [ "$PLATFORM" == "linux" ] || [ "$PLATFORM" == "win32" ]; then
TARGET_ARCHES="$TARGET_ARCHES x86"
fi
fi
if [ "$PLATFORM" != "linux" ]; then
"$HERE/check-dependency.sh" make
fi
for ARCH in $TARGET_ARCHES; do
echo "Publishing Etcher v$ETCHER_VERSION production release for $PLATFORM/$ARCH"
run_make_target "$ARCH" publish-all
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment