forked from norman-abramovitz/cf-targets-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-all.sh
executable file
·59 lines (48 loc) · 1.65 KB
/
build-all.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
#!/bin/sh
if [[ "$1" = "release" ]] ; then
TAG="$2"
: ${TAG:?"Usage: build_all.sh [release] [TAG]"}
git tag | grep $TAG > /dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "$TAG exists, remove it or increment"
exit 1
else
MAJOR=`echo $TAG | sed 's/^v//' | awk 'BEGIN {FS = "." } ; { printf $1;}'`
MINOR=`echo $TAG | sed 's/^v//' | awk 'BEGIN {FS = "." } ; { printf $2;}'`
BUILD=`echo $TAG | sed 's/^v//' | awk 'BEGIN {FS = "." } ; { printf $3;}'`
`sed -i .bak -e "s/Major:.*/Major: $MAJOR,/" \
-e "s/Minor:.*/Minor: $MINOR,/" \
-e "s/Build:.*/Build: $BUILD,/" cf_targets.go`
fi
fi
GOOS=linux GOARCH=amd64 go build
LINUX64_SHA1=`cat cf-targets-plugin | openssl sha1`
mkdir -p bin/linux64
mv cf-targets-plugin bin/linux64
GOOS=darwin GOARCH=amd64 go build
OSX_AMD64_SHA1=`cat cf-targets-plugin | openssl sha1`
mkdir -p bin/osx-amd64
mv cf-targets-plugin bin/osx-amd64
GOOS=darwin GOARCH=arm64 go build
OSX_ARM64_SHA1=`cat cf-targets-plugin | openssl sha1`
mkdir -p bin/osx-arm64
mv cf-targets-plugin bin/osx-arm64/cf-targets-plugin
GOOS=windows GOARCH=amd64 go build
WIN64_SHA1=`cat cf-targets-plugin.exe | openssl sha1`
mkdir -p bin/win64
mv cf-targets-plugin.exe bin/win64
cat repo-index.yml |
sed "s/osx-amd64-sha1/$OSX_AMD64_SHA1/" |
sed "s/osx-arm64-sha1/$OSX_ARM64_SHA1/" |
# sed "s/win64-sha1/$WIN64_SHA1/" |
sed "s/linux64-sha1/$LINUX64_SHA1/" |
sed "s/_TAG_/$TAG/" |
cat
#Final build gives developer a plugin to install
go build
if [[ "$1" = "release" ]] ; then
git commit -am "Build version $TAG"
git tag $TAG
echo "Tagged release, 'git push --tags' to move it to github, and copy the output above"
echo "to the cli repo you plan to deploy in"
fi