7 changed files with 251 additions and 14 deletions
@ -0,0 +1 @@ |
|||||
|
IOTContainer/* |
||||
@ -1,28 +1,85 @@ |
|||||
kind: pipeline |
kind: pipeline |
||||
type: exec |
|
||||
|
type: docker |
||||
name: windows打包exe |
name: windows打包exe |
||||
host_aliases: |
host_aliases: |
||||
- ip: 192.168.0.2 |
- ip: 192.168.0.2 |
||||
hostnames: |
hostnames: |
||||
- git.1000my.com |
- git.1000my.com |
||||
platform: |
|
||||
os: windows |
|
||||
arch: amd64 |
|
||||
# version: 1809 |
|
||||
clone: |
clone: |
||||
pull: if-not-exists |
pull: if-not-exists |
||||
depth: 1 |
|
||||
|
|
||||
trigger: |
trigger: |
||||
branch: |
branch: |
||||
- master |
- master |
||||
event: |
event: |
||||
- push |
- push |
||||
|
|
||||
|
volumes: |
||||
|
- name: dockersock |
||||
|
host: |
||||
|
path: /data/drone/docker/sock |
||||
|
|
||||
steps: |
steps: |
||||
- name: greeting |
|
||||
commands: |
|
||||
- echo hello world |
|
||||
- ping git.1000my.com |
|
||||
- ipconfig |
|
||||
- makensis .\nbn.nsi |
|
||||
- ls |
|
||||
|
|
||||
|
- name: 生成Release版本 |
||||
|
pull: if-not-exists |
||||
|
image: registry.cn-hangzhou.aliyuncs.com/tgabc-namespace/tgabc:semantic-release-v21.0.1 |
||||
|
environment: |
||||
|
GITEA_TOKEN: |
||||
|
from_secret: gitea_token |
||||
|
settings: |
||||
|
git_login: |
||||
|
from_secret: gitea_username |
||||
|
git_password: |
||||
|
from_secret: gitea_password |
||||
|
|
||||
|
- name: 获取tag数据 |
||||
|
image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:alpine-git-v2.36.2 |
||||
|
commands: |
||||
|
- git fetch --tags |
||||
|
- git submodule init |
||||
|
- git submodule update --recursive --remote |
||||
|
# - git submodule add -b master https://git.1000my.com/project_runteng/server_iot-common.git |
||||
|
# - git mv server_iot-common iot-common |
||||
|
# - git submodule sync |
||||
|
- git describe --tags `git rev-list --tags --max-count=1` |
||||
|
|
||||
|
# 获取当前分支的tag |
||||
|
- git describe --abbrev=0 --tags > .tags |
||||
|
- cat .tags |
||||
|
|
||||
|
|
||||
|
- name: 编译 |
||||
|
pull: if-not-exists |
||||
|
image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:nsis20241212 |
||||
|
commands: |
||||
|
- makensis Sources/nbn.nsi |
||||
|
- ls Sources/Setup.exe |
||||
|
- du -sh Sources/Setup.exe |
||||
|
when: |
||||
|
branch: |
||||
|
- master |
||||
|
|
||||
|
|
||||
|
# - name: 上传zip到iot正式接口platformProgramAdd |
||||
|
# pull: if-not-exists |
||||
|
# image: registry.cn-hangzhou.aliyuncs.com/qmiot/init:apisix-init-base |
||||
|
# environment: |
||||
|
# url_for_iotplatform: 'http://192.168.0.11:31667' |
||||
|
# url_for_iotfile: 'http://192.168.0.11:31666' |
||||
|
# logo: '/drone/src/logo.jpg' |
||||
|
# cdn_url: 'https://qianmu-iot.1000my.com' |
||||
|
# # genre: "Samsung" |
||||
|
# commands: |
||||
|
# - export isiot="True" # 要不要传iot |
||||
|
# - export name="导视_正式版" # 应用名称(自行填写) |
||||
|
# - export version=$(cat .tags) # 应用版本 |
||||
|
# - export sourceId="3" # 应用来源id |
||||
|
# - export genre="localpack" # 应用类型 本地资源包 |
||||
|
# - export resolution="1920*1080横屏" # 分辨率(自行填写)[1080*1920竖屏, 1920*1080横屏, 3840*2160横屏, 2160*3840竖屏] |
||||
|
# - export package="/drone/src/target/$DRONE_REPO_NAME.$(cat .tags).zip" # zip包名称 |
||||
|
# - export des=$CI_COMMIT_MESSAGE # 应用描述 |
||||
|
# - python3 iot_upload.py |
||||
|
# when: |
||||
|
# branch: |
||||
|
# - master |
||||
@ -0,0 +1,4 @@ |
|||||
|
Dockerfile |
||||
|
nsWindows.nsh |
||||
|
TextReplace.nsh |
||||
|
Sources/Setup.exe |
||||
@ -0,0 +1,27 @@ |
|||||
|
{ |
||||
|
"branches": [ |
||||
|
"master", { |
||||
|
"name": "test", "prerelease": "beta" |
||||
|
} |
||||
|
], |
||||
|
"plugins": [ |
||||
|
["@semantic-release/commit-analyzer", { |
||||
|
"preset": "angular", |
||||
|
"releaseRules": [ |
||||
|
{"type": "docs", "scope":"README", "release": "patch"}, |
||||
|
{"type": "refactor", "release": "patch"}, |
||||
|
{"type": "style", "release": "patch"} |
||||
|
], |
||||
|
"parserOpts": { |
||||
|
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"] |
||||
|
} |
||||
|
}], |
||||
|
"@semantic-release/release-notes-generator", |
||||
|
"@semantic-release/git", |
||||
|
["@saithodev/semantic-release-gitea", { |
||||
|
"giteaUrl": "https://git.1000my.com", |
||||
|
"assets": [ |
||||
|
] |
||||
|
}] |
||||
|
] |
||||
|
} |
||||
@ -0,0 +1,148 @@ |
|||||
|
import json |
||||
|
import os |
||||
|
import requests |
||||
|
|
||||
|
|
||||
|
def file_write(file_name,text_content): |
||||
|
# charset() |
||||
|
file = open(file_name , "w") |
||||
|
file.write(str(text_content)) |
||||
|
file.close() |
||||
|
|
||||
|
|
||||
|
def dingtalk(cdn_url,packageUrl): |
||||
|
tpl_for_dingtalk=f''' |
||||
|
<font color=[TPL_STATUS_COLOR] size="3"> |
||||
|
下载地址: (<a href="{cdn_url}{packageUrl}" target="_blank">{cdn_url}{packageUrl}</a>) |
||||
|
</font> |
||||
|
|
||||
|
|
||||
|
 |
||||
|
|
||||
|
项目名称:[PLUGIN_TPL_REPO_SHORT_NAME] |
||||
|
|
||||
|
更新作者: [CI_COMMIT_AUTHOR_NAME] |
||||
|
|
||||
|
<font color=[TPL_STATUS_COLOR] size="3"> |
||||
|
更新内容:[TPL_COMMIT_MSG] |
||||
|
</font> |
||||
|
|
||||
|
[ [查看构建详情)]]([TPL_BUILD_LINK]) |
||||
|
|
||||
|
''' |
||||
|
print (tpl_for_dingtalk) |
||||
|
file_write("./.tpl",tpl_for_dingtalk) |
||||
|
|
||||
|
|
||||
|
def obsUpload(file,uploadType): |
||||
|
url_obsUpload = os.getenv('url_for_iotfile') + "/api/file/v1/attachment/obsUpload" |
||||
|
myfiles = {'file': open(file, 'rb')} |
||||
|
mydata = {'uploadType': uploadType} |
||||
|
r = requests.post(url_obsUpload, data=mydata, files=myfiles) |
||||
|
print (r.text) |
||||
|
json_str = r.text |
||||
|
info = json.loads(json_str)['data'] |
||||
|
return info |
||||
|
|
||||
|
# APP管理-新增APP |
||||
|
def platformAppAdd(): |
||||
|
# with open(".tags") as f: version = f.read().strip() |
||||
|
logoFile = obsUpload(file=str(os.getenv('logo')), uploadType='logo') |
||||
|
packageFile = obsUpload(file=str(os.getenv('package')),uploadType='compress') |
||||
|
bodyjson = { |
||||
|
'name': os.getenv('name'), |
||||
|
'version': os.getenv('version'), |
||||
|
'genre': os.getenv('genre'), |
||||
|
'logoCode': logoFile['code'], |
||||
|
'logoUrl': logoFile['url'], |
||||
|
'packageCode': packageFile['code'], |
||||
|
'packageUrl': packageFile['url'], |
||||
|
'des': os.getenv('des') |
||||
|
} |
||||
|
print (bodyjson) |
||||
|
url_platformAppAdd = os.getenv('url_for_iotplatform') + "/api/platform/v1/platformApp/platformAppAdd" |
||||
|
headers = {'content-type': 'application/json;charset=UTF-8'} |
||||
|
r = requests.post(url_platformAppAdd, headers=headers, data=json.dumps(bodyjson)) |
||||
|
print (r.text) |
||||
|
|
||||
|
cdn_url = os.getenv('cdn_url') |
||||
|
packageUrl = packageFile['url'] |
||||
|
dingtalk(cdn_url,packageUrl) |
||||
|
|
||||
|
|
||||
|
# 应用管理-授权(获取code list) |
||||
|
def getPlatformProgramList(): |
||||
|
bodyjson = { |
||||
|
'name': os.getenv('name'), |
||||
|
'version': os.getenv('version'), |
||||
|
'genre': os.getenv('genre'), |
||||
|
} |
||||
|
print (bodyjson) |
||||
|
url_platformAppAdd = os.getenv('url_for_iotplatform') + "/api/platform/v1/platformProgram/getPlatformProgramList/1/10" |
||||
|
headers = {'content-type': 'application/json;charset=UTF-8'} |
||||
|
r = requests.post(url_platformAppAdd, headers=headers, data=json.dumps(bodyjson)) |
||||
|
print (type(json.loads(r.text))) |
||||
|
print (json.loads(r.text)['data']["listObject"][0]['code']) |
||||
|
|
||||
|
return json.loads(r.text)['data']["listObject"][0]['code'] |
||||
|
|
||||
|
|
||||
|
# 应用管理-授权 |
||||
|
def multipleProgramToOneProject(): |
||||
|
codeList = getPlatformProgramList() |
||||
|
bodyjson = { |
||||
|
"projectCode": os.getenv('projectCode'), |
||||
|
"codeList": [codeList] |
||||
|
} |
||||
|
print (bodyjson) |
||||
|
url_platformAppAdd = os.getenv('url_for_iotplatform') + "/api/platform/v1/platformProgram/multipleProgramToOneProject" |
||||
|
headers = {'content-type': 'application/json;charset=UTF-8'} |
||||
|
r = requests.post(url_platformAppAdd, headers=headers, data=json.dumps(bodyjson)) |
||||
|
print (r.text) |
||||
|
|
||||
|
|
||||
|
# 应用管理-新增应用 |
||||
|
def platformProgramAdd(): |
||||
|
# with open(".tags") as f: version = f.read().strip() |
||||
|
logoFile = obsUpload(file=str(os.getenv('logo')), uploadType='logo') |
||||
|
packageFile = obsUpload(file=str(os.getenv('package')),uploadType='compress') |
||||
|
bodyjson = { |
||||
|
'name': os.getenv('name'), |
||||
|
'version': os.getenv('version'), |
||||
|
'genre': os.getenv('genre'), |
||||
|
'sourceId': os.getenv('sourceId'), |
||||
|
"resolution": os.getenv('resolution'), |
||||
|
'logoCode': logoFile['code'], |
||||
|
'logoUrl': logoFile['url'], |
||||
|
'packageCode': packageFile['code'], |
||||
|
'packageUrl': packageFile['url'], |
||||
|
'des': os.getenv('des') |
||||
|
} |
||||
|
print (bodyjson) |
||||
|
url_platformAppAdd = os.getenv('url_for_iotplatform') + "/api/platform/v1/platformProgram/platformProgramAdd" |
||||
|
headers = {'content-type': 'application/json;charset=UTF-8'} |
||||
|
r = requests.post(url_platformAppAdd, headers=headers, data=json.dumps(bodyjson)) |
||||
|
print (r.text) |
||||
|
cdn_url = os.getenv('cdn_url') |
||||
|
packageUrl = packageFile['url'] |
||||
|
dingtalk(cdn_url,packageUrl) |
||||
|
|
||||
|
# 自动授权 |
||||
|
# multipleProgramToOneProject() |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
if os.getenv("isiot") != 'False': |
||||
|
platformProgramAdd() |
||||
|
else: |
||||
|
print ("is not iot") |
||||
|
if os.getenv("DRONE_BRANCH") == 'master': |
||||
|
cdn_url = 'https://qianmu-iot.1000my.com/' |
||||
|
else: |
||||
|
cdn_url = 'https://test-598d.1000my.com/' |
||||
|
packageUrl = os.getenv('DRONE_REPO_NAMESPACE') + '-' + os.getenv('DRONE_REPO_NAME') + '-' + os.getenv('DRONE_BRANCH') + '/' + os.getenv('DRONE_REPO_NAME') + '.' + os.getenv('version')+ '.zip' |
||||
|
dingtalk(cdn_url,packageUrl) |
||||
|
|
||||
|
|
||||
|
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
Loading…
Reference in new issue