-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcircle.yml
85 lines (85 loc) · 3.89 KB
/
circle.yml
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
machine:
environment:
PACKAGE_PATH: "github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME"
GOPATH: "$HOME/.go_workspace"
PROJECT_DIR: "$GOPATH/src/$PACKAGE_PATH"
GODIST: "go1.8.1.linux-amd64.tar.gz"
DEBIAN_PACKAGE_NAME: "${CIRCLE_PROJECT_REPONAME}-1.0.${CIRCLE_BUILD_NUM}_armhf"
node:
version: 6
post:
# Install the specified version of Go
- mkdir -p download
- test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST
- sudo rm -rf /usr/local/go
- sudo tar -C /usr/local -xzf download/$GODIST
# Install the latest version of Yarn package manager:
- curl -o- -L https://yarnpkg.com/install.sh | bash
checkout:
post:
# Get our UI source
- cd /tmp; git clone https://github.com/$CIRCLE_PROJECT_USERNAME/appliance-monitor-ui.git
dependencies:
pre:
# Sanity check that our go version is installed
- go version
# Compiler and release tools
- go get github.com/mitchellh/gox
- go get github.com/tcnksm/ghr
# Static assets compilers
- go get github.com/jteeuwen/go-bindata/...
- go get github.com/elazarl/go-bindata-assetfs/...
# Utilities
- go get github.com/danesparza/tokenreplace
# Unit test reports
- go get -u github.com/jstemmer/go-junit-report
# Sanity check the yarn version:
- yarn --version
# Reset UI config
- rm /tmp/appliance-monitor-ui/src/config.js
- cp /tmp/appliance-monitor-ui/src/config.reset.js /tmp/appliance-monitor-ui/src/config.js
override:
# Create our project workspace
- mkdir -p "$PROJECT_DIR"
# Go configuration on CircleCI is wonky. Make sure our code
# is in the correct Go workspace structure
- rsync -azC --delete ./ --include=".git" "$PROJECT_DIR"
- env GOARCH=arm go get -d -v $PACKAGE_PATH/...
- go get -t -d -v $PACKAGE_PATH/...
post:
# Setup our UI
- mkdir -p /tmp/ui
- cd /tmp/appliance-monitor-ui; git describe --tags; yarn; yarn build; go-bindata-assetfs -pkg cmd build/...; mv -f bindata_assetfs.go "$PROJECT_DIR/cmd";
- ls -lR $PROJECT_DIR
# Compile the UI static assets into a Go sourcefile (to be compiled)
# - cd $PROJECT_DIR; go-bindata-assetfs -pkg cmd ./ui/...;rm cmd/bindata_assetfs.go; ls -l cmd; mv bindata_assetfs.go cmd; ls -l cmd; cat cmd/bindata_assetfs.go
cache_directories:
- ~/download
test:
pre:
- go vet -x $PACKAGE_PATH/...
override:
- go test -v -race $PACKAGE_PATH/...
post:
# Publish test results in jUnit format (so CircleCI can report on tests better)
- mkdir $CIRCLE_TEST_REPORTS/junit
- go test -v -race $PACKAGE_PATH/... | go-junit-report > $CIRCLE_TEST_REPORTS/junit/junit.xml
# Multi-platform compile with version information
- cd $PROJECT_DIR
- gox -os="linux" -arch="arm" -ldflags "-X $PACKAGE_PATH/cmd.BuildVersion=1.0.$CIRCLE_BUILD_NUM -X $PACKAGE_PATH/cmd.CommitID=$CIRCLE_SHA1" -output "${CIRCLE_ARTIFACTS}/${CIRCLE_PROJECT_REPONAME}_{{.OS}}_{{.Arch}}" $PACKAGE_PATH/...
# Setup our debian package
- cp -r "${PROJECT_DIR}/dist" "/tmp/${DEBIAN_PACKAGE_NAME}"
- chmod 755 "/tmp/${DEBIAN_PACKAGE_NAME}/DEBIAN/postinst"
- chmod 755 "/tmp/${DEBIAN_PACKAGE_NAME}/DEBIAN/prerm"
# Format the control file
- tokenreplace -file "/tmp/${DEBIAN_PACKAGE_NAME}/DEBIAN/control" -token="{build}" -replacement="${CIRCLE_BUILD_NUM}"
# Copy our binary and create our debian package
- mkdir -p "/tmp/${DEBIAN_PACKAGE_NAME}/usr/bin"
- cp "${CIRCLE_ARTIFACTS}/${CIRCLE_PROJECT_REPONAME}_linux_arm" "/tmp/${DEBIAN_PACKAGE_NAME}/usr/bin/${CIRCLE_PROJECT_REPONAME}"
- cd /tmp; dpkg -b "${DEBIAN_PACKAGE_NAME}"; mv *.deb "${CIRCLE_ARTIFACTS}";
deployment:
release:
branch: master
commands:
# Publish assets to Github
- ghr -prerelease -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME v1.0.$CIRCLE_BUILD_NUM $CIRCLE_ARTIFACTS/ || true