diff --git a/.drone.yml b/.drone.yml index 401aabb..4a8d8bb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -63,6 +63,17 @@ steps: files: - ./coverage/lcov.info +volumes: +- name: pub-cache + temp: {} +- name: gradle + temp: {} + +--- +kind: pipeline +name: publish + +steps: - name: publish-check image: v7lin/flutter:1.5.4-hotfix.2-stable volumes: @@ -70,12 +81,87 @@ steps: path: /opt/flutter/.pub-cache commands: - flutter packages pub publish --dry-run - when: - event: - - tag + +- name: restore-cache + image: alpine:3.9.3 + volumes: + - name: pub-cache + path: /opt/flutter/.pub-cache + commands: + - FLUTTER_HOME=/opt/flutter/.pub-cache + - wget -P $FLUTTER_HOME https://raw.githubusercontent.com/v7lin/pub_credentials/master/credentials.json.enc + +- name: restore-cache-openssl + image: v7lin/openssl:1.1.1b + volumes: + - name: pub-cache + path: /opt/flutter/.pub-cache + environment: + ENC_METHOD: + from_secret: ENC_METHOD + ENC_PASSWORD: + from_secret: ENC_PASSWORD + commands: + - FLUTTER_HOME=/opt/flutter/.pub-cache + - openssl enc -d -$ENC_METHOD -k $ENC_PASSWORD -in $FLUTTER_HOME/credentials.json.enc -out $FLUTTER_HOME/credentials.json + - rm $FLUTTER_HOME/credentials.json.enc + +- name: publish + image: v7lin/flutter:1.5.4-hotfix.2-stable + volumes: + - name: pub-cache + path: /opt/flutter/.pub-cache + commands: + - echo "y" | flutter packages pub publish + +- name: save-cache-openssl + image: v7lin/openssl:1.1.1b + volumes: + - name: pub-cache + path: /opt/flutter/.pub-cache + environment: + ENC_METHOD: + from_secret: ENC_METHOD + ENC_PASSWORD: + from_secret: ENC_PASSWORD + commands: + - FLUTTER_HOME=/opt/flutter/.pub-cache + - openssl enc -e -$ENC_METHOD -k $ENC_PASSWORD -in $FLUTTER_HOME/credentials.json -out $FLUTTER_HOME/credentials.json.enc + - rm /opt/flutter/.pub-cache/credentials.json + +- name: save-cache + image: docker:git + volumes: + - name: pub-cache + path: /opt/flutter/.pub-cache + environment: + GIT_USER_EMAIL: + from_secret: GIT_USER_EMAIL + GIT_USER_NAME: + from_secret: GIT_USER_NAME + GIT_USER_PASSWORD: + from_secret: GIT_USER_PASSWORD # 密码含'@',用'%40'替换 -> URLEncoder.encode("@","utf-8"); + commands: + - FLUTTER_HOME=/opt/flutter/.pub-cache + - git config --global user.email $GIT_USER_EMAIL + - git config --global user.name $GIT_USER_NAME + - git config --global credential.helper store + - git clone -b master https://$GIT_USER_NAME:$GIT_USER_PASSWORD@github.com/v7lin/pub_credentials.git $FLUTTER_HOME/pub_credentials + - rm $FLUTTER_HOME/pub_credentials/credentials.json.enc + - mv $FLUTTER_HOME/credentials.json.enc $FLUTTER_HOME/pub_credentials/credentials.json.enc + - cd $FLUTTER_HOME/pub_credentials + - git commit -am "update credentials by ci/cd tools" + - git push volumes: - name: pub-cache temp: {} -- name: gradle - temp: {} + +trigger: + status: + - success + event: + - tag + +depends_on: +- default diff --git a/CHANGELOG.md b/CHANGELOG.md index b46b8a5..37c6523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [0.2.0] - 2019.5.24 + +* 优化 +* 自动化发布 + ## [0.1.0] - 2019.3.19 * 规范 library 代码 diff --git a/README.md b/README.md index 49a0175..116a4db 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ flutter版新浪微博SDK ## fake 系列 libraries -* [flutter版okhttp3](https://github.com/v7lin/fake_http) * [flutter版微信SDK](https://github.com/v7lin/fake_wechat) * [flutter版腾讯(QQ)SDK](https://github.com/v7lin/fake_tencent) * [flutter版新浪微博SDK](https://github.com/v7lin/fake_weibo) diff --git a/example/lib/main.dart b/example/lib/main.dart index 82e98f6..7e2bda7 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -42,7 +42,11 @@ class _HomeState extends State { WeiboScope.ALL, ]; - Weibo _weibo = Weibo(); + Weibo _weibo = Weibo() + ..registerApp( + appKey: _WEIBO_APP_KEY, + scope: _WEIBO_SCOPE, + ); StreamSubscription _auth; StreamSubscription _share; @@ -52,10 +56,6 @@ class _HomeState extends State { @override void initState() { super.initState(); - _weibo.registerApp( - appKey: _WEIBO_APP_KEY, - scope: _WEIBO_SCOPE, - ); _auth = _weibo.authResp().listen(_listenAuth); _share = _weibo.shareMsgResp().listen(_listenShareMsg); } diff --git a/lib/src/weibo.dart b/lib/src/weibo.dart index 93969ae..c33ae02 100644 --- a/lib/src/weibo.dart +++ b/lib/src/weibo.dart @@ -74,10 +74,12 @@ class Weibo { } } + /// 登录 Stream authResp() { return _authRespStreamController.stream; } + /// 分享 Stream shareMsgResp() { return _shareMsgRespStreamController.stream; } @@ -86,6 +88,7 @@ class Weibo { return (await _channel.invokeMethod(_METHOD_ISWEIBOINSTALLED)) as bool; } + /// 登录 Future auth({ @required String appKey, @required List scope, @@ -103,6 +106,7 @@ class Weibo { ); } + /// 用户信息 Future getUserInfo({ @required String appkey, @required String userId, @@ -137,7 +141,6 @@ class Weibo { ) { params.putIfAbsent('source', () => appkey); params.putIfAbsent('access_token', () => accessToken); - Uri baseUri = Uri.parse(baseUrl); Map> queryParametersAll = Map>.of(baseUri.queryParametersAll); @@ -145,10 +148,10 @@ class Weibo { queryParametersAll.remove(key); queryParametersAll.putIfAbsent(key, () => [value]); }); - return baseUri.replace(queryParameters: queryParametersAll); } + /// 分享 - 文本 Future shareText({ @required String text, }) { @@ -161,6 +164,7 @@ class Weibo { ); } + /// 分享 - 图片 Future shareImage({ @required Uint8List imageData, }) { @@ -173,6 +177,7 @@ class Weibo { ); } + /// 分享 - 网页 Future shareWebpage({ @required String title, @required String description,