diff --git a/.github/workflows/upload_artifact.yml b/.github/workflows/upload_artifact.yml index 7ec568dd..42051308 100644 --- a/.github/workflows/upload_artifact.yml +++ b/.github/workflows/upload_artifact.yml @@ -3,7 +3,7 @@ name: upload_artifact on: workflow_dispatch: push: - branches: [main] + branches: [main1] paths: - "version.json" @@ -16,16 +16,8 @@ jobs: - uses: actions/checkout@v2 name: Check out code - - name: Read release mode - id: check_release - run: | - release=$(jq -r '.RELEASE' version.json) - echo $release - echo "::set-output name=release::$release" - - name: Read Plugin Version id: update_data - if: ${{ steps.check_release.outputs.release != 'dev' }} run: | version=$(jq -r '.VERSION' version.json) echo version=$version @@ -53,7 +45,6 @@ jobs: - name: Upload To Azure Blob uses: LanceMcCarthy/Action-AzureBlobUpload@v2 - if: ${{ steps.check_release.outputs.release != 'dev' }} with: connection_string: ${{ secrets.AZURE_STORAGE_ARTIFACT }} container_name: release @@ -64,7 +55,6 @@ jobs: - name: Create Release id: create_release - if: ${{ steps.check_release.outputs.release != 'dev' }} uses: softprops/action-gh-release@v1 with: files: /* diff --git a/.github/workflows/upload_test_artifact.yml b/.github/workflows/upload_test_artifact.yml index 27bd3cb9..7b3d0bd8 100644 --- a/.github/workflows/upload_test_artifact.yml +++ b/.github/workflows/upload_test_artifact.yml @@ -16,16 +16,8 @@ jobs: - uses: actions/checkout@v2 name: Check out code - - name: Read release mode - id: check_release - run: | - release=$(jq -r '.RELEASE' version.json) - echo $release - echo "::set-output name=release::$release" - - name: Read Plugin Version id: update_data - if: ${{ steps.check_release.outputs.release == 'dev' }} run: | version=$(jq -r '.VERSION' version.json) echo version=$version @@ -52,7 +44,6 @@ jobs: cp artifacts/websoft9-$version.zip artifacts/websoft9-latest.zip - name: Upload To Azure Blob - if: ${{ steps.check_release.outputs.release == 'dev' }} uses: LanceMcCarthy/Action-AzureBlobUpload@v2 with: connection_string: ${{ secrets.AZURE_STORAGE_ARTIFACT }} @@ -63,16 +54,15 @@ jobs: fail_if_source_empty: true - name: Create Release - if: ${{ steps.check_release.outputs.release == 'dev' }} id: create_release uses: softprops/action-gh-release@v1 with: files: /* - tag_name: v${{ env.VERSION }}-dev - title: Release-v${{ env.VERSION }}-dev + tag_name: v${{ env.VERSION }}-rc + title: Release-v${{ env.VERSION }}-rc body: ${{ steps.update_data.outputs.CHANGELOG }} draft: false - prerelease: true + prerelease: false # - name: Commit and push changes # uses: stefanzweifel/git-auto-commit-action@v4 diff --git a/appmanage/Dockerfile b/appmanage/Dockerfile index c2524901..9205883f 100644 --- a/appmanage/Dockerfile +++ b/appmanage/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.10-slim LABEL maintainer="Websoft9" -LABEL version="0.8.14" +LABEL version="0.8.15" # Create API Directory WORKDIR /usr/src/app diff --git a/appmanage/api/service/db.py b/appmanage/api/service/db.py index f020fc34..8724b13f 100644 --- a/appmanage/api/service/db.py +++ b/appmanage/api/service/db.py @@ -18,6 +18,23 @@ def AppUpdateUser(user_name, password): conn.commit() conn.close() +def AppUpdatePreview(preview): + conn = sqlite3.connect('/usr/src/app/db/database.sqlite') + cursor = conn.cursor() + cursor.execute("UPDATE app_preview SET preview=? WHERE module='appstore'", ( preview,)) + conn.commit() + conn.close() + +def AppSearchPreview(): + + conn = sqlite3.connect('/usr/src/app/db/database.sqlite') + conn.row_factory = dict_factory + cursor = conn.cursor() + cursor.execute("SELECT preview FROM app_preview WHERE module='appstore'", ()) + rows = cursor.fetchone() + conn.close() + return rows + def AppSearchUsers(user_type): if user_type == None or user_type == "undefine": raise CommandException(const.ERROR_CLIENT_PARAM_BLANK, "This plugin is blank!", "This plugin is blank!") diff --git a/appmanage/api/service/manage.py b/appmanage/api/service/manage.py index 45e050fd..6f62995d 100644 --- a/appmanage/api/service/manage.py +++ b/appmanage/api/service/manage.py @@ -35,21 +35,9 @@ # 使用指定的 Redis 连接创建 RQ 队列 q = Queue(connection=redis_conn, default_timeout=3600) -def get_release_version(version): - now = shell_execute.execute_command_output_all("cat /data/apps/websoft9/version.json")['result'] - now_release = json.loads(now)['RELEASE'] - if now_release == None or now_release == "dev": - dev_version = version + "-dev" - return dev_version - else: - return version - def get_release_url(): - now = shell_execute.execute_command_output_all("cat /data/apps/websoft9/version.json")['result'] - now_release = json.loads(now)['RELEASE'] - myLogger.info_logger("add now_release:") - myLogger.info_logger(now_release) - if now_release == None or now_release == "dev": + preview = db.AppSearchPreview().get("preview") + if preview == "false": return const.ARTIFACT_URL_DEV else: return const.ARTIFACT_URL @@ -78,6 +66,19 @@ def appstore_update(): # scheduler.add_job(add_hostname, 'interval', minutes=1) # scheduler.start() +def AppPreviewUpdate(preview): + myLogger.info_logger("AppPreviewUpdate") + if preview == "true" or preview == "True": + db.AppUpdatePreview(preview) + return "true" + elif preview == "false" or preview == "False": + db.AppUpdatePreview(preview) + return "false" + elif preview == None or preview == "" or preview == "undefine": + return db.AppSearchPreview().get("preview") + else: + raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "preview is true,false,blank", "preview is true,false,blank") + def AppAutoUpdate(auto_update): myLogger.info_logger("AppAutoUpdate") # myLogger.info_logger(scheduler.state) @@ -142,24 +143,24 @@ def AppStoreUpdate(): def get_update_list(): local_path = '/data/apps/websoft9/version.json' local_version = "0" - release_url = get_release_url() + try: op = shell_execute.execute_command_output_all("cat " + local_path)['result'] local_version = json.loads(op)['VERSION'] except: local_version = "0.0.0" - version_cmd = "wget -O version.json " + release_url + "/version.json && cat version.json" + version_cmd = "wget -O version.json " + const.ARTIFACT_URL + "/version.json && cat version.json" latest = shell_execute.execute_command_output_all(version_cmd)['result'] version = json.loads(latest)['VERSION'] ret = {} - ret['local_version'] = get_release_version(local_version) - ret['target_version'] = get_release_version(version) + ret['local_version'] = local_version + ret['target_version'] = version content = [] date = "" if compared_version(local_version, version) == -1: ret['update'] = True - cmd = "wget -O CHANGELOG.md " + release_url + "/CHANGELOG.md && cat CHANGELOG.md" + cmd = "wget -O CHANGELOG.md " + const.ARTIFACT_URL + "/CHANGELOG.md && cat CHANGELOG.md" change_log_contents = shell_execute.execute_command_output_all(cmd)['result'] change_log = change_log_contents.split('## ')[1].split('\n') date = change_log[0].split()[-1] @@ -188,8 +189,8 @@ def get_appstore_update_list(): latest = shell_execute.execute_command_output_all(version_cmd)['result'] version = json.loads(latest)['Version'] ret = {} - ret['local_version'] = get_release_version(local_version) - ret['target_version'] = get_release_version(version) + ret['local_version'] = local_version + ret['target_version'] = version content = [] date = "" core_compare = "" diff --git a/appmanage/api/v1/routers/apps.py b/appmanage/api/v1/routers/apps.py index b68c6875..5c315b10 100644 --- a/appmanage/api/v1/routers/apps.py +++ b/appmanage/api/v1/routers/apps.py @@ -433,6 +433,29 @@ def AppStoreUpdate(request: Request): return response +@router.api_route("/AppPreviewUpdate", methods=["GET", "POST"], summary="软件商店预览版更新", response_model=Response, response_description=rd_auto_list) +def AppPreviewUpdate(request: Request,preview: Optional[str] = Query(default=None, description="自动更新标志(可选值:true,false,None)")): + + try: + myLogger.info_logger("Receive request: /AppPreviewUpdate") + get_headers(request) + ret = {} + ret['ResponseData'] = {} + ret['ResponseData']['reviewUpdate'] = "api is not available" + response = JSONResponse(content=ret) + except CommandException as ce: + ret = {} + ret['ResponseData'] = {} + ret['Error'] = manage.get_error_info(ce.code, ce.message, ce.detail) + response = JSONResponse(content=ret) + except Exception as e: + ret = {} + ret['ResponseData'] = {} + ret['Error'] = manage.get_error_info(const.ERROR_SERVER_SYSTEM, "system original error", str(e)) + response = JSONResponse(content=ret) + + return response + @router.api_route("/AppAutoUpdate", methods=["GET", "POST"], summary="软件商店自动更新", response_model=Response, response_description=rd_auto_list) def AppAutoUpdate(request: Request,auto_update: Optional[str] = Query(default=None, description="自动更新标志(可选值:true,false,None)")): diff --git a/appmanage/database.sqlite b/appmanage/database.sqlite index 6575f7a0..0b88c5b6 100644 Binary files a/appmanage/database.sqlite and b/appmanage/database.sqlite differ diff --git a/docker/w9appmanage/.env b/docker/w9appmanage/.env index 4d7691c9..678a02a6 100644 --- a/docker/w9appmanage/.env +++ b/docker/w9appmanage/.env @@ -1,4 +1,4 @@ APP_NAME=websoft9-appmanage -APP_VERSION=0.8.14 +APP_VERSION=0.8.15 APP_HTTP_PORT=5000 APP_NETWORK=websoft9 diff --git a/install/update.sh b/install/update.sh index 302a2497..64bea734 100644 --- a/install/update.sh +++ b/install/update.sh @@ -9,11 +9,6 @@ function error_exit { trap 'error_exit "Please push issue to: https://github.com/Websoft9/websoft9/issues"' ERR urls="https://w9artifact.blob.core.windows.net/release/websoft9" -release=$(cat /data/apps/websoft9/version.json | jq .RELEASE | tr -d '"') -if [[ "$release" == "null" ]] || [[ "$release" == "dev" ]] || [[ -z "$release" ]]; then - echo "update by dev artifacts" - urls="https://w9artifact.blob.core.windows.net/dev/websoft9" -fi CheckEnv(){ echo "------------------ Welcome to update websoft9's appstore, it will take 1-3 minutes -----------------" diff --git a/version.json b/version.json index aef7d298..3ab6c363 100644 --- a/version.json +++ b/version.json @@ -2,7 +2,7 @@ "SERVICES": { "PORTAINER": "2.18.3", "NGINX": "2.10.3", - "APPMANAGE": "0.8.14", + "APPMANAGE": "0.8.15", "REDIS": "7.0.11" }, "PLUGINS": { @@ -43,6 +43,5 @@ "18.04" ] }, - "RELEASE": "dev", "VERSION": "0.8.18" } \ No newline at end of file