改进编译脚本

This commit is contained in:
GoEdgeLab
2020-10-14 14:46:10 +08:00
parent 965fbe60e1
commit 59046aae19
6 changed files with 40 additions and 27 deletions

View File

@@ -3,7 +3,7 @@
function build() { function build() {
ROOT=$(dirname $0) ROOT=$(dirname $0)
NAME="edge-api" NAME="edge-api"
DIST="../dist/${NAME}" DIST=$ROOT/"../dist/${NAME}"
OS=${1} OS=${1}
ARCH=${2} ARCH=${2}
@@ -16,16 +16,30 @@ function build() {
exit exit
fi fi
VERSION_DATA=$(cat ../internal/const/const.go) VERSION=$(lookup-version $ROOT/../internal/const/const.go)
re="Version[ ]+=[ ]+\"([0-9.]+)\"" ZIP="${NAME}-${OS}-${ARCH}-v${VERSION}.zip"
if [[ $VERSION_DATA =~ $re ]]; then
VERSION=${BASH_REMATCH[1]} # check edge-node
else NodeVersion=$(lookup-version $ROOT"/../../EdgeNode/internal/const/const.go")
echo "could not match version" echo "building edge-node v${NodeVersion} ..."
EDGE_NODE_BUILD_SCRIPT=$ROOT"/../../EdgeNode/build/build.sh"
if [ ! -f $EDGE_NODE_BUILD_SCRIPT ]; then
echo "unable to find edge-node build script 'EdgeNode/build/build.sh'"
exit exit
fi fi
cd $ROOT"/../../EdgeNode/build"
echo "=============================="
architects=("amd64" "386")
for arch in "${architects[@]}"; do
./build.sh linux $arch
done
echo "=============================="
cd -
ZIP="${NAME}-${OS}-${ARCH}-v${VERSION}.zip" rm -f $ROOT/deploy/*.zip
for arch in "${architects[@]}"; do
cp $ROOT"/../../EdgeNode/dist/edge-node-linux-${arch}-v${NodeVersion}.zip" $ROOT/deploy/
done
# copy files # copy files
echo "copying ..." echo "copying ..."
@@ -35,10 +49,11 @@ function build() {
mkdir $DIST/configs mkdir $DIST/configs
mkdir $DIST/logs mkdir $DIST/logs
fi fi
cp configs/api.template.yaml $DIST/configs/ cp $ROOT/configs/api.template.yaml $DIST/configs/
cp configs/db.template.yaml $DIST/configs/ cp $ROOT/configs/db.template.yaml $DIST/configs/
cp -R deploy $DIST/ cp -R $ROOT/deploy $DIST/
cp -R installers $DIST/ rm -f $dist/deploy/.gitignore
cp -R $ROOT/installers $DIST/
# building installer # building installer
echo "building installer ..." echo "building installer ..."
@@ -63,4 +78,17 @@ function build() {
echo "[done]" echo "[done]"
} }
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 build $1 $2

Binary file not shown.

View File

@@ -1,2 +0,0 @@
nodeId: "${nodeId}"
secret: "${secret}"

View File

@@ -1,11 +0,0 @@
default:
db: "prod"
prefix: ""
dbs:
prod:
driver: "mysql"
dsn: "root:123456@tcp(127.0.0.1:3306)/db_edge?charset=utf8mb4&timeout=30s"
prefix: "edge"
models:
package: internal/web/models

View File

@@ -1 +0,0 @@
*.zip

View File

@@ -1 +0,0 @@
installer-*