Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaofeng1227 committed Aug 18, 2023
1 parent 495f9ae commit d0f6099
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 54 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/upload_artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: upload_artifact
on:
workflow_dispatch:
push:
branches: [main]
branches: [main1]
paths:
- "version.json"

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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: /*
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/upload_test_artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion appmanage/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.10-slim
LABEL maintainer="Websoft9<[email protected]>"
LABEL version="0.8.14"
LABEL version="0.8.15"

# Create API Directory
WORKDIR /usr/src/app
Expand Down
17 changes: 17 additions & 0 deletions appmanage/api/service/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
43 changes: 22 additions & 21 deletions appmanage/api/service/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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 = ""
Expand Down
23 changes: 23 additions & 0 deletions appmanage/api/v1/routers/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)")):

Expand Down
Binary file modified appmanage/database.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion docker/w9appmanage/.env
Original file line number Diff line number Diff line change
@@ -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
5 changes: 0 additions & 5 deletions install/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -----------------"
Expand Down
3 changes: 1 addition & 2 deletions version.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -43,6 +43,5 @@
"18.04"
]
},
"RELEASE": "dev",
"VERSION": "0.8.18"
}

0 comments on commit d0f6099

Please sign in to comment.