-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci-deploy.sh
executable file
·105 lines (88 loc) · 2.67 KB
/
ci-deploy.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
GITHUB_USER=ids
GITHUB_REPO=clairctl
RELEASE_DESC="A CLI based utility for interacting with the Clair API"
RELEASE_TITLE=" - stable release"
mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
cd $GOPATH/src/$REPO_NAME
curl https://glide.sh/get | sh
glide install -v
go get -u github.com/jteeuwen/go-bindata/...
go generate ./clair
go get github.com/mitchellh/gox
gox -os="linux" -os="darwin" -arch="amd64" -output="client-bins/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags "-X github.com/ids/clairctl/cmd.version=$(cat VERSION)"
go get github.com/aktau/github-release
cd $CI_PROJECT_DIR
git config --global user.email $GITHUB_EMAIL
git config --global user.name $GITHUB_USERNAME
echo "configured remotes:"
git remote -v
git remote remove github
git remote add github "https://$GITHUB_USERNAME:[email protected]/ids/clairctl"
echo "re-configured remote w/ token:"
git remote -v
export VERSION=develop
export PRE_FLAG=
echo "CI_COMMIT_REF_NAME: ${CI_COMMIT_REF_NAME}"
if [ "${CI_COMMIT_REF_NAME}" == "develop" ]; then
PRE_FLAG=--pre-release
RELEASE_TITLE=" - unstable"
else
# it's master, update the version
VERSION=`cat VERSION`
VERSION=`echo $VERSION | ./version-inc.sh`
fi
THEME=$(git log -1 --pretty=%B)
echo "THEME: ${THEME}"
echo "VERSION: ${VERSION}"
echo "creating tag ${VERSION}"
git tag -a $VERSION -m "${VERSION}" -f
git push --force github refs/tags/${VERSION}:refs/tags/${VERSION}
github-release release \
--user $GITHUB_USER \
--repo $GITHUB_REPO \
--tag $VERSION \
--name "${VERSION} ${RELEASE_TITLE}" \
--description "${RELEASE_DESC}" \
$PRE_FLAG
if [ $? -ne 0 ]; then
github-release delete \
--user $GITHUB_USER \
--repo $GITHUB_REPO \
--tag $VERSION \
github-release release \
--user $GITHUB_USER \
--repo $GITHUB_REPO \
--tag $VERSION \
--name "${VERSION} ${RELEASE_TITLE}" \
--description "${RELEASE_DESC}" \
$PRE_FLAG
fi
github-release upload \
--user $GITHUB_USER \
--repo $GITHUB_REPO \
--tag $VERSION \
--replace \
--name "clairctl-darwin-amd64" \
--file $CI_PROJECT_DIR/client-bins/clairctl-darwin-amd64
github-release upload \
--user $GITHUB_USER \
--repo $GITHUB_REPO \
--tag $VERSION \
--replace \
--name "clairctl-linux-amd64" \
--file $CI_PROJECT_DIR/client-bins/clairctl-linux-amd64
if [ "$CI_COMMIT_REF_NAME" == "master" ]; then
rm -rf client-bins
git status
git checkout master
git pull github master
git status
git branch
echo $VERSION > VERSION
git add VERSION
git commit -a -m "automated update to version: ${VERSION}"
git push github master
fi
echo "Release binairies have been deployed and updated"