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

chore(release) minor quality-of-life tweaks #310

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 65 additions & 10 deletions util/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,71 @@ OPENSSL_VER=${OPENSSL_VER:-$(get_variable_from_makefile OPENSSL)}
PCRE_VER=${PCRE_VER:-$(get_variable_from_makefile PCRE)}
ZLIB_VER=${ZLIB_VER:-$(get_variable_from_makefile ZLIB)}

show_help() {
cat << EOF
Generate release assets.

Usage:

$0 <name> --src
$0 <name> --bin [--wasmtime <ver>] [--wasmer <ver>] [--v8 <ver>]
$0 <name> --all [--match <pattern>]

Arguments:

<name> Release name.
Will appear in asset names as wasmx-NAME-RUNTIME-ARCH-OS.EXT

Release mode:

--src Produce source tarball.

--bin Produce binary package(s) for the currently running system.
Packages are built depending on the presence of the
runtime flags --wasmtime, --wasmer and/or --v8,
or the environment variables WASMTIME_VER, WASMER_V8 and/or V8_VER.

--all Produce source tarball and binary packages for all
supported runtimes and distros using container images.

More options (for --all, defaults are autodetected from the source Makefile):

--wasmtime <ver> Set Wasmtime version.
--wasmer <ver> Set Wasmer version.
--v8 <ver> Set V8 version.
--ngx <ver> Set Nginx version.

--match <pattern> (--all only) Only container images whose names
match <pattern> will be used.

EOF
}

while (( "$#" )); do
case "$1" in
--help)
show_help
exit 0
;;
--src)
RELEASE_SOURCE=1
RELEASE_MODE=src
shift
;;
--bin-all)
RELEASE_BIN_ALL=1
--all|--bin-all)
RELEASE_MODE=all
shift
;;
--bin)
RELEASE_BIN=1
RELEASE_MODE=bin
shift
;;
--match)
MATCH_DOCKERFILES="$2"
if [ -z "$MATCH_DOCKERFILES" ]; then
fatal "--match argument missing a pattern to match Dockerfiles"
fi
shift 2
;;
--ngx)
NGX_VER="$2"
if [ -z "$NGX_VER" ]; then
Expand Down Expand Up @@ -76,7 +127,7 @@ if [ -z "$name" ]; then
name=$RELEASE_NAME

if [ -z "$name" ]; then
fatal "$SCRIPT_NAME missing release name argument/env variable"
fatal "$SCRIPT_NAME missing release name argument/env variable. Try --help."
fi
fi

Expand Down Expand Up @@ -332,7 +383,11 @@ release_all_bin_docker() {
V8_VER=$(get_variable_from_makefile V8)
fi

for path in $DIR_BUILD_DOCKERFILES/Dockerfile.*; do
dockerfiles=(`echo $DIR_BUILD_DOCKERFILES/Dockerfile.* \
| tr ' ' '\n' \
| grep "$MATCH_DOCKERFILES"`)

for path in $dockerfiles; do
local dockerfile=$(basename $path)
local imgname=${dockerfile#"Dockerfile."}
local imgtag=wasmx-build-$imgname
Expand Down Expand Up @@ -388,26 +443,26 @@ cp -R \

# produce release artifact

if [ -n "$RELEASE_SOURCE" ]; then
if [ "$RELEASE_MODE" = "src" ]; then
release_source

elif [ -n "$RELEASE_BIN_ALL" ]; then
elif [ "$RELEASE_MODE" = "all" ]; then
release_source

case $OSTYPE in
linux*) release_all_bin_docker;;
*) fatal "cannot build release from docker images on \"$OSTYPE\""
esac

elif [ -n "$RELEASE_BIN" ]; then
elif [ "$RELEASE_MODE" = "bin" ]; then
case $OSTYPE in
linux*) release_bin;;
darwin*) release_bin;;
*) fatal "unsupported OS \"$OSTYPE\""
esac

else
fatal "missing release type, specify --bin, --bin-all, or --src"
fatal "missing release mode, specify --src, --bin or --all"
fi

# vim: ft=sh ts=4 sts=4 sw=4: