1 | #!/bin/bash
|
2 | set -e
|
3 |
|
4 | if ! [ -x "$(command -v ossutil)" ]; then
|
5 |
|
6 | case "$OSTYPE" in
|
7 | darwin*)
|
8 |
|
9 | if ! [ -x "$(command -v brew)" ]; then
|
10 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
11 | fi
|
12 | brew tap vangie/formula
|
13 | brew install ossutil
|
14 | ;;
|
15 | *)
|
16 | echo "'ossutil' command is missing."
|
17 | exit -1
|
18 | ;;
|
19 | esac
|
20 | fi
|
21 |
|
22 | OSS_CFG_FILE=./.oss_cfg
|
23 | ENDPOINT=cn-hangzhou.oss.aliyun-inc.com
|
24 |
|
25 | echo "Try to load OSS config from $OSS_CFG_FILE"
|
26 | if [ -f $OSS_CFG_FILE ]; then
|
27 | source $OSS_CFG_FILE
|
28 | fi
|
29 |
|
30 | if [ -z ${OSS_ACCESS_KEY_ID+x} ]; then
|
31 | echo -n "OSS Access Key ID:"
|
32 | read OSS_ACCESS_KEY_ID
|
33 | fi
|
34 |
|
35 | if [ -z ${OSS_ACCESS_KEY_SECRET+x} ]; then
|
36 | echo -n "OSS Access Key SECRET:"
|
37 | read OSS_ACCESS_KEY_SECRET
|
38 | fi
|
39 |
|
40 | cat >$OSS_CFG_FILE <<EOL
|
41 | OSS_ACCESS_KEY_ID=$OSS_ACCESS_KEY_ID
|
42 | OSS_ACCESS_KEY_SECRET=$OSS_ACCESS_KEY_SECRET
|
43 | EOL
|
44 |
|
45 | VERSION=`node -p "require('./package').version"`
|
46 | CHECK_FILE=oss://oss-attachment/fun-install/fun-install-v${VERSION}-linux-x64.zip
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | cd output
|
54 |
|
55 | files=()
|
56 |
|
57 | for p in *.zip
|
58 | do
|
59 | echo $p
|
60 | ossutil cp $p oss://oss-attachment/fun-install/$p --endpoint $ENDPOINT --access-key-id $OSS_ACCESS_KEY_ID --access-key-secret $OSS_ACCESS_KEY_SECRET
|
61 | files+=($p)
|
62 | done
|
63 |
|
64 | echo ""
|
65 | echo "All uploaded success!"
|
66 | echo "====================================="
|
67 | for f in "${files[@]}"
|
68 | do
|
69 | echo "[$f](https://gosspublic.alicdn.com/fun-install/$f)"
|
70 | done
|