-
Notifications
You must be signed in to change notification settings - Fork 50
/
bitrise.yml
197 lines (180 loc) · 6.23 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
189
190
191
192
193
194
195
196
197
format_version: 3
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
envs:
- GO_PROJECT_PATH: github.com/bitrise-io/bitrise-webhooks
- GO_VERSION: 1.21.2
- PORT: "4000"
- IS_USE_GIN: "yes"
opts:
description: |
If set to "yes" we'll use github.com/codegangsta/gin to live-reload the code on change.
- RELEASE_START_BRANCH: master
- RELEASE_DESTINATION_BRANCH: prod
workflows:
_install_test_tools:
steps:
- script:
title: Install required testing tools
inputs:
- content: |-
#!/bin/bash
set -ex
# Check for unhandled errors
go install github.com/kisielk/errcheck@latest
# Go lint
go install golang.org/x/lint/golint@latest
publish-release-package:
before_run:
- configure-git-credentials
after_run:
- create-release
- configure-upstream
- publish-release
configure-git-credentials:
steps:
- set-git-credentials@1:
inputs:
- git_user_name: "$WEBSITEBOT_USER"
- git_email_address: "$WEBSITEBOT_EMAIL"
create-release:
steps:
- script:
title: Create version bump commit
inputs:
- content: |-
#!/bin/bash
set -e
echo
echo 'How to roll-back?'
echo '* if you want to undo the last commit you can call:'
echo ' $ git reset --hard HEAD~1'
echo '* to roll back to the remote state:'
echo ' $ git reset --hard origin/[branch-name]'
echo
set -x
version_file_path="./version/version.go"
git fetch
git checkout ${RELEASE_START_BRANCH}
current_version="$(go run _scripts/get_version.go -file "$version_file_path")"
bumped_version=$(ruby -e "splits='${current_version}'.split('.');major=splits[0];minor=splits[1];patch=splits[2];puts \"#{major}.#{minor}.#{patch.to_i.next}\"")
bash _scripts/set_version.sh "$version_file_path" "$bumped_version"
git add "$version_file_path"
git commit -m "v${bumped_version} [skip ci]"
echo
echo '------------'
git show
echo '------------'
echo
git checkout ${RELEASE_DESTINATION_BRANCH}
git pull
git merge ${RELEASE_START_BRANCH} --no-ff -m "Merge ${RELEASE_START_BRANCH} into ${RELEASE_DESTINATION_BRANCH}, release: v${bumped_version}"
git tag "${bumped_version}"
echo
echo '------------'
git show
echo '------------'
echo
git checkout ${RELEASE_START_BRANCH}
configure-upstream:
steps:
- script:
title: Configure the upstream repo
inputs:
- content: |-
#!/usr/bin/env bash
set -e
set -x
echo ${GIT_REPOSITORY_URL}
stripped_url=$(echo $GIT_REPOSITORY_URL | sed -e 's/^http:\/\///g' -e 's/^https:\/\///g')
git remote add upstream https://websitebot:${GITHUB_AUTH_TOKEN}@${stripped_url}
git fetch upstream
publish-release:
steps:
- script:
title: Publish the prepared release, push the commits
inputs:
- content: |-
#!/bin/bash
set -ex
git checkout ${RELEASE_START_BRANCH}
git push upstream
git push upstream --tags
git checkout ${RELEASE_DESTINATION_BRANCH}
git push upstream
git push upstream --tags
git checkout ${RELEASE_START_BRANCH}
start:
steps:
- script:
inputs:
- content: |-
#!/bin/bash
set -ex
go install $GO_PROJECT_PATH
if [ "$IS_USE_GIN" == "yes" ] ; then
(go install github.com/codegangsta/gin@latest)
gin --port $PORT
else
bitrise-webhooks -port $PORT
fi
test:
before_run:
- _install_test_tools
steps:
- script:
title: Update go
run_if: .IsCI
inputs:
- content: |
#!/bin/bash
set -ex
./_scripts/update_go.sh
# some legacy steps don't have go.mod and would fail without this
go env -w GO111MODULE=auto
- script:
title: Print infos for the test
inputs:
- content: |-
set -x
go version
- script:
title: GOLIST_WITHOUT_VENDOR
inputs:
- content: |-
set -ex
no_vendor_paths="$(go list ./... | grep -v vendor)"
envman add --key GOLIST_WITHOUT_VENDOR --value "$no_vendor_paths"
- script:
title: Go Test
inputs:
- content: go test ./...
- script:
title: Go Vet
inputs:
- content: go vet ./...
- script:
title: Err check
inputs:
- content: |-
#!/bin/bash
set -ex
if [ -x "$(command -v asdf)" ]; then
asdf reshim golang
fi
errcheck -asserts=true -blank=true $GOLIST_WITHOUT_VENDOR
- script:
title: Go Lint
inputs:
- content: |-
#!/bin/bash
set -e
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"