Skip to content

Commit 64a08ff

Browse files
feiren.kuangraullenchai
feiren.kuang
authored andcommitted
github release,travis windows,bookkeeper tools (iotexproject#1087)
1 parent ecade7e commit 64a08ff

File tree

4 files changed

+256
-10
lines changed

4 files changed

+256
-10
lines changed

.circleci/circleci_github_release.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
USER="iotexproject"
4+
PROJECT="iotex-core"
5+
BRANCH="master"
6+
VERSION="0"
7+
CIRCLE_TOKEN="<YOUR_ACCESS_TOKEN>"
8+
while getopts v:b: option
9+
do
10+
case "${option}"
11+
in
12+
v) VERSION="$OPTARG";;
13+
b) BRANCH="$OPTARG";;
14+
esac
15+
done
16+
if [ "$VERSION" = "0" ]; then
17+
echo "Usage: $0 -v <version> [-b <branch>]"
18+
exit 1
19+
fi
20+
21+
CIRCLEJOBS="nightly_bin_build_docker nightly_bin_build_darwin"
22+
23+
24+
for CIRCLE_JOB in ${CIRCLEJOBS} ; do
25+
curl -d "build_parameters[CIRCLE_JOB]=${CIRCLE_JOB}" -d "build_parameters[VERSION]=$VERSION" "https://circleci.com/api/v1.1/project/github/${USER}/${PROJECT}/tree/${BRANCH}?circle-token=${CIRCLE_TOKEN}"
26+
done

.circleci/config.yml

+35-10
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,23 @@ jobs:
9494
steps:
9595
- checkout
9696
- run: cd cli/ioctl/ && ./buildcli.sh
97-
- run: sudo apt-get install python python-pip
98-
- run: sudo pip install awscli
99-
- run: aws s3 sync cli/ioctl/release/ ${S3_BUCKET_DIR}
10097
- run: cd tools/actioninjector.v2/ && ./build_injector.sh
101-
- run: aws s3 sync tools/actioninjector.v2/release/ ${S3_BUCKET_DIR}
98+
- run:
99+
name: build bin put s3 (unstable) or github (release)
100+
command: |
101+
if [ "${VERSION}" ]; then
102+
echo "Put bin to github release ${VERSION}"
103+
go get -u github.com/tcnksm/ghr
104+
arg="-t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${VERSION}"
105+
echo $arg
106+
ghr $arg cli/ioctl/release/
107+
ghr $arg tools/actioninjector.v2/release/
108+
else
109+
sudo apt-get install python python-pip
110+
sudo pip install awscli
111+
aws s3 sync cli/ioctl/release/ ${S3_BUCKET_DIR}
112+
aws s3 sync tools/actioninjector.v2/release/ ${S3_BUCKET_DIR}
113+
fi
102114
103115
nightly_bin_build_darwin:
104116
macos:
@@ -115,22 +127,35 @@ jobs:
115127
sudo tar -C /usr/local -xzf go1.11.6.darwin-amd64.tar.gz
116128
rm go1.11.6.darwin-amd64.tar.gz
117129
- run:
118-
name: SET GO ENV AND buildcli.sh
130+
name: SET go env and buildcli.sh,build_injector.sh
119131
command: |
120132
export GOPATH=~/go
121133
export GOROOT="/usr/local/go"
122134
export PATH=$PATH:$GOPATH/bin:$PATH:$GOROOT/bin
123135
cd cli/ioctl/ && ./buildcli.sh
124-
sudo pip install awscli
125-
aws s3 sync release/ ${S3_BUCKET_DIR}
126136
cd tools/actioninjector.v2/ && ./build_injector.sh
127-
aws s3 sync tools/actioninjector.v2/release/ ${S3_BUCKET_DIR}
137+
- run:
138+
name: build bin put s3 (unstable) or github (release)
139+
commnad: |
140+
if [ "${VERSION}" ]; then
141+
echo "Put bin to github release ${VERSION}"
142+
go get -u github.com/tcnksm/ghr
143+
arg="-t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${VERSION}"
144+
echo $arg
145+
ghr $arg cli/ioctl/release/
146+
ghr $arg tools/actioninjector.v2/release/
147+
else
148+
sudo pip install awscli
149+
aws s3 sync cli/ioctl/release/ ${S3_BUCKET_DIR}
150+
aws s3 sync tools/actioninjector.v2/release/ ${S3_BUCKET_DIR}
151+
fi
152+
128153
workflows:
129154
version: 2
130155
commit:
131156
jobs:
132157
#- build_test_ubuntu
133-
- build_test_darwin
158+
# - build_test_darwin
134159
- build_test_docker
135160

