forked from bitrise-io/bitrise-steplib
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbitrise.yml
252 lines (226 loc) · 7.8 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
format_version: 1.1.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
envs:
- STEPLIB_SOURCE: 'https://github.com/bitrise-io/bitrise-steplib.git'
# define these ENVs in your .bitrise.secrets.yml
- AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
- S3_UPLOAD_BUCKET: $S3_UPLOAD_BUCKET
- S3_UPLOAD_BUCKET_REGION: $S3_UPLOAD_BUCKET_REGION
- IS_LOCAL_TEST: $IS_LOCAL_TEST
- BITRISE_GIT_BRANCH: $BITRISE_GIT_BRANCH
- BITRISE_BUILD_URL: $BITRISE_BUILD_URL
- BITRISE_APP_TITLE: $BITRISE_APP_TITLE
- SLACK_WEBHOOK_URL: $SLACK_WEBHOOK_URL
- SLACK_CHANNEL: $SLACK_CHANNEL
trigger_map:
- pattern: generate/spec.json
workflow: _generate
workflows:
_notifications:
steps:
- slack:
inputs:
- webhook_url: "${SLACK_WEBHOOK_URL}"
- channel: "${SLACK_CHANNEL}"
- from_username: "${BITRISE_APP_TITLE} - OK"
- from_username_on_error: "${BITRISE_APP_TITLE} - ERROR"
- message: |-
Workflow: *${BITRISE_WORKFLOW_ID}*
Branch: ${BITRISE_GIT_BRANCH}
Build URL: ${BITRISE_BUILD_URL}
install_required_tool_versions:
steps:
- script:
title: Make sure the required Stepman version is installed
run_if: .IsCI
inputs:
- content: |-
#!/bin/bash
set -ex
# curl -fL https://github.com/bitrise-io/bitrise/releases/download/1.2.4/bitrise-$(uname -s)-$(uname -m) > /usr/local/bin/bitrise
# chmod +x /usr/local/bin/bitrise
# bitrise setup --minimal
#
# # Stepman version:
# stepman --version
_generate:
title: Workflow for testing, PR check
description: |-
Adds a clean copy of this StepLib collection to stepman,
calls a setup on it, moves the generated spec.json to
a specified path and makes the path available for other workflows.
steps:
- script:
title: Set TMP_COLLECTION_ID
inputs:
- content: |-
#!/bin/bash
set -ex
envman add --key TMP_COLLECTION_ID --value "file://$(pwd)"
- script:
title: Remove previous version of this local spec from stepman
inputs:
- content: |-
#!/bin/bash
set -ex
stepman delete -c "${TMP_COLLECTION_ID}"
- script:
title: Generate
dependencies:
- manager: brew
name: jq
inputs:
- content: |-
#!/bin/bash
set -ex
tmp_dir="$(pwd)/_tmp"
mkdir -p "${tmp_dir}"
spec_path="${tmp_dir}/spec.json"
stepman setup -c "${TMP_COLLECTION_ID}" --copy-spec-json="${spec_path}"
slim_spec_path="$(find "${HOME}/.stepman" -name slim-spec.json | head -n1)"
# write out minimized slim-spec.json
jq --compact-output '.' ${slim_spec_path} > "${tmp_dir}/slim-spec.json"
envman add --key SPEC_JSON_PATH --value "${spec_path}"
envman add --key SLIM_JSON_PATH --value "${spec_path/spec.json/slim-spec.json}"
- script:
title: tmp
inputs:
- content: |-
#!/bin/bash
set -e
echo "SPEC_JSON_PATH: ${SPEC_JSON_PATH}"
echo "SLIM_JSON_PATH: ${SLIM_JSON_PATH}"
pr_audit:
title: Pull Request audit
description: |-
Performs an audit only on the changed step.yml files, and on the
related Steps.
Development Note: if `IS_LOCAL_TEST` is enabled it'll check the
changes in the local git staging/cache.
envs:
- BITRISE_WORKFLOW_ID: pr_audit
before_run:
- _generate
after_run:
- _notifications
steps:
- script:
title: List of changed files
dependencies:
- manager: brew
name: go
inputs:
- content: |-
set -e
localtest_param=""
if [[ "${IS_LOCAL_TEST}" == "true" ]] ; then
localtest_param="--localtest"
fi
go get github.com/hashicorp/go-version
go get github.com/bitrise-io/go-utils/command
go get github.com/bitrise-io/go-utils/fileutil
go get github.com/bitrise-io/go-utils/pathutil
go get github.com/bitrise-io/go-utils/log
go get gopkg.in/yaml.v2
go run ./_scripts/audit/audit_changed_steps.go --collectionid "${TMP_COLLECTION_ID}" ${localtest_param}
- script:
title: Check icon for the changes steps
dependencies:
- manager: brew
name: go
inputs:
- content: |-
set -e
go get github.com/hashicorp/go-version
go get github.com/bitrise-io/go-utils/command
go get github.com/bitrise-io/go-utils/fileutil
go get github.com/bitrise-io/go-utils/pathutil
go get github.com/bitrise-io/go-utils/log
go get gopkg.in/yaml.v2
go run ./_scripts/audit_icons/audit_icons.go --collectionid "${TMP_COLLECTION_ID}" ${localtest_param}
full_audit:
title: Full Audit
description: |-
Performs a full audit on the collection.
before_run:
- _generate
steps:
- script:
title: Run full audit on the StepLib collection
inputs:
- content: |-
set -ex
stepman audit --collection "${TMP_COLLECTION_ID}"
deploy:
title: Workflow for deployment
description: |-
Deploys the StepLib to Amazon S3
envs:
- AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
- S3_UPLOAD_BUCKET_REGION: $S3_UPLOAD_BUCKET_REGION
- S3_UPLOAD_BUCKET: $S3_UPLOAD_BUCKET
- BITRISE_WORKFLOW_ID: "DEPLOY"
before_run:
- install_required_tool_versions
- full_audit
after_run:
- _notifications
steps:
- script:
title: Check spec.json - exist?
inputs:
- content: |-
#!/usr/bin/env bash
if [[ ! -f "${SPEC_JSON_PATH}" ]] ; then
echo " [!] spec.json does not exist at path: ${SPEC_JSON_PATH}"
exit 1
fi
if [[ ! -f "${SLIM_JSON_PATH}" ]] ; then
echo " [!] slim-spec.json does not exist at path: ${SLIM_JSON_PATH}"
exit 1
fi
- script:
title: Fix steplib_source in spec.json
inputs:
- content: |-
require 'json'
spec_json_pth = ENV['SPEC_JSON_PATH']
puts " -> spec_json_pth: #{spec_json_pth}"
file = File.read(spec_json_pth)
data_hash = JSON.parse(file)
puts " -> original steplib source: #{data_hash['steplib_source']}"
steplib_source_param = ENV['STEPLIB_SOURCE']
puts " -> steplib_source_param: #{steplib_source_param}"
data_hash['steplib_source'] = steplib_source_param
File.write(spec_json_pth, JSON.pretty_generate(data_hash))
puts "DONE - OK"
- runner_bin: ruby
- script:
title: Generate
dependencies:
- manager: brew
name: s3cmd
inputs:
- content: |-
#!/bin/bash
set -ex
bash ./_scripts/deploy/deploy.sh
- script:
title: Upload slim.json
dependencies:
- manager: brew
name: awscli
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
aws s3 cp "${SLIM_JSON_PATH}" "s3://${S3_UPLOAD_BUCKET}/slim-spec.json" --acl public-read
aws s3 cp "${SLIM_JSON_PATH}" "s3://${S3_UPLOAD_BUCKET}/slim-spec.json.gz" --acl public-read --content-encoding gzip
quicktest:
description: |-
A workflow for testing quick bitrise.yml changes
after_run:
- _notifications