-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathbuildAndUpload.sh
executable file
·72 lines (61 loc) · 2.26 KB
/
buildAndUpload.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -eu
#function build(pkg, goos, goarch, exeName)
build () {
pkg="$1"
export GOOS="$2"
export GOARCH="$3"
exeName="$4"
echo "Building $exeName for $GOOS-$GOARCH ..."
CGO_ENABLED=0 jf go build -o "$exeName" -ldflags '-w -extldflags "-static" -X github.com/jfrog/frogbot/v2/utils.FrogbotVersion='"$version"
chmod +x "$exeName"
# Run verification after building plugin for the correct platform of this image.
if [[ "$pkg" = "frogbot-linux-386" ]]; then
verifyVersionMatching
fi
}
#function buildAndUpload(pkg, goos, goarch, fileExtension)
buildAndUpload () {
pkg="$1"
goos="$2"
goarch="$3"
fileExtension="$4"
exeName="frogbot$fileExtension"
build "$pkg" "$goos" "$goarch" "$exeName"
destPath="$pkgPath/$version/$pkg/$exeName"
echo "Uploading $exeName to $destPath ..."
jf rt u "./$exeName" "$destPath"
}
# Verify version provided in pipelines UI matches version in frogbot source code.
verifyVersionMatching () {
echo "Verifying provided version matches built version..."
res=$(eval "./frogbot -v")
exitCode=$?
if [[ $exitCode -ne 0 ]]; then
echo "Error: Failed verifying version matches"
exit $exitCode
fi
# Get the version which is after the last space. (expected output to -v for example: "Frogbot version version v2.0.0")
echo "Output: $res"
builtVersion="${res##* }"
# Compare versions
if [[ "$builtVersion" != "$version" ]]; then
echo "Versions dont match. Provided: $version, Actual: $builtVersion"
exit 1
fi
echo "Versions match."
}
version="$1"
pkgPath="ecosys-frogbot/v2"
# Build and upload for every architecture.
# Keep 'linux-386' first to prevent unnecessary uploads in case the built version doesn't match the provided one.
buildAndUpload 'frogbot-linux-386' 'linux' '386' ''
buildAndUpload 'frogbot-linux-amd64' 'linux' 'amd64' ''
buildAndUpload 'frogbot-linux-s390x' 'linux' 's390x' ''
buildAndUpload 'frogbot-linux-arm64' 'linux' 'arm64' ''
buildAndUpload 'frogbot-linux-arm' 'linux' 'arm' ''
buildAndUpload 'frogbot-linux-ppc64' 'linux' 'ppc64' ''
buildAndUpload 'frogbot-linux-ppc64le' 'linux' 'ppc64le' ''
buildAndUpload 'frogbot-mac-386' 'darwin' 'amd64' ''
buildAndUpload 'frogbot-windows-amd64' 'windows' 'amd64' '.exe'
jf rt u "./buildscripts/getFrogbot.sh" "$pkgPath/$version/" --flat