136161
scheduled-workflow:
@@ -144,4 +169,4 @@ workflows:
144169
jobs:
145170
- nightly_build_docker
146171
- nightly_bin_build_docker
147-
- nightly_bin_build_darwin
172+
# - nightly_bin_build_darwin

.travis.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
os:
2+
- windows
3+
- osx
4+
- linux
5+
language: go
6+
env:
7+
global:
8+
- USER="iotexproject"
9+
- REPO="iotex-core"
10+
- LD_LIBRARY_PATH=:${TRAVIS_HOME}/gopath/src/github.com/iotexproject/iotex-core/crypto/lib
11+
git:
12+
depth: 3
13+
quiet: true
14+
go:
15+
# - 1.10.x
16+
- "1.11.5"
17+
# - "1.11.6"
18+
# - 1.12.x
19+
20+
# services:
21+
# - rabbitmq
22+
23+
# env:
24+
# - GO111MODULE=on AMQP_URL=amqp://guest:[email protected]:5672/
25+
26+
# before_install:
27+
# - go get -v golang.org/x/lint/golint
28+
before_script:
29+
- if [[ $TRAVIS_OS_NAME == windows ]]; then
30+
mkdir -p ${TRAVIS_HOME}/gopath/src/github.com/$USER/$REPO;
31+
tar -Pczf ${TRAVIS_TMPDIR}/src_archive.tar.gz -C ${TRAVIS_BUILD_DIR} . ;
32+
tar -Pxzf ${TRAVIS_TMPDIR}/src_archive.tar.gz -C ${TRAVIS_HOME}/gopath/src/github.com/$USER/$REPO;
33+
cd ${TRAVIS_HOME}/gopath/src/github.com/$USER/$REPO;
34+
fi
35+
script:
36+
- pwd
37+
- ./go.test.sh
38+
after_success:
39+
- bash <(curl -s https://codecov.io/bash)
40+
# - go test -cpu=1,2 -v -tags integration ./...
41+
- go test -run=XXX -bench=. $(go list ./crypto)
42+
- make minicluster

install-bookkeeper.sh

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#!/bin/sh
2+
3+
# This install script is intended to download and install the latest available
4+
# release of the ioctl dependency manager for Golang.
5+
#
6+
# It attempts to identify the current platform and an error will be thrown if
7+
# the platform is not supported.
8+
#
9+
# Environment variables:
10+
# - INSTALL_DIRECTORY (optional): defaults to $GOPATH/bin (if $GOPATH exists)
11+
# or /usr/local/bin (else)
12+
# - CLI_RELEASE_TAG (optional): defaults to fetching the latest release
13+
#
14+
# You can install using this script:
15+
# $ curl https://raw.githubusercontent.com/iotexproject/iotex-core/master/install-cli.sh | sh
16+
17+
set -e
18+
19+
#RELEASES_URL="https://github.com/iotexproject/iotex-core/releases"
20+
S3URL="https://s3-ap-southeast-1.amazonaws.com/ioctl"
21+
RELEASES_URL=$S3URL
22+
INSTALL_DIRECTORY='/usr/local/bin'
23+
24+
downloadJSON() {
25+
url="$2"
26+
27+
echo "Fetching $url.."
28+
if test -x "$(command -v curl)"; then
29+
response=$(curl -s -L -w 'HTTPSTATUS:%{http_code}' -H 'Accept: application/json' "$url")
30+
body=$(echo "$response" | sed -e 's/HTTPSTATUS\:.*//g')
31+
code=$(echo "$response" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
32+
elif test -x "$(command -v wget)"; then
33+
temp=$(mktemp)
34+
body=$(wget -q --header='Accept: application/json' -O - --server-response "$url" 2> "$temp")
35+
code=$(awk '/^ HTTP/{print $2}' < "$temp" | tail -1)
36+
rm "$temp"
37+
else
38+
echo "Neither curl nor wget was available to perform http requests."
39+
exit 1
40+
fi
41+
if [ "$code" != 200 ]; then
42+
echo "Request failed with code $code"
43+
exit 1
44+
fi
45+
46+
eval "$1='$body'"
47+
}
48+
49+
downloadFile() {
50+
url="$1"
51+
destination="$2"
52+
53+
echo "Fetching $url.."
54+
if test -x "$(command -v curl)"; then
55+
code=$(curl -s -w '%{http_code}' -L "$url" -o "$destination")
56+
elif test -x "$(command -v wget)"; then
57+
code=$(wget -q -O "$destination" --server-response "$url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1)
58+
else
59+
echo "Neither curl nor wget was available to perform http requests."
60+
exit 1
61+
fi
62+
63+
if [ "$code" != 200 ]; then
64+
echo "Request failed with code $code"
65+
exit 1
66+
fi
67+
}
68+
69+
initArch() {
70+
ARCH=$(uname -m)
71+
case $ARCH in
72+
amd64) ARCH="amd64";;
73+
x86_64) ARCH="amd64";;
74+
i386) ARCH="386";;
75+
ppc64) ARCH="ppc64";;
76+
ppc64le) ARCH="ppc64le";;
77+
s390x) ARCH="s390x";;
78+
armv6*) ARCH="arm";;
79+
armv7*) ARCH="arm";;
80+
aarch64) ARCH="arm64";;
81+
*) echo "Architecture ${ARCH} is not supported by this installation script"; exit 1;;
82+
esac
83+
echo "ARCH = $ARCH"
84+
}
85+
86+
initOS() {
87+
OS=$(uname | tr '[:upper:]' '[:lower:]')
88+
OS_CYGWIN=0
89+
case "$OS" in
90+
darwin) OS='darwin';;
91+
linux) OS='linux';;
92+
freebsd) OS='freebsd';;
93+
mingw*) OS='windows';;
94+
msys*) OS='windows';;
95+
cygwin*)
96+
OS='windows'
97+
OS_CYGWIN=1
98+
;;
99+
*) echo "OS ${OS} is not supported by this installation script"; exit 1;;
100+
esac
101+
echo "OS = $OS"
102+
}
103+
104+
# identify platform based on uname output
105+
initArch
106+
initOS
107+
INSTALL_NAME="bookkeeper"
108+
109+
# assemble expected release artifact name
110+
if [ "${OS}" != "linux" ] && { [ "${ARCH}" = "ppc64" ] || [ "${ARCH}" = "ppc64le" ];}; then
111+
# ppc64 and ppc64le are only supported on Linux.
112+
echo "${OS}-${ARCH} is not supported by this instalation script"
113+
else
114+
BINARY="${INSTALL_NAME}-${OS}-${ARCH}"
115+
fi
116+
117+
# add .exe if on windows
118+
if [ "$OS" = "windows" ]; then
119+
BINARY="$BINARY.exe"
120+
fi
121+
122+
#if [ -z "$CLI_RELEASE_TAG" ]; then
123+
# downloadJSON LATEST_RELEASE "$RELEASES_URL/latest"
124+
# CLI_RELEASE_TAG=$(echo "${LATEST_RELEASE}" | tr -s '\n' ' ' | sed 's/.*"tag_name":"//' | sed 's/".*//' )
125+
#fi
126+
127+
if [ "$1" = "unstable" ]; then
128+
BINARY_URL="$S3URL/$BINARY"
129+
130+
else
131+
# fetch the real release data to make sure it exists before we attempt a download
132+
# downloadJSON RELEASE_DATA "$RELEASES_URL/tag/$CLI_RELEASE_TAG"
133+
BINARY_URL="$RELEASES_URL/$BINARY"
134+
fi
135+
136+
DOWNLOAD_FILE=$(mktemp)
137+
138+
downloadFile "$BINARY_URL" "$DOWNLOAD_FILE"
139+
downloadFile "$RELEASES_URL/committee.yaml" "committee.yaml"
140+
141+
echo "Setting executable permissions."
142+
chmod +x "$DOWNLOAD_FILE"
143+
144+
if [ "$OS" = "windows" ]; then
145+
INSTALL_NAME="$INSTALL_NAME.exe"
146+
echo "Moving executable to $HOME/$INSTALL_NAME"
147+
mv "$DOWNLOAD_FILE" "$HOME/$INSTALL_NAME"
148+
else
149+
echo "Moving executable to $INSTALL_DIRECTORY/$INSTALL_NAME"
150+
sudo mv "$DOWNLOAD_FILE" "$INSTALL_DIRECTORY/$INSTALL_NAME"
151+
fi
152+
sudo cp committee.yaml $INSTALL_DIRECTORY/
153+

0 commit comments

Comments
 (0)