forked from earlephilhower/arduino-pico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
321 lines (250 loc) · 9.36 KB
/
.gitlab-ci.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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
image: smartmeio/arancino-library-build
stages:
- start
- package
- upload
- index
- cleanup
#################################
####### START #######
#################################
####### START
start:
stage: start
variables:
GIT_STRATEGY: none
script:
- rm -rf tmp/
- mkdir -p tmp
- echo `date +%Y-%m-%d` > tmp/date.txt
- echo `date +%H-%M-%S` > tmp/time.txt
artifacts:
paths:
- tmp/
expire_in: 1d
only:
- tags
except:
- master
- branches
######## PUSH
push:
stage: start
when: manual
only: ['tags']
except: ['master', 'branches']
allow_failure: true
variables:
GIT_STRATEGY: clone
before_script:
- eval `python3 check-version-tag.py ${CI_COMMIT_TAG}`
script:
#- apk add git
- git remote add github https://$GITHUB_BOT_USERNAME:[email protected]/$GITHUB_DEST_REPO
#- git remote show github
#- git remote show origin
#- git branch -a
- git checkout $CI_COMMIT_TAG
- git fetch github
#- git push github $CI_COMMIT_REF_NAME --force
- >
if [[ ${PRE_RELEASE} == "test" ]]; then
echo "not performing TAG push";
else
git push github ${CI_COMMIT_TAG}
fi
- git push github --all --force
#################################
####### PACKAGE #######
#################################
####### Package Release #######
package_release:
stage: package
variables:
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: normal
before_script:
# Do some replacements in platform.txt file, which are required because IDE
# handles tool paths differently when package is installed in hardware folder
- >
cat platform.txt |
sed 's/^runtime.tools.pqt-.*.path=.*//g' |
sed 's/^tools.uf2conv.cmd=.*//g' |
sed 's/^#tools.uf2conv.cmd=/tools.uf2conv.cmd=/g' |
sed 's/^tools.picoprobe.cmd=.*//g' |
sed 's/^#tools.picoprobe.cmd=/tools.picoprobe.cmd=/g' | tee /tmp/platform.txt
- rm platform.txt
- mv /tmp/platform.txt .
# Put core version and short hash of git version into core_version.h
- echo "#define ARDUINO_RP2040_GIT_VER 0x`git rev-parse --short=8 HEAD 2>/dev/null`" > cores/rp2040/core_version.h
- echo "#define ARDUINO_RP2040_GIT_DESC `git describe --tags 2>/dev/null`" >> cores/rp2040/core_version.h
- echo "#define ARDUINO_RP2040_RELEASE_$CI_COMMIT_TAG" >> cores/rp2040/core_version.h
- echo "#define ARDUINO_RP2040_RELEASE $CI_COMMIT_TAG" >> cores/rp2040/core_version.h
# cloning additional submodules for pico-sdk
- cd pico-sdk && git submodule update --init && cd ..
script:
# create some variables into temp folder
- PKG_NAME=$PLATFORM_NAME-$CI_COMMIT_TAG
- PKG_NAME_PIO=framework-arduino-rp2040-arancino-$CI_COMMIT_TAG
- echo $PKG_NAME > tmp/pkg_name.txt
- echo $PKG_NAME_PIO > tmp/pkg_name_pio.txt
- echo $CI_COMMIT_TAG > tmp/target_path.txt
- sed -i "s:\(ARANCINO_CORE_VERSION\) .*:\1 \"$CI_COMMIT_TAG\":" ./cores/rp2040/Arduino.h
- sed -i "s:\(version\)=.*:\1=$CI_COMMIT_TAG:" ./platform.txt
- jq --arg tag_ver ${CI_COMMIT_TAG} '.version = $tag_ver' package.json|sponge package.json
# adding ArduinoJson into core
- git clone $REPO_LIB_ARDUINOJSON_URL -b v6.18.0 libraries/ArduinoJson
# adding MsgPack into core
- git clone $REPO_LIB_MSGPACK_URL -b 0.3.8 libraries/MsgPack
# adding MsgPacketizer into core
- git clone $REPO_LIB_MSGPACKETIZER_URL -b 0.3.0 libraries/MsgPacketizer
# adding Microcontroller ID into core
- git clone $REPO_LIB_MICROCONTROLLER_ID_URL -b 1.0.0 libraries/Microcontroller-id
# adding MQTT PubSubClient into core
- git clone $REPO_LIB_PUBSUBCLIENT_URL -b v2.8 libraries/PubSubClient
- cd ..
# tar files and move temp folder back
- >
tar --exclude=tmp --exclude=.git* --exclude=*.DS_Store* \
--exclude=package --exclude=doc \
--exclude=.travis.yml -cvjf $PKG_NAME.tar.bz2 $CI_PROJECT_NAME
# pio packaging
- cp -r $CI_PROJECT_NAME framework-arduino-rp2040-arancino
- >
tar --exclude=tmp --exclude=.git* --exclude=*.DS_Store* \
--exclude=package --exclude=doc \
--exclude=.travis.yml -cvjf $PKG_NAME_PIO.tar.bz2 framework-arduino-rp2040-arancino
# move tar into temp folder
- cd $CI_PROJECT_NAME
- mv ../$PKG_NAME.tar.bz2 tmp/
- mv ../$PKG_NAME_PIO.tar.bz2 tmp/
# create files containing sha 256 checksum and size in bytes of the tar file
- sha256sum tmp/$PKG_NAME.tar.bz2 | awk '{print $1}' > tmp/SHA256.txt
- du -b tmp/$PKG_NAME.tar.bz2 | awk {'print $1}' > tmp/SIZE.txt
- echo FILENAME $PKG_NAME.tar.bz2
- echo SHA-256 `cat tmp/SHA256.txt`
- echo SIZE `cat tmp/SIZE.txt`
- echo PKG_NAME `cat tmp/pkg_name.txt`
# same step above but for PIO
- sha256sum tmp/$PKG_NAME_PIO.tar.bz2 | awk '{print $1}' > tmp/SHA256_pio.txt
- du -b tmp/$PKG_NAME_PIO.tar.bz2 | awk {'print $1}' > tmp/SIZE_pio.txt
- echo FILENAME_PIO $PKG_NAME_PIO.tar.bz2
- echo SHA-256-PIO `cat tmp/SHA256_pio.txt`
- echo SIZE_PIO `cat tmp/SIZE_pio.txt`
- echo PKG_NAME_PIO `cat tmp/pkg_name_pio.txt`
dependencies:
- start
artifacts:
paths:
- tmp/
except:
- branches
- master
only:
- tags
#################################
####### UPLOAD #######
#################################
####### Upload Staging and Release #######
upload:
stage: upload
before_script:
- eval `python3 check-version-tag.py ${CI_COMMIT_TAG}`
script:
- DATE="$(cat tmp/date.txt)"
- TIME="$(cat tmp/time.txt)"
- PKG_NAME="$(cat tmp/pkg_name.txt)"
- PKG_NAME_PIO="$(cat tmp/pkg_name_pio.txt)"
- TARGET_PATH="$(cat tmp/target_path.txt)"
- >
if [[ ${PRE_RELEASE} == "test" ]]; then
REPO_NAME=${REPO_NAME}-snapshot
REPO_NAME_PIO=${REPO_NAME_PIO}-snapshot
fi
# Upload to Artifactory
- curl -u $REPO_USR:$REPO_PWD -T tmp/$PKG_NAME.tar.bz2 "${REPO_BASE_URL}/artifactory/${REPO_NAME}/${TARGET_PATH}/${PKG_NAME}.tar.bz2"
- curl -u $REPO_USR:$REPO_PWD -T tmp/$PKG_NAME_PIO.tar.bz2 "${REPO_BASE_URL}/artifactory/${REPO_NAME_PIO}/${TARGET_PATH}/${PKG_NAME_PIO}.tar.bz2"
only:
- tags
except:
- master
- branches
#################################
######## INDEX ########
#################################
####### Create Json Index Entry for the Arduino Board Index #######
index:
stage: index
before_script:
- eval `python3 check-version-tag.py ${CI_COMMIT_TAG}`
script:
- VERSION=${CI_COMMIT_TAG}
# definisco la URL in base al core ed al tag
- >
if [[ ${CORE_NAME} == "samd21" ]]; then
URL="smartmeio-arancino-platform"
else
URL="smartmeio-arancino-platform-$CORE_NAME"
fi
if [[ ${PRE_RELEASE} != "" ]]; then
URL="$URL-snapshot"
fi
#git clone della repo dell'index ()
- git config user.name devops
- git config user.email [email protected]
- git clone https://$REPO_USR:[email protected]/smartme.io/arancino/ide/smartmeio-package-index.git tmp/index
- cd tmp/index
- git checkout dev
- package_template=`cat template_platform_smartmeio_$CORE_NAME.json`
#creazione file a partire dal template
- FILENAME=smartmeio-arancino-${VERSION}.tar.bz2
- SIZE=`cat ../SIZE.txt`
- SHASUM=`cat ../SHA256.txt`
- >
package_template=`echo $package_template |
sed s/%%FILENAME%%/${FILENAME}/g |
sed s/%%SIZE%%/${SIZE}/g |
sed s/%%SHA256%%/${SHASUM}/g|
sed s/%%URL%%/${URL}/g |
sed s/%%VERSION%%/${CI_COMMIT_TAG}/g`
#- set +x
#- echo $package_index
# export del contenuto su file
- echo $package_template > ../platform_index.json
# merge del file template all'interno dell'index
- python3 ../../index-update.py
#push dev
- git add package_smartmeio_index.json
- git commit -m "adding $CORE_NAME platform realease $VERSION"
- git push origin dev
#push master
- >
if [ "$PRE_RELEASE" = "" ]; then
git checkout master
python3 ../../index-update.py
git add package_smartmeio_index.json
git commit -m "adding $CORE_NAME platform realease $VERSION"
git push origin master
fi
only:
- tags
except:
- master
- branches
#################################
####### CLEANUP #######
#################################
####### Cleanup Job #######
cleanup:
stage: cleanup
variables:
GIT_STRATEGY: none
script:
- echo "Cleaning up"
- rm -rf tmp/
when: always
only:
- tags
except:
- master
- branches