This repository has been archived on 2024-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
orion/script/release
William Petit 713ca17c62
Some checks reported errors
Pyxis/orion/feature%2Fjsonrpc-next Something is wrong with the build of this commit
Pyxis/orion/pipeline/head Something is wrong with the build of this commit
LaCanne/orion/pipeline/head Something is wrong with the build of this commit
WIP: JSONRPC server refactoring
2019-02-12 10:17:06 +01:00

83 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -eo pipefail
OS_TARGETS=(linux)
ARCH_TARGETS=(arm)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
function build {
local name=$1
local srcdir=$2
local os=$3
local arch=$4
local dirname="$name-$os-$arch"
local destdir="$DIR/../release/$dirname"
rm -rf "$destdir"
mkdir -p "$destdir"
echo "building $dirname..."
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -ldflags="-s -w" -o "$destdir/$name" "$srcdir"
}
function copy {
local name=$1
local os=$2
local arch=$3
local src=$4
local dest=$5
local dirname="$name-$os-$arch"
local destdir="$DIR/../release/$dirname"
echo "copying '$src' to '$destdir/$dest'..."
mkdir -p "$(dirname $destdir/$dest)"
cp -rfL $src "$destdir/$dest"
}
function compress {
local name=$1
local os=$2
local arch=$3
local dirname="$name-$os-$arch"
local destdir="$DIR/../release/$dirname"
echo "compressing $dirname..."
tar -czf "$destdir.tar.gz" -C "$destdir/../" "$dirname"
}
function release_server {
local os=$1
local arch=$2
build 'server' "$DIR/../cmd/server" $os $arch
copy 'server' $os $arch "$DIR/../README.md" "README.md"
copy 'server' $os $arch "$DIR/../cmd/server/static/dist" "static"
copy 'server' $os $arch "$DIR/../cmd/server/templates" "templates"
compress 'server' $os $arch
}
function main {
for os in ${OS_TARGETS[@]}; do
for arch in ${ARCH_TARGETS[@]}; do
release_server $os $arch
done
done
}
main