File tree Expand file tree Collapse file tree 6 files changed +63
-4
lines changed Expand file tree Collapse file tree 6 files changed +63
-4
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ build: &build
3232
3333deploy : &deploy
3434 docker :
35- - image : tsub/ghr :latest
35+ - image : broooooklyn/rust-python :latest
3636 working_directory : /mnt/crate
3737 steps :
3838 - attach_workspace :
@@ -43,7 +43,8 @@ deploy: &deploy
4343 if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
4444 then
4545 export GIT_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"; \
46- ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so
46+ ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so && \
47+ python upload-ali-oss.py
4748 else
4849 echo "Not a release, skipping publish"
4950 fi
Original file line number Diff line number Diff line change @@ -36,3 +36,9 @@ deploy:
3636 skip_cleanup : true
3737 on :
3838 tags : true
39+
40+ deploy :
41+ provider : script
42+ script : python upload-ali-oss.py
43+ on :
44+ tags : true
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ FROM ubuntu:18.04
22
33ARG PYTHON_VERSION=3.6
44
5+ ENV GHR_VERSION="0.9.0"
6+
57ENV RUSTUP_HOME=/usr/local/rustup \
68 CARGO_HOME=/usr/local/cargo \
79 PATH=/usr/local/cargo/bin:$PATH \
@@ -18,11 +20,19 @@ RUN apt-get update && \
1820 if [ $PYTHON_VERSION = '3.6' ]; \
1921 then \
2022 apt-get install python3-pip -y --no-install-recommends && \
21- ln -sf /usr/bin/pip3 /usr/bin/pip; \
23+ ln -sf /usr/bin/pip3 /usr/bin/pip && \
24+ pip install setuptools; \
2225 else \
2326 curl https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}; \
2427 fi && \
25- pip install --upgrade pip
28+ pip install --upgrade pip && \
29+ curl -fSL -o ghr.tar.gz "https://github.com/tcnksm/ghr/releases/download/v${GHR_VERSION}/ghr_v${GHR_VERSION}_linux_amd64.tar.gz" && \
30+ tar -xvzf ghr.tar.gz && \
31+ mv ghr_v${GHR_VERSION}_linux_amd64/ghr /usr/local/bin && \
32+ chown root:root /usr/local/bin/ghr && \
33+ rm -r \
34+ ghr.tar.gz \
35+ ghr_v${GHR_VERSION}_linux_amd64
2636
2737RUN set -eux; \
2838 dpkgArch="$(dpkg --print-architecture)" ; \
Original file line number Diff line number Diff line change @@ -74,6 +74,9 @@ artifacts:
7474 - path : build\lib\py_sourcemap\*.pyd
7575 name : Binary
7676
77+ before_deploy :
78+ - " %PYTHON%\\ python.exe upload-ali-oss.py"
79+
7780deploy :
7881 provider : GitHub
7982 description : $(APPVEYOR_REPO_TAG_NAME)
Original file line number Diff line number Diff line change @@ -2,3 +2,5 @@ yapf==0.23.0
22twine==1.11.0
33bumpversion==0.5.3
44pytest==3.7.4
5+ oss2==2.5.0
6+ pycryptodome==3.6.6
Original file line number Diff line number Diff line change 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.' )
You can’t perform that action at this time.
0 commit comments