Add release target to generate compiled version archive
This commit is contained in:
parent
8c6c0e12b2
commit
c7d4215be8
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
/vendor
|
||||
/bin
|
||||
/.env
|
||||
/.env
|
||||
/release
|
7
Makefile
7
Makefile
@ -29,11 +29,14 @@ install-devtools: vendor
|
||||
GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
|
||||
clean:
|
||||
rm -rf ./bin
|
||||
rm -rf ./bin ./release
|
||||
go clean -i -x -r -modcache
|
||||
|
||||
doc:
|
||||
@echo "Open your browser to http://localhost:6060/pkg/forge.cadoles.com/Pyxis/orion/ to see the documentation"
|
||||
@godoc -http=:6060
|
||||
|
||||
.PHONY: test clean generate vendor install-devtools lint watch tidy doc
|
||||
release:
|
||||
scripts/release
|
||||
|
||||
.PHONY: test clean generate vendor install-devtools lint watch tidy doc release
|
@ -1,4 +1,4 @@
|
||||
# Example: ReachView
|
||||
# Example: Configurator
|
||||
|
||||
A simple example of a ReachView client that can:
|
||||
|
||||
@ -10,7 +10,7 @@ A simple example of a ReachView client that can:
|
||||
|
||||
2. Launch the example:
|
||||
```shell
|
||||
go run example/reachview/main.go \
|
||||
go run cmd/configurator/main.go \
|
||||
-mode 'rover|base'\
|
||||
-host '<DEVICE_IP_ADDRESS'\
|
||||
```
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
timeout = 5 * time.Second
|
||||
timeout = 10 * time.Second
|
||||
)
|
||||
|
||||
func init() {
|
@ -11,7 +11,7 @@ A simple example of an updater client wich can:
|
||||
|
||||
2. Launch the example in `configure-wifi` phase and provides WiFi network informations.
|
||||
```shell
|
||||
go run example/updater/main.go \
|
||||
go run cmd/updater/main.go \
|
||||
-phase 'configure-wifi'\
|
||||
-host '<DEVICE_IP_ADDRESS'\
|
||||
-ssid '<WIFI_SSID>'\
|
||||
@ -21,7 +21,7 @@ A simple example of an updater client wich can:
|
||||
3. The device will switch to the provided WiFi network, as you should do.
|
||||
4. Launch the example in `update-then-reboot` phase.
|
||||
```shell
|
||||
go run example/updater/main.go \
|
||||
go run cmd/updater/main.go \
|
||||
-phase 'update-and-reboot'\
|
||||
-host '<DEVICE_IP_ADDRESS'
|
||||
```
|
118
scripts/release
Executable file
118
scripts/release
Executable file
@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
export GO111MODULE=on
|
||||
|
||||
OS_TARGETS=(windows linux)
|
||||
ARCH_TARGETS=(amd64)
|
||||
|
||||
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"
|
||||
|
||||
local ext=
|
||||
[ "$os" == "windows" ] && ext=.exe
|
||||
|
||||
rm -rf "$destdir"
|
||||
mkdir -p "$destdir"
|
||||
|
||||
echo "building $dirname..."
|
||||
|
||||
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build \
|
||||
-v \
|
||||
-mod=vendor \
|
||||
-ldflags="-s -w" \
|
||||
-gcflags=-trimpath="${PWD}" \
|
||||
-asmflags=-trimpath="${PWD}" \
|
||||
-o "$destdir/$name$ext" \
|
||||
"$srcdir"
|
||||
|
||||
if [ ! -z "$(which upx)" ]; then
|
||||
upx --best "$destdir/$name$ext"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
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_updater {
|
||||
|
||||
local os=$1
|
||||
local arch=$2
|
||||
|
||||
build 'updater' "$DIR/../cmd/updater" $os $arch
|
||||
compress 'updater' $os $arch
|
||||
|
||||
}
|
||||
|
||||
function release_discovery {
|
||||
|
||||
local os=$1
|
||||
local arch=$2
|
||||
|
||||
build 'discovery' "$DIR/../cmd/discovery" $os $arch
|
||||
compress 'discovery' $os $arch
|
||||
|
||||
}
|
||||
|
||||
function release_configurator {
|
||||
|
||||
local os=$1
|
||||
local arch=$2
|
||||
|
||||
build 'configurator' "$DIR/../cmd/configurator" $os $arch
|
||||
compress 'configurator' $os $arch
|
||||
|
||||
}
|
||||
|
||||
|
||||
function main {
|
||||
for os in ${OS_TARGETS[@]}; do
|
||||
for arch in ${ARCH_TARGETS[@]}; do
|
||||
release_configurator $os $arch
|
||||
release_updater $os $arch
|
||||
release_discovery $os $arch
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
main
|
Reference in New Issue
Block a user