mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-08 03:00:27 +08:00
改进编译脚本
This commit is contained in:
@@ -1,12 +1,19 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
function build() {
|
function build() {
|
||||||
VERSION_DATA=$(cat ../internal/const/const.go)
|
ROOT=$(dirname $0)
|
||||||
re="Version[ ]+=[ ]+\"([0-9.]+)\""
|
NAME="edge-node"
|
||||||
if [[ $VERSION_DATA =~ $re ]]; then
|
VERSION=$(lookup-version $ROOT/../internal/const/const.go)
|
||||||
VERSION=${BASH_REMATCH[1]}
|
DIST=$ROOT/"../dist/${NAME}"
|
||||||
else
|
OS=${1}
|
||||||
echo "could not match version"
|
ARCH=${2}
|
||||||
|
|
||||||
|
if [ -z $OS ]; then
|
||||||
|
echo "usage: build.sh OS ARCH"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
if [ -z $ARCH ]; then
|
||||||
|
echo "usage: build.sh OS ARCH"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -17,10 +24,8 @@ function build() {
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "building v${VERSION}/${1}/${2} ..."
|
echo "building v${VERSION}/${OS}/${ARCH} ..."
|
||||||
NAME="edge-node"
|
ZIP="${NAME}-${OS}-${ARCH}-v${VERSION}.zip"
|
||||||
DIST="../dist/${NAME}"
|
|
||||||
ZIP="${NAME}-${1}-${2}-v${VERSION}.zip"
|
|
||||||
|
|
||||||
echo "copying ..."
|
echo "copying ..."
|
||||||
if [ ! -d $DIST ]; then
|
if [ ! -d $DIST ]; then
|
||||||
@@ -30,12 +35,12 @@ function build() {
|
|||||||
mkdir $DIST/logs
|
mkdir $DIST/logs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp configs/api.template.yaml $DIST/configs
|
cp $ROOT/configs/api.template.yaml $DIST/configs
|
||||||
cp -R www $DIST/
|
cp -R $ROOT/www $DIST/
|
||||||
cp -R pages $DIST/
|
cp -R $ROOT/pages $DIST/
|
||||||
|
|
||||||
echo "building ..."
|
echo "building ..."
|
||||||
env GOOS=${1} GOARCH=${2} go build -o $DIST/bin/${NAME} -ldflags="-s -w" ../cmd/edge-node/main.go
|
env GOOS=${OS} GOARCH=${ARCH} go build -o $DIST/bin/${NAME} -ldflags="-s -w" $ROOT/../cmd/edge-node/main.go
|
||||||
|
|
||||||
echo "zip files"
|
echo "zip files"
|
||||||
cd "${DIST}/../" || exit
|
cd "${DIST}/../" || exit
|
||||||
@@ -49,4 +54,17 @@ function build() {
|
|||||||
echo "OK"
|
echo "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
build "linux" "amd64"
|
function lookup-version() {
|
||||||
|
FILE=$1
|
||||||
|
VERSION_DATA=$(cat $FILE)
|
||||||
|
re="Version[ ]+=[ ]+\"([0-9.]+)\""
|
||||||
|
if [[ $VERSION_DATA =~ $re ]]; then
|
||||||
|
VERSION=${BASH_REMATCH[1]}
|
||||||
|
echo $VERSION
|
||||||
|
else
|
||||||
|
echo "could not match version"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build $1 $2
|
||||||
|
|||||||
Reference in New Issue
Block a user