-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbitrise.yml
188 lines (164 loc) · 6.01 KB
/
bitrise.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
format_version: 5
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
envs:
- RELEASE_VERSION: 0.0.1
- BIN_NAME: bitrise-plugins-service
- OSX_BIN_NAME: bitrise-plugins-service-Darwin-x86_64
- LINUX_BIN_NAME: bitrise-plugins-service-Linux-x86_64
workflows:
# ----------------------------------------------------------------
# --- workflows for CI and testing
test:
before_run:
- go-test
steps:
go-test:
steps:
- script:
title: Export go files to test
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
no_vendor_paths="$(go list ./... | grep -v vendor)"
envman add --key GOLIST_WITHOUT_VENDOR --value "$no_vendor_paths"
- script:
title: Err check
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go get -u github.com/kisielk/errcheck
errcheck -asserts=true -blank=true $GOLIST_WITHOUT_VENDOR
- script:
title: Go lint
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go get -u golang.org/x/lint/golint
while read -r line; do
echo "-> Linting: $line"
golint_out="$(golint $line)"
if [[ "${golint_out}" != "" ]] ; then
echo "=> Golint issues found:"
echo "${golint_out}"
exit 1
fi
done <<< "$GOLIST_WITHOUT_VENDOR"
- script:
title: Go test
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go test $(go list ./... | grep -v vendor)
_embed_resources:
steps:
- script@1.1.3:
title: rice embed
inputs:
- content: |-
#!/bin/bash
set -ex
go get github.com/GeertJohan/go.rice/rice
cd ./create
rice embed-go
integration-test:
steps:
- script:
title: Go build
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
# build the new bitrise-plugins-service
current_dir=$(pwd)
current_bin=$current_dir/_tmp/${BIN_NAME}
go build -o $current_bin
envman add --key CURRENT_BIN --value $current_bin
- script:
title: Run integration tests
inputs:
- content: |-
#!/usr/bin/env bash
echo "Running integration tests ..."
set -ex
export INTEGRATION_TEST_BINARY_PATH="$CURRENT_BIN"
go test -v -tags=integration ./integrationtests/...
# ----------------------------------------------------------------
# --- workflows for Releasing
create-release:
title: Create release with Releaseman
before_run:
- test
after_run:
- _embed_resources
- create_binaries
- update_plugin_defintion
steps:
- script:
title:
inputs:
- content: |
#!/usr/bin/env bash
set -ex
go get -u github.com/bitrise-tools/releaseman@236729b52920a686f4379b36f658335df20c8039
# go get -u github.com/bitrise-tools/releaseman
export CI=true
releaseman create-changelog \
--version "$RELEASE_VERSION" \
--set-version-script "bash _scripts/set_version.sh version/version.go"
create_binaries:
title: Create binaries
description: |
Creates Linux and Darwin binaries
steps:
- script:
title: create Linux and macOS (Darwin) bins, with version infos
inputs:
- content: |-
#!/usr/bin/env bash
set -e
echo
echo "Create release binaries"
echo " * Build number: $BITRISE_BUILD_NUMBER"
echo
set -x
git_commit_hash="$(git rev-parse HEAD)"
version_package="github.com/bitrise-core/bitrise-plugins-service/version"
export ARCH=x86_64
export GOARCH=amd64
# Create Darwin bin
export OS=Darwin
export GOOS=darwin
binary_path="_bin/${BIN_NAME}-${OS}-${ARCH}"
go build \
-ldflags "-X ${version_package}.VERSION=${RELEASE_VERSION} -X ${version_package}.BuildNumber=${BITRISE_BUILD_NUMBER} -X ${version_package}.Commit=${git_commit_hash}" \
-o "${binary_path}"
cp "${binary_path}" "${BITRISE_DEPLOY_DIR}/${BIN_NAME}-${OS}-${ARCH}"
envman add --key OSX_BIN_NAME --value "${BIN_NAME}-${OS}-${ARCH}"
# Create Linux binary
export OS=Linux
export GOOS=linux
binary_path="_bin/${BIN_NAME}-${OS}-${ARCH}"
go build \
-ldflags "-X ${version_package}.VERSION=${RELEASE_VERSION} -X ${version_package}.BuildNumber=${BITRISE_BUILD_NUMBER} -X ${version_package}.Commit=${git_commit_hash}" \
-o "${binary_path}"
cp "${binary_path}" "${BITRISE_DEPLOY_DIR}/${BIN_NAME}-${OS}-${ARCH}"
envman add --key LINUX_BIN_NAME --value "${BIN_NAME}-${OS}-${ARCH}"
update_plugin_defintion:
steps:
- script:
title: Create binaries
inputs:
- content: |-
#!/usr/bin/env bash
set -e
go get github.com/bitrise-io/go-utils/fileutil
go run _scripts/set_version.go \
--src "https://github.com/bitrise-io/bitrise-plugins-service" \
--version "$RELEASE_VERSION" \
--osx_bin "$OSX_BIN_NAME" \
--linux_bin "$LINUX_BIN_NAME"