-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
278 lines (263 loc) · 9.58 KB
/
config.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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/configuration-reference
version: 2.1
orbs:
win: circleci/windows@5.0
gh: circleci/github-cli@2.3.0
# Orchestrate jobs using workflows
# See: https://circleci.com/docs/configuration-reference/#workflows
workflows:
neopic-workflow:
jobs:
- build-linux:
filters:
branches:
ignore: /.*/
tags:
only: /^(circleci|release)-.*/
- build-macos:
filters:
branches:
ignore: /.*/
tags:
only: /^(circleci|release)-.*/
- build-windows:
filters:
branches:
ignore: /.*/
tags:
only: /^(circleci|release)-.*/
- create-release:
requires: # only release, if all 3 pass, naturally
- build-linux
- build-macos
- build-windows
filters:
branches:
ignore: /
tags:
only: /^release-.*/
# Reuse a sequence of steps
# See: https://circleci.com/docs/configuration-reference/#workflows
commands:
steps-before:
steps:
- run:
name: release-build on github ONLY
command: |
echo "CIRCLE_JOB B: $CIRCLE_JOB"
if [[ "$CIRCLE_TAG" == release-* && "$CIRCLE_IS_GITHUB" != "true" ]]; then
echo "release-tag shall run only on github. skipping on bitbucket."
circleci-agent step halt
fi
echo "proceeding with circleci run"
# note: checkout must be before mkdir, mkdir must be before sanity test 😬
- checkout
- run: mkdir -p ./out/make ./out/junit
- run:
name: sanity test
command: |
echo "pwd: $PWD node version: $(node --version) shell: $SHELL uname: $(uname)"
steps-after:
steps:
- run:
name: set PASS flag
when: on_success
command: |
mkdir -p workspace
echo "export THIS_RUN=PASS" >> "$BASH_ENV"
echo PASS > workspace/${CIRCLE_JOB/build-/result_}
- run:
name: set FAIL flag
when: on_fail
command: |
mkdir -p workspace
echo "export THIS_RUN=FAIL" >> "$BASH_ENV"
echo PASS > workspace/${CIRCLE_JOB/build-/result_}
- run:
name: "write badge to gist"
when: always
command: |
COLOR="unclear"
STATUS="unclear"
if [ "$THIS_RUN" == "PASS" ]; then
COLOR="brightgreen"
STATUS="pass"
elif [ "$THIS_RUN" == "FAIL" ]; then
COLOR="red"
STATUS="failed"
fi
JSON_PAYLOAD='{"files": { "'"${CIRCLE_JOB/build-/neopic-status-}.json"'": {"content": "{\"schemaVersion\": 1, \"label\": \"'${CIRCLE_JOB#build-}' build \", \"message\": \"'"$STATUS"'\", \"color\": \"'"$COLOR"'\"}"}}}'
curl -L -X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-d "$JSON_PAYLOAD" \
"https://api.github.com/gists/$GITHUB_GIST"
- store_artifacts:
path: out/make
- run:
name: persist on tag release ONLY
command: |
if [[ "$CIRCLE_TAG" != release-* ]]; then
echo "github release only with tag release-*. thus ending here for $CIRCLE_TAG."
circleci-agent step halt
fi
echo 'export RELEASE_VERSION_NUMBER="${CIRCLE_TAG#release-}"' >> "$BASH_ENV"
echo "proceeding with release on github"
- persist_to_workspace:
root: .
paths:
- out/make
# Jobs to be invoked in a workflow.
# See: https://circleci.com/docs/configuration-reference/#jobs
jobs:
build-linux:
docker:
- image: cimg/node:20.10.0
steps:
- steps-before
- restore_cache:
key: dependency-B-linux-{{ checksum "package.json" }}
- run: npm install
- run: npm run test:ci
- store_test_results:
path: out/junit
- run:
name: Install OS specific
command: |
sudo apt-get update -y
# rpm only needed for MakerRpm
sudo apt-get install -y dpkg fakeroot rpm
# all of these only needed for running (in selftest)
sudo apt-get install -y libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 libatspi2.0-0 libdrm2 libgbm1 libasound2 libcups2 libatk1.0-0 libatk-bridge2.0-0 xvfb
# reduce dbus warning on linux selftest
sudo apt-get install -y dbus
sudo dbus-uuidgen --ensure
sudo service dbus start
- save_cache:
key: dependency-B-linux-{{ checksum "package.json" }}
paths:
- ./node_modules
- run: npm run make
- run:
name: List store_artifacts
command: ls -lR ./out
- run:
name: start mock display
background: true
command: Xvfb :99 -screen 0 1920x1080x24
- run:
name: electron selftest (linux)
command: |
export DISPLAY=:99
./out/neopic-linux-x64/neopic -selftest --disable-gpu
exitcode=$?
if [ $exitcode -ne 0 ]; then
echo "Failure or exit with code $exitcode"
exit $exitcode
fi
echo "selftest success"
- steps-after
build-macos:
macos:
xcode: 15.1.0
steps:
- run: xcodebuild -version
- steps-before
- restore_cache:
key: dependency-B-macos-{{ checksum "package.json" }}
- run: npm install
- run: npm run test:ci
- store_test_results:
path: out/junit
- run:
name: Install dpkg and fakeroot
command: |
brew update
brew install dpkg fakeroot
- save_cache:
key: dependency-B-macos-{{ checksum "package.json" }}
paths:
- ./node_modules
- run: npm run make
- run:
name: List store_artifacts
command: ls -lR ./out
- run:
name: electron selftest (mac)
command: |
./out/neopic-darwin-x64/neopic.app/Contents/MacOS/neopic -selftest
exitcode=$?
if [ $exitcode -ne 0 ]; then
echo "Failure or exit with code $exitcode"
exit $exitcode
fi
echo "selftest success"
- steps-after
build-windows:
executor:
name: win/default
shell: bash
steps:
- steps-before
- restore_cache:
key: dependency-C-windows-{{ checksum "package.json" }}
- run: npm install
- store_test_results:
path: out/junit
- save_cache:
key: dependency-C-windows-{{ checksum "package.json" }}
paths:
- ./node_modules
- run: npm run make
- run:
name: List store_artifacts
command: ls -lR ./out
- run:
name: electron.exe selftest (win)
command: |
./out/neopic-win32-x64/neopic.exe -selftest
exitcode=$?
if [ $exitcode -ne 0 ]; then
echo "Failure or exit with code $exitcode"
exit $exitcode
fi
echo "selftest success"
- steps-after
create-release:
docker:
- image: cimg/node:20.10.0
environment:
SOURCE_CODE_NOTICE: |
⚠️ Please ignore the Source Code files (`Source code(zip), Source code (tar.gz)`)
( github [insists on creating them](https://github.com/orgs/community/discussions/6003). )
steps:
- checkout # CHANGELOG.md and `gh release create` need checkout
- gh/install
- attach_workspace:
at: ./artifacts
- run:
name: create release
command: |
ARTIFACTS_BASE="./artifacts/out/make"
# wipe out spaces for underscores (serious problem in github artifacts, and there is one, before `… setup.exe`)
find $ARTIFACTS_BASE -type f -name '* *' -exec bash -c 'mv "$0" "${0// /_}"' {} \;
# prefix builds with they platform they are meant for, for clarity
find $ARTIFACTS_BASE -type f \( -name '*.rpm' -o -name '*.deb' \) -exec bash -c 'mv "$0" "${0%/*}/LINUX_${0##*/}"' {} \;
find $ARTIFACTS_BASE -type f \( -name '*.exe' -o -name '*.nupkg' \) -exec bash -c 'mv "$0" "${0%/*}/WIN_${0##*/}"' {} \;
find $ARTIFACTS_BASE -type f \( -name '*.zip' -o -name '*.dmg' \) -exec bash -c 'mv "$0" "${0%/*}/MAC_${0##*/}"' {} \;
# sanity preview
echo "files to be released (spaces converted to underscores, platform prefixes)"
find $ARTIFACTS_BASE -type f \( -name '*.deb' -o -name '*.rpm' -o -name '*.zip' -o -name '*.exe' -o -name '*.nupkg' \)
ARTIFACTS=$(find $ARTIFACTS_BASE -type f \( -name '*.deb' -o -name '*.rpm' -o -name '*.zip' -o -name '*.exe' -o -name '*.nupkg' \))
# allow overriding existing review (idempotency)
# this warning is ok (dealt with in scripts/circleci): ! Note that the release-….….… git tag still remains in the repository
if gh release view "${CIRCLE_TAG}" > /dev/null 2>&1; then
gh release delete "${CIRCLE_TAG}" -y
fi
echo "${SOURCE_CODE_NOTICE}" > RELEASE_NOTES_TEMP.txt
gh release create "${CIRCLE_TAG}" \
--title "${CIRCLE_TAG#release-}" \
--notes-file RELEASE_NOTES_TEMP.txt \
$ARTIFACTS