Skip to content

Commit c8b73d9

Browse files
committed
Updated goreleaser config to avoid including version into archive name.
1 parent 7196499 commit c8b73d9

File tree

3 files changed

+34
-171
lines changed

3 files changed

+34
-171
lines changed

.goreleaser renamed to .goreleaser.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ builds:
1111
flags:
1212
- -mod=vendor
1313

14+
archives:
15+
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
16+
1417
release:
1518
prerelease: auto
1619

cmd/root.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ var gitCommit string
4141
var localFilename string
4242
var codeperfUrl string
4343
var codeperfApiUrl string
44+
var benchTime string
4445
var local bool
4546
var longDescription = ` __ ____ _
4647
_________ ____/ /__ ____ ___ _____/ __/ (_)___
@@ -71,7 +72,6 @@ func testLogic(cmd *cobra.Command, args []string) {
7172
// TODO: Check pprof is available on path
7273
const shell = "/bin/bash"
7374
benchmarks, _ := GetBenchmarks(".")
74-
benchtime := "1s"
7575
var err error = nil
7676

7777
goPath, err := exec.LookPath("go")
@@ -184,6 +184,7 @@ func init() {
184184
rootCmd.PersistentFlags().StringVar(&localFilename, "local-filename", "profile.json", "Local file to export the json to. Only used when the --local flag is set")
185185
rootCmd.PersistentFlags().StringVar(&codeperfUrl, "codeperf-url", "https://codeperf.io", "codeperf URL")
186186
rootCmd.PersistentFlags().StringVar(&codeperfApiUrl, "codeperf-api-url", "https://api.codeperf.io", "codeperf API URL")
187+
rootCmd.PersistentFlags().StringVar(&benchTime, "benchtime", "10s", "benchmark time")
187188
rootCmd.PersistentFlags().StringVar(&bench, "bench", "", "Benchmark name")
188189
//rootCmd.MarkPersistentFlagRequired("bench")
189190
}

get.sh

+29-170
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
11
#!/bin/bash
22

3-
# Copyright OpenFaaS Author(s) 2019
4-
#########################
5-
# Repo specific content #
6-
#########################
3+
set -e
74

8-
export VERIFY_CHECKSUM=0
9-
export ALIAS=""
105
export OWNER=codeperfio
116
export REPO=codeperf
12-
export SUCCESS_CMD="$REPO version"
13-
export BINLOCATION="/usr/local/bin"
147

15-
###############################
16-
# Content common across repos #
17-
###############################
18-
19-
version=$(curl -sI https://github.com/$OWNER/$REPO/releases/latest | grep -i "location:" | awk -F"/" '{ printf "%s", $NF }' | tr -d '\r')
20-
if [ ! $version ]; then
21-
echo "Failed while attempting to install $REPO. Please manually install:"
22-
echo ""
23-
echo "1. Open your web browser and go to https://github.com/$OWNER/$REPO/releases"
24-
echo "2. Download the latest release for your platform. Call it '$REPO'."
25-
echo "3. chmod +x ./$REPO"
26-
echo "4. mv ./$REPO $BINLOCATION"
27-
if [ -n "$ALIAS_NAME" ]; then
28-
echo "5. ln -sf $BINLOCATION/$REPO /usr/local/bin/$ALIAS_NAME"
29-
fi
30-
exit 1
31-
fi
8+
TAR_FILE="/tmp/$REPO.tar.gz"
9+
RELEASES_URL="https://github.com/$OWNER/$REPO/releases"
10+
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
3211

3312
hasCli() {
3413

@@ -39,153 +18,33 @@ hasCli() {
3918
fi
4019
}
4120

42-
checkHash(){
43-
44-
sha_cmd="sha256sum"
45-
46-
if [ ! -x "$(command -v $sha_cmd)" ]; then
47-
sha_cmd="shasum -a 256"
48-
fi
49-
50-
if [ -x "$(command -v $sha_cmd)" ]; then
51-
52-
targetFileDir=${targetFile%/*}
53-
54-
(cd $targetFileDir && curl -sSL $url.sha256|$sha_cmd -c >/dev/null)
55-
56-
if [ "$?" != "0" ]; then
57-
rm $targetFile
58-
echo "Binary checksum didn't match. Exiting"
59-
exit 1
60-
fi
61-
fi
62-
}
63-
64-
getPackage() {
65-
uname=$(uname)
66-
userid=$(id -u)
67-
68-
suffix=""
69-
case $uname in
70-
"Darwin")
71-
suffix="-darwin"
72-
;;
73-
"MINGW"*)
74-
suffix=".exe"
75-
BINLOCATION="$HOME/bin"
76-
mkdir -p $BINLOCATION
77-
78-
;;
79-
"Linux")
80-
arch=$(uname -m)
81-
echo $arch
82-
case $arch in
83-
"aarch64")
84-
suffix="-arm64"
85-
;;
86-
esac
87-
case $arch in
88-
"armv6l" | "armv7l")
89-
suffix="-armhf"
90-
;;
91-
esac
92-
;;
93-
esac
94-
95-
targetFile="/tmp/$REPO"
96-
97-
if [ "$userid" != "0" ]; then
98-
targetFile="$(pwd)/$REPO"
99-
fi
100-
101-
if [ -e "$targetFile" ]; then
102-
rm "$targetFile"
103-
fi
104-
105-
url=https://github.com/$OWNER/$REPO/releases/download/$version/$REPO$suffix
106-
echo "Downloading package $url as $targetFile"
107-
108-
curl -sSL $url --output "$targetFile"
109-
110-
if [ "$?" = "0" ]; then
111-
112-
if [ "$VERIFY_CHECKSUM" = "1" ]; then
113-
checkHash
114-
fi
115-
116-
chmod +x "$targetFile"
117-
118-
echo "Download complete."
119-
120-
if [ ! -w "$BINLOCATION" ]; then
121-
122-
echo
123-
echo "============================================================"
124-
echo " The script was run as a user who is unable to write"
125-
echo " to $BINLOCATION. To complete the installation the"
126-
echo " following commands may need to be run manually."
127-
echo "============================================================"
128-
echo
129-
echo " sudo cp $REPO $BINLOCATION/$REPO"
130-
131-
if [ -n "$ALIAS_NAME" ]; then
132-
echo " sudo ln -sf $BINLOCATION/$REPO $BINLOCATION/$ALIAS_NAME"
133-
fi
134-
135-
echo
136-
137-
else
138-
139-
echo
140-
echo "Running with sufficient permissions to attempt to move $REPO to $BINLOCATION"
141-
142-
if [ ! -w "$BINLOCATION/$REPO" ] && [ -f "$BINLOCATION/$REPO" ]; then
143-
144-
echo
145-
echo "================================================================"
146-
echo " $BINLOCATION/$REPO already exists and is not writeable"
147-
echo " by the current user. Please adjust the binary ownership"
148-
echo " or run sh/bash with sudo."
149-
echo "================================================================"
150-
echo
151-
exit 1
152-
153-
fi
154-
155-
mv $targetFile $BINLOCATION/$REPO
156-
157-
if [ "$?" = "0" ]; then
158-
echo "New version of $REPO installed to $BINLOCATION"
159-
fi
160-
161-
if [ -e "$targetFile" ]; then
162-
rm "$targetFile"
163-
fi
164-
165-
if [ -n "$ALIAS_NAME" ]; then
166-
if [ ! -L $BINLOCATION/$ALIAS_NAME ]; then
167-
ln -s $BINLOCATION/$REPO $BINLOCATION/$ALIAS_NAME
168-
echo "Creating alias '$ALIAS_NAME' for '$REPO'."
169-
fi
170-
fi
171-
172-
${SUCCESS_CMD}
173-
fi
174-
fi
21+
last_version() {
22+
curl -sL -o /dev/null -w %{url_effective} "$RELEASES_URL/latest" |
23+
rev |
24+
cut -f1 -d'/'|
25+
rev
17526
}
17627

177-
thanks() {
178-
echo " __ ____ _ "
179-
echo " _________ ____/ /__ ____ ___ _____/ __/ (_)___ "
180-
echo " / ___/ __ \/ __ / _ \/ __ \/ _ \/ ___/ /_ / / __ \ "
181-
echo "/ /__/ /_/ / /_/ / __/ /_/ / __/ / / __/ _ / / /_/ / "
182-
echo "\___/\____/\__,_/\___/ .___/\___/_/ /_/ (_) /_/\____/"
183-
echo " /_/"
184-
echo
185-
echo "Export and persist Go profiling data locally, or into https://codeperf.io for FREE"
186-
echo
28+
download() {
29+
echo "getting latest release from $RELEASES_URL/latest..."
30+
echo "detected latest version=$(last_version)"
31+
test -z "$VERSION" && VERSION="$(last_version)"
32+
test -z "$VERSION" && {
33+
echo "Unable to get codeperf version." >&2
34+
exit 1
35+
}
36+
rm -f "$TAR_FILE"
37+
RELEASE_ARTIFACT="$RELEASES_URL/download/$VERSION/${REPO}_$(uname -s)_$(uname -m).tar.gz"
38+
echo "getting $RELEASE_ARTIFACT into $TAR_FILE"
39+
curl -s -L -o "$TAR_FILE" \
40+
$RELEASE_ARTIFACT
41+
18742
}
18843

18944
hasCli
190-
getPackage
191-
thanks
45+
download
46+
tar -xf "$TAR_FILE" -C "$TMPDIR"
47+
rm $TAR_FILE
48+
mv $TMPDIR/$REPO .
49+
echo "Checking we can call the codeperf tool"
50+
./codeperf --help

0 commit comments

Comments
 (0)