Skip to content

Commit e4b178c

Browse files
committed
build config and install script update for v0.13.0 release
1 parent bfe611c commit e4b178c

File tree

2 files changed

+65
-68
lines changed

2 files changed

+65
-68
lines changed

.travis.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ sudo: false
44

55
branches:
66
except:
7-
# skip master build, we are building edge and tag that is enough for
8-
# consistenty check and release.
9-
# Let's use Travis CI resources optimally for aah framework.
10-
- master
7+
# skip tags build, we are building branch and master that is enough for
8+
# consistenty check and release. Let's use Travis CI resources optimally
9+
# for aah framework.
10+
- /^v[0-9.]+$/
1111

1212
go:
1313
- 1.11.x
@@ -25,13 +25,6 @@ script:
2525
after_success:
2626
- bash <(curl -s https://codecov.io/bash)
2727

28-
deploy:
29-
provider: script
30-
skip_cleanup: true
31-
script: curl -s https://aahframework.org/publish-cli | bash
32-
on:
33-
tags: true
34-
3528
matrix:
3629
allow_failures:
3730
- go: tip

scripts/install-cli

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env bash
22

3-
# Purpose : Script installs aah CLI into 'GOPATH/bin' based OS and ARCH.
4-
# It should work on macOS, Linux, Unix systems and
5-
# on Windows with msys and mingw.
3+
# Purpose : Script installs aah CLI into 'GOPATH/bin'.
4+
# It should work on macOS, Linux BSD systems and Windows with Cygwin.
65
# Script License: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
76
# Creator : Jeevanandam M. (https://github.com/jeevatkm, [email protected])
8-
# Requires : bash, mkdir, cp, rm, curl/wget, sed/awk, tr, type, unzip, mktemp
7+
# Requires : bash, mkdir, rm, curl/wget, sed/awk, tr, type, mktemp
98
# Credits : This script inspired by Caddy server and Glide installer.
109
#
1110
# Version History
@@ -55,19 +54,44 @@ fetch() {
5554
eval "$1='$body'"
5655
}
5756

58-
download() {
59-
local url="$1"
60-
local filePath="$2"
61-
if [ "$download_cmd" = "curl" ]; then
62-
httpStatusCode=$(curl -s -w '%{http_code}' -L "$url" -o "$filePath")
63-
elif [ "$download_cmd" = "wget" ]; then
64-
body=$(wget --quiet --server-response --content-on-error -O "$filePath" "$url")
65-
httpStatusCode=$(cat $tmpFile | awk '/^ HTTP/{print $2}')
66-
fi
67-
echo "$httpStatusCode"
57+
quiet_git() {
58+
stdout=$(mktemp)
59+
stderr=$(mktemp)
60+
if ! git "$@" </dev/null >$stdout 2>$stderr; then
61+
cat $stderr >&2
62+
rm -f $stdout $stderr
63+
exit 1
64+
fi
65+
rm -f $stdout $stderr
6866
}
6967

70-
cli_version="$1"
68+
quiet_go() {
69+
stdout=$(mktemp)
70+
stderr=$(mktemp)
71+
if ! go "$@" </dev/null >$stdout 2>$stderr; then
72+
cat $stderr >&2
73+
rm -f $stdout $stderr
74+
exit 1
75+
fi
76+
rm -f $stdout $stderr
77+
}
78+
79+
# check prerequesties check
80+
if ! type -p git >/dev/null 2>&1; then
81+
quit "aah CLI Installation aborted, unable to find 'git'"
82+
fi
83+
if ! type -p go >/dev/null 2>&1; then
84+
quit "aah CLI Installation aborted, unable to find 'go'"
85+
fi
86+
87+
# Infer download command
88+
if type -p curl >/dev/null 2>&1; then
89+
download_cmd="curl"
90+
elif type -p wget >/dev/null 2>&1; then
91+
download_cmd="wget"
92+
else
93+
quit "Installation aborted, unable to find 'curl' or 'wget'"
94+
fi
7195

7296
# Infer target arch
7397
target_arch=$(uname -m)
@@ -86,12 +110,8 @@ case "$target_os" in
86110
esac
87111

88112
say "Starting aah CLI installer for $target_os/$target_arch"
113+
say "aah requires >= go.11"
89114

90-
# Verify Go installation and Check GOPATH environment variable is set
91-
go_cmd=$(which go)
92-
if [ "$?" = "1" ]; then
93-
quit "Go is not installed, aah CLI requires Go. Please install it"
94-
fi
95115
go_path=$GOPATH
96116
if [ -z "$go_path" ]; then
97117
go_path=$(go env GOPATH)
@@ -107,47 +127,31 @@ fi
107127
go_bin_dir="$go_path/bin"
108128
go_bin_dir="${go_bin_dir//\\//}"
109129

110-
# Infer download command
111-
if type -p curl >/dev/null 2>&1; then
112-
download_cmd="curl"
113-
elif type -p wget >/dev/null 2>&1; then
114-
download_cmd="wget"
115-
else
116-
quit "Installation aborted, unable to find 'curl' or 'wget'"
117-
fi
130+
export GO111MODULE=on
118131

119-
# Fetch latest version no and Download aah CLI binary
132+
cli_version="$1"
133+
# Fetch latest version no
120134
if [ -z "$cli_version" ]; then
121-
say "Fetch latest aah CLI version info from https://aahframework.org/version-cli"
135+
say "Fetch latest version info from https://aahframework.org/version-cli"
122136
fetch cli_version https://aahframework.org/version-cli
123-
fi
124-
say "Resolve aah CLI release artifact for $cli_version"
125-
cli_release=aah-$cli_version-$target_os-$target_arch
126-
cli_file_name="$cli_release.zip"
127-
cli_tmp_file="/tmp/$cli_file_name"
128-
cli_download_uri="https://github.com/go-aah/tools/releases/download/$cli_version/$cli_file_name"
129-
rm -rf $cli_tmp_file
130-
say "Downloading $cli_download_uri"
131-
status_code=$(download "$cli_download_uri" "$cli_tmp_file")
132-
if [ "$status_code" -ne 200 ]; then
133-
say "Unable to find aah CLI release $cli_version for your system $target_os/$target_arch"
134-
say "Note: aah CLI binary distribution available since CLI v0.13.0"
135-
quit "Please create an issue here https://aahframework.org/issues to add support"
137+
else
138+
say "Use given version info $cli_version"
136139
fi
137140

138-
# Install the aah CLI into GOPATH/bin
139-
cli_extract_tmp_dir="/tmp/$cli_release/"
140-
rm -rf $cli_extract_tmp_dir
141-
mkdir -p $cli_extract_tmp_dir
142-
if type unzip >/dev/null 2>&1; then
143-
unzip -q $cli_tmp_file -d $cli_extract_tmp_dir
144-
else
145-
quit "Installation aborted, unable to find 'unzip' program. Please install it"
141+
cli_import_path=aahframe.work/cli/aah
142+
cli_tmp_dir=$(mktemp -d)
143+
cli_tmp_dir="$cli_tmp_dir/aah-cli"
144+
145+
say "Getting git tag $cli_version"
146+
quiet_git clone -b $cli_version --single-branch --depth 1 https://github.com/go-aah/tools.git $cli_tmp_dir
147+
if [ ! -d "$cli_tmp_dir/aah" ]; then
148+
quit "It seems there was issue with fetching source code from github for tag $cli_version"
146149
fi
147-
say "Installing aah CLI into $go_bin_dir/"
148-
rm -rf "$go_bin_dir/aah"
149-
cp "$cli_extract_tmp_dir/aah" $go_bin_dir/
150-
rm -rf $cli_tmp_file $cli_extract_tmp_dir
150+
cd $cli_tmp_dir/aah
151+
cli_git_commit_sha=$(git rev-parse HEAD)
152+
just_cli_version=${cli_version#"v"}
153+
154+
say "Build & Install aah CLI into $go_bin_dir/"
155+
quiet_go install -ldflags="-s -w -X main.Version=$just_cli_version -X main.CliCommitID=$cli_git_commit_sha -X main.CliPackaged=true -X main.CliOS=$target_os -X main.CliArch=$target_arch" $cli_import_path
156+
rm -rf $cli_tmp_dir
151157
say "Congrats, aah CLI installed successfully"
152-
say "Running aah --version"
153-
aah --version

0 commit comments

Comments
 (0)