From 49ccec8ae818628242e60a4bce5886fb981adbbe Mon Sep 17 00:00:00 2001 From: zijiren233 Date: Wed, 10 Jan 2024 16:03:41 +0800 Subject: [PATCH] Fix: build only flag --- .github/workflows/build.yml | 6 +++--- scripts/build.sh | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 43daaa1..92c5d43 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: build on: push: - branches: ["main"] + branches: ["master"] pull_request: - branches: ["main"] + branches: ["master"] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -23,4 +23,4 @@ jobs: - name: Build run: | - bash scripts/build.sh + bash scripts/build.sh -h diff --git a/scripts/build.sh b/scripts/build.sh index 5066ee9..e78ebf3 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -18,6 +18,29 @@ function Init() { fi } +function Help() { + echo "-h: help" + echo "-t: test build only" +} + +function ParseArgs() { + while getopts "ht" arg; do + case $arg in + h) + Help + exit 0 + ;; + t) + TEST_BUILD_ONLY="1" + ;; + ?) + echo "unkonw argument" + exit 1 + ;; + esac + done +} + function Build() { TARGET="$1" make TARGET=${TARGET} GCC_VER="11.4.0" \ @@ -35,13 +58,16 @@ function Build() { echo "build ${TARGET} error" exit 1 fi - rm -rf output/${TARGET} - tar -zcvf ${DIST}/${TARGET}.tgz output/* - if [ $? -ne 0 ]; then - echo "package ${TARGET} error" - exit 1 + if [ ! "$TEST_BUILD_ONLY" ]; then + rm -rf output/${TARGET} + tar -zcvf ${DIST}/${TARGET}.tgz output/* + if [ $? -ne 0 ]; then + echo "package ${TARGET} error" + exit 1 + fi fi rm -rf output/* + rm -rf build/* } ALL_TARGETS='aarch64-linux-musl @@ -98,4 +124,5 @@ function BuildAll() { ChToScriptFileDir Init +ParseArgs "$@" BuildAll