UNPKG

1.76 kBapplication/x-shView Raw
1#!/bin/bash
2set -e
3
4if ! [ -x "$(command -v ossutil)" ]; then
5
6 case "$OSTYPE" in
7 darwin*)
8 # install home brew if missing
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
20fi
21
22OSS_CFG_FILE=./.oss_cfg
23ENDPOINT=cn-hangzhou.oss.aliyun-inc.com
24
25echo "Try to load OSS config from $OSS_CFG_FILE"
26if [ -f $OSS_CFG_FILE ]; then
27 source $OSS_CFG_FILE
28fi
29
30if [ -z ${OSS_ACCESS_KEY_ID+x} ]; then
31 echo -n "OSS Access Key ID:"
32 read OSS_ACCESS_KEY_ID
33fi
34
35if [ -z ${OSS_ACCESS_KEY_SECRET+x} ]; then
36 echo -n "OSS Access Key SECRET:"
37 read OSS_ACCESS_KEY_SECRET
38fi
39
40cat >$OSS_CFG_FILE <<EOL
41OSS_ACCESS_KEY_ID=$OSS_ACCESS_KEY_ID
42OSS_ACCESS_KEY_SECRET=$OSS_ACCESS_KEY_SECRET
43EOL
44
45VERSION=`node -p "require('./package').version"`
46CHECK_FILE=oss://oss-attachment/fun-install/fun-install-v${VERSION}-linux-x64.zip
47
48# if ossutil ls $CHECK_FILE --endpoint $ENDPOINT --access-key-id $OSS_ACCESS_KEY_ID --access-key-secret $OSS_ACCESS_KEY_SECRET | grep "Object Number is: 1" > /dev/null ; then
49# echo "Version $VERSION is already uploaded!"
50# exit -1
51# fi
52
53cd output
54
55files=()
56
57for p in *.zip
58do
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)
62done
63
64echo ""
65echo "All uploaded success!"
66echo "====================================="
67for f in "${files[@]}"
68do
69 echo "[$f](https://gosspublic.alicdn.com/fun-install/$f)"
70done