From f556de44d7e31f54efd348ef224417684314391b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Thu, 4 Jul 2024 11:45:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release-drafter.yml | 37 ++++++++++++----------- cn-quick_start.sh | 1 - quick_start.sh | 1 - scripts/utils.sh | 43 +++++++++++++++++++-------- 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 296b7ca0..0c0047ac 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -7,40 +7,41 @@ on: name: Create Release And Upload assets jobs: - create-realese: + create-release: # 修正了拼写错误 name: Create Release runs-on: ubuntu-latest outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + - name: Get version id: get_version run: | TAG=$(basename ${GITHUB_REF}) - VERSION=${TAG/v/} - echo "::set-output name=TAG::$TAG" - echo "::set-output name=VERSION::$VERSION" + echo "TAG=$TAG" >> $GITHUB_OUTPUT + - name: Create Release id: create_release - uses: release-drafter/release-drafter@v5 + uses: release-drafter/release-drafter@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: config-name: release-config.yml version: ${{ steps.get_version.outputs.TAG }} tag: ${{ steps.get_version.outputs.TAG }} - - build-and-release: - needs: create-realese - name: Build and Release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Build it and upload - uses: jumpserver/action-build-upload-assets@master + + - name: Create Upload Assets + run: | + mkdir -p build jumpserver-installer-${{ steps.get_version.outputs.TAG }} + git archive --format tar HEAD | tar x -C jumpserver-installer-${{ steps.get_version.outputs.TAG }} + tar -czf build/jumpserver-installer-${{ steps.get_version.outputs.TAG }}.tar.gz jumpserver-installer-${{ steps.get_version.outputs.TAG }} + cd build + md5sum jumpserver-installer-${{ steps.get_version.outputs.TAG }}.tar.gz > jumpserver-installer-${{ steps.get_version.outputs.TAG }}.tar.gz.md5 + + - name: Release Upload Assets + run: | + gh release upload ${{ steps.get_version.outputs.TAG }} build/* -R $GITHUB_REPOSITORY env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-realese.outputs.upload_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/cn-quick_start.sh b/cn-quick_start.sh index c3542458..ace0470b 100644 --- a/cn-quick_start.sh +++ b/cn-quick_start.sh @@ -50,7 +50,6 @@ function get_installer() { function config_installer() { cd /opt/jumpserver-installer-${VERSION} || exit 1 - sed -i "s/VERSION=.*/VERSION=${VERSION}/g" /opt/jumpserver-installer-${VERSION}/static.env sed -i "s/# DOCKER_IMAGE_MIRROR=1/DOCKER_IMAGE_MIRROR=1/g" /opt/jumpserver-installer-${VERSION}/config-example.txt ./jmsctl.sh install ./jmsctl.sh start diff --git a/quick_start.sh b/quick_start.sh index 88b4e82b..c9291e82 100644 --- a/quick_start.sh +++ b/quick_start.sh @@ -50,7 +50,6 @@ function get_installer() { function config_installer() { cd /opt/jumpserver-installer-${VERSION} || exit 1 - sed -i "s/VERSION=.*/VERSION=${VERSION}/g" /opt/jumpserver-installer-${VERSION}/static.env ./jmsctl.sh install ./jmsctl.sh start } diff --git a/scripts/utils.sh b/scripts/utils.sh index aa4a510f..185bb0e0 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -108,21 +108,38 @@ function disable_config() { } function check_db_data() { - db_type=$1 - if [[ ! -f "${CONFIG_FILE}" ]]; then - return - fi - volume_dir=$(get_config VOLUME_DIR) - db_name=$(get_config DB_NAME) - if [[ -d "${volume_dir}/${db_type}/data/${db_name}" ]]; then - echo "1" - fi + db_type=$1 + if [[ ! -f "${CONFIG_FILE}" ]]; then + return + fi + volume_dir=$(get_config VOLUME_DIR) + if [[ -d "${volume_dir}/${db_type}/data" ]]; then + echo "1" + else + echo "0" + fi } function get_db_info() { info_type=$1 - mysql_data_exists=$(check_db_data "mysql") - mariadb_data_exists=$(check_db_data "mariadb") + db_engine=$(get_config DB_ENGINE "mysql") + db_host=$(get_config DB_HOST) + + mysql_data_exists="0" + mariadb_data_exists="0" + postgres_data_exists="0" + + case "${db_engine}" in + "mysql") + if [[ "${db_host}" == "mysql" ]]; then + mysql_data_exists=$(check_db_data "mysql") + fi + mariadb_data_exists="1" + ;; + "postgresql") + postgres_data_exists="1" + ;; + esac case "${info_type}" in "image") @@ -130,7 +147,7 @@ function get_db_info() { echo "mysql:5.7" elif [[ "${mariadb_data_exists}" == "1" ]]; then echo "mariadb:10.6" - else + elif [[ "${postgres_data_exists}" == "1" ]]; then echo "postgres:16.3-bullseye" fi ;; @@ -139,7 +156,7 @@ function get_db_info() { echo "compose/mysql.yml" elif [[ "${mariadb_data_exists}" == "1" ]]; then echo "compose/mariadb.yml" - else + elif [[ "${postgres_data_exists}" == "1" ]]; then echo "compose/postgres.yml" fi ;;