Skip to content

Commit d20ace1

Browse files
committed
chore: write a script to upload *.so to ali oss
1 parent d4cd332 commit d20ace1

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Diff for: requirement-dev.txt

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ yapf==0.23.0
22
twine==1.11.0
33
bumpversion==0.5.3
44
pytest==3.7.4
5+
oss2==2.5.0
6+
pycryptodome==3.6.6

Diff for: upload-ali-oss.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
import sys
3+
import ntpath
4+
import glob
5+
import configparser
6+
7+
import oss2
8+
9+
endpoint = 'http://{region}.aliyuncs.com'.format(region='oss-cn-shanghai')
10+
11+
bucket_name = 'lc-frontend'
12+
13+
if __name__ == '__main__':
14+
if len(sys.argv) >= 2:
15+
files = sys.argv[1:]
16+
else:
17+
files = glob.glob('build/lib/py_sourcemap/*.so')
18+
19+
config = configparser.ConfigParser()
20+
config.read('.bumpversion.cfg')
21+
package_version = config['bumpversion']['current_version']
22+
23+
access_key = os.environ.get('ALIYUN_ACCESS_KEY')
24+
access_token = os.environ.get('ALIYUN_ACCESS_TOKEN')
25+
26+
auth = oss2.Auth(access_key, access_token)
27+
bucket = oss2.Bucket(auth, endpoint, bucket_name)
28+
29+
for file_path in files:
30+
basename = ntpath.basename(file_path)
31+
fp = open(file_path, 'rb')
32+
target_key = 'packages/py_sourcemap/{version}/{name}'.format(
33+
version=package_version, name=basename)
34+
print('Uploading {}...'.format(target_key))
35+
bucket.put_object(target_key, fp.read())
36+
fp.close()
37+
print('Uploaded all.')

0 commit comments

Comments
 (0)