diff --git a/build/build.sh b/build/build.sh index 5f55ab47..604e1997 100755 --- a/build/build.sh +++ b/build/build.sh @@ -3,7 +3,7 @@ function build() { ROOT=$(dirname $0) NAME="edge-api" - DIST="../dist/${NAME}" + DIST=$ROOT/"../dist/${NAME}" OS=${1} ARCH=${2} @@ -16,16 +16,30 @@ function build() { exit fi - VERSION_DATA=$(cat ../internal/const/const.go) - re="Version[ ]+=[ ]+\"([0-9.]+)\"" - if [[ $VERSION_DATA =~ $re ]]; then - VERSION=${BASH_REMATCH[1]} - else - echo "could not match version" + VERSION=$(lookup-version $ROOT/../internal/const/const.go) + ZIP="${NAME}-${OS}-${ARCH}-v${VERSION}.zip" + + # check edge-node + NodeVersion=$(lookup-version $ROOT"/../../EdgeNode/internal/const/const.go") + 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 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 echo "copying ..." @@ -35,10 +49,11 @@ function build() { mkdir $DIST/configs mkdir $DIST/logs fi - cp configs/api.template.yaml $DIST/configs/ - cp configs/db.template.yaml $DIST/configs/ - cp -R deploy $DIST/ - cp -R installers $DIST/ + cp $ROOT/configs/api.template.yaml $DIST/configs/ + cp $ROOT/configs/db.template.yaml $DIST/configs/ + cp -R $ROOT/deploy $DIST/ + rm -f $dist/deploy/.gitignore + cp -R $ROOT/installers $DIST/ # building installer echo "building installer ..." @@ -63,4 +78,17 @@ function build() { 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 diff --git a/dist/edge-api/bin/edge-api b/dist/edge-api/bin/edge-api deleted file mode 100755 index bd808a9f..00000000 Binary files a/dist/edge-api/bin/edge-api and /dev/null differ diff --git a/dist/edge-api/configs/api.template.yaml b/dist/edge-api/configs/api.template.yaml deleted file mode 100644 index 3b9713a6..00000000 --- a/dist/edge-api/configs/api.template.yaml +++ /dev/null @@ -1,2 +0,0 @@ -nodeId: "${nodeId}" -secret: "${secret}" \ No newline at end of file diff --git a/dist/edge-api/configs/db.template.yaml b/dist/edge-api/configs/db.template.yaml deleted file mode 100644 index 7696ed29..00000000 --- a/dist/edge-api/configs/db.template.yaml +++ /dev/null @@ -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 diff --git a/dist/edge-api/deploy/.gitignore b/dist/edge-api/deploy/.gitignore deleted file mode 100644 index 6f66c74b..00000000 --- a/dist/edge-api/deploy/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.zip \ No newline at end of file diff --git a/dist/edge-api/installers/.gitignore b/dist/edge-api/installers/.gitignore deleted file mode 100644 index 6997afc8..00000000 --- a/dist/edge-api/installers/.gitignore +++ /dev/null @@ -1 +0,0 @@ -installer-* \ No newline at end of file