Skip to content

Commit 28b8f68

Browse files
committed
add: 加入了action自动发布
1 parent 675c056 commit 28b8f68

File tree

5 files changed

+237
-0
lines changed

5 files changed

+237
-0
lines changed

.github/workflows/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: release
2+
3+
on:
4+
push:
5+
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
workflow_dispatch:
10+
11+
jobs:
12+
run-script:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.9'
19+
- run: pip install -r requirements.txt
20+
- run: python main.py
21+
22+
- uses: ncipollo/release-action@v1
23+
with:
24+
artifacts: "package_air_index.json"
25+
tag: "Nightly"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
132+
.idea/

main.py

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# 导入requests库
2+
import requests
3+
import json
4+
import hashlib
5+
import os
6+
7+
packagesPath = "package_air_index.json"
8+
9+
GCCVersion = "12.2.1-1.2"
10+
AirISPVersion = "1.1.1.0"
11+
CMSISVersion = "5.7.0"
12+
PlatformsVersion = ["0.0.1"]
13+
14+
15+
def ComputeSHA256(path):
16+
path = "temp/" + path
17+
with open(path, "rb") as f:
18+
# 读取文件内容
19+
data = f.read()
20+
# 计算SHA256值
21+
sha256 = hashlib.sha256(data).hexdigest()
22+
# 打印SHA256值
23+
print("The SHA256 of", path, "is", sha256)
24+
return sha256
25+
26+
27+
def ComputeSize(path):
28+
path = "temp/" + path
29+
# 获取文件大小,单位为字节
30+
file_size = os.path.getsize(path)
31+
# 打印文件大小
32+
print("The size of", path, "is", file_size, "bytes")
33+
return str(file_size)
34+
35+
36+
def downloadFile(url):
37+
# 定义文件名
38+
filename = url.split("/")[-1]
39+
40+
# 定义保存路径
41+
save_path = "temp/" + filename
42+
43+
# 发送get请求,获取文件内容
44+
response = requests.get(url)
45+
46+
# 判断响应状态码是否为200,表示成功
47+
if response.status_code == 200:
48+
# 打开文件,以二进制写入模式
49+
with open(save_path, "wb") as f:
50+
# 写入文件内容
51+
f.write(response.content)
52+
# 打印成功信息
53+
print("File downloaded and saved to", save_path)
54+
else:
55+
# 打印失败信息
56+
print("Failed to download file, status code:", response.status_code)
57+
58+
59+
def DownloadAndCheck(url, fileName, host, suffixName):
60+
temp = {}
61+
url += fileName
62+
temp['host'] = host
63+
tempUrl = url + suffixName
64+
downloadFile(tempUrl)
65+
temp['url'] = tempUrl
66+
print(tempUrl)
67+
temp['archiveFileName'] = fileName + suffixName
68+
tempPath = fileName + suffixName
69+
temp['checksum'] = "SHA-256:" + ComputeSHA256(tempPath)
70+
temp['size'] = ComputeSize(tempPath)
71+
return temp
72+
73+
74+
def GCC():
75+
data = {'name': "xpack-arm-none-eabi-gcc", 'version': GCCVersion}
76+
system = []
77+
78+
def f(host, suffixName):
79+
url = "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v" + GCCVersion + "/"
80+
fileName = "xpack-arm-none-eabi-gcc-" + GCCVersion + "-"
81+
return DownloadAndCheck(url, fileName, host, suffixName)
82+
83+
temp = f("x86_64-mingw32", "win32-x64.zip")
84+
system.append(temp)
85+
temp = f("i686-mingw32", "win32-x64.zip")
86+
system.append(temp)
87+
temp = f("x86_64-apple-darwin", "darwin-x64.tar.gz")
88+
system.append(temp)
89+
temp = f("arm64-apple-darwin", "darwin-arm64.tar.gz")
90+
system.append(temp)
91+
temp = f("arm-linux-gnueabihf", "linux-arm.tar.gz")
92+
system.append(temp)
93+
temp = f("aarch64-linux-gnu", "linux-arm64.tar.gz")
94+
system.append(temp)
95+
temp = f("x86_64-pc-linux-gnu", "linux-x64.tar.gz")
96+
system.append(temp)
97+
data['systems'] = system
98+
return data
99+
100+
101+
def AirISP():
102+
data = {'name': "AirISP", 'version': AirISPVersion}
103+
system = []
104+
105+
def f(host, suffixName):
106+
url = "https://github.com/Air-duino/AirISP/releases/download/" + AirISPVersion + "/"
107+
fileName = "AirISP-"
108+
return DownloadAndCheck(url, fileName, host, suffixName)
109+
110+
temp = f("x86_64-mingw32", "win-x64.zip")
111+
system.append(temp)
112+
temp = f("i686-mingw32", "win-x64.zip")
113+
system.append(temp)
114+
temp = f("x86_64-apple-darwin", "osx-x64.zip")
115+
system.append(temp)
116+
temp = f("arm64-apple-darwin", "osx-arm64.zip")
117+
system.append(temp)
118+
temp = f("arm-linux-gnueabihf", "linux-arm.zip")
119+
system.append(temp)
120+
temp = f("aarch64-linux-gnu", "linux-arm64.zip")
121+
system.append(temp)
122+
temp = f("x86_64-pc-linux-gnu", "linux-x64.zip")
123+
system.append(temp)
124+
data['systems'] = system
125+
print(data)
126+
return data
127+
128+
129+
def CMSIS():
130+
data = {'name': "CMSIS", 'version': CMSISVersion}
131+
system = []
132+
133+
def f(host, suffixName):
134+
url = "https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/" + CMSISVersion + "/"
135+
fileName = "CMSIS-" + CMSISVersion
136+
return DownloadAndCheck(url, fileName, host, suffixName)
137+
138+
temp = f("x86_64-mingw32", ".tar.bz2")
139+
system.append(temp)
140+
temp = f("i686-mingw32", ".tar.bz2")
141+
system.append(temp)
142+
temp = f("x86_64-apple-darwin", ".tar.bz2")
143+
system.append(temp)
144+
temp = f("arm64-apple-darwin", ".tar.bz2")
145+
system.append(temp)
146+
temp = f("arm-linux-gnueabihf", ".tar.bz2")
147+
system.append(temp)
148+
temp = f("aarch64-linux-gnu", ".tar.bz2")
149+
system.append(temp)
150+
temp = f("x86_64-pc-linux-gnu", ".tar.bz2")
151+
system.append(temp)
152+
data['systems'] = system
153+
print(data)
154+
return data
155+
156+
157+
def PlatformsAirMCU(version):
158+
fileName = "AirMCU-" + version + ".zip"
159+
url = "https://github.com/Air-duino/Arduino-AirMCU/releases/download/" + version + "/" + fileName
160+
downloadFile(url)
161+
data = {}
162+
data['name'] = "Air MCU"
163+
data['architecture'] = "AirMCU"
164+
data['version'] = version
165+
data['category'] = "Contributed"
166+
data['help'] = {'online': "https://github.com/Air-duino/Arduino-AirMCU"}
167+
data['url'] = url
168+
data['archiveFileName'] = fileName
169+
data['checksum'] = "SHA-256:" + ComputeSHA256(fileName)
170+
data['size'] = ComputeSize(fileName)
171+
data['boards'] = [{'name': "Air001"}]
172+
data['toolsDependencies'] = [{'packager': "AirM2M", 'name': "xpack-arm-none-eabi-gcc", 'version': GCCVersion},
173+
{'packager': "AirM2M", 'name': "CMSIS", 'version': CMSISVersion},
174+
{'packager': "AirM2M", 'name': "AirISP", 'version': AirISPVersion}]
175+
return data
176+
177+
178+
def PackagesAirM2M():
179+
data = {}
180+
data['name'] = "AirM2M"
181+
data['maintainer'] = "AirM2M"
182+
data['websiteURL'] = "https://github.com/Air-duino"
183+
data['email'] = "[email protected]"
184+
data['help'] = {'online': "https://github.com/Air-duino"}
185+
platforms = []
186+
for item in PlatformsVersion:
187+
platforms.append(PlatformsAirMCU(item))
188+
data['platforms'] = platforms
189+
tools = [GCC(), CMSIS(), AirISP()]
190+
data['tools'] = tools
191+
return data
192+
193+
194+
def Encode():
195+
data = {}
196+
data['packages'] = [PackagesAirM2M()]
197+
json_str = json.dumps(data, indent=2)
198+
with open(packagesPath, "w+") as f:
199+
f.write(json_str)
200+
return json_str
201+
202+
203+
def main():
204+
print(Encode())
205+
206+
207+
if __name__ == '__main__':
208+
main()

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests~=2.28.1

temp/temp file path.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)