forked from stm32duino/Arduino_Core_STM32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
executable file
·207 lines (160 loc) · 5.7 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
image: smartmeio/arancino-library-build
stages:
- start
- package
- upload
- cleanup
#################################
####### START #######
#################################
####### START
start:
stage: start
variables:
GIT_STRATEGY: none
script:
- 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
only: ['tags']
except: ['master', 'branches']
allow_failure: true
variables:
GIT_STRATEGY: clone
before_script:
# - sed -i "s/version=.*/version=${CI_COMMIT_TAG}/g" library.properties
- 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
script:
# create some variables into temp folder
- PKG_NAME=$PLATFORM_NAME-$CI_COMMIT_TAG
- PKG_NAME_PIO=framework-arduino-stm32-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/arduino/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 STM32FreeRTOS into core
- git clone $REPO_RTOS_URL -b 10.2.1 libraries/STM32duino_FreeRTOS
# 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* -cvjf $PKG_NAME.tar.bz2 $CI_PROJECT_NAME
# pio packaging
- cp -r $CI_PROJECT_NAME framework-arduino-stm32-arancino
- tar --exclude=tmp --exclude=.git* --exclude=*.DS_Store* -cvjf $PKG_NAME_PIO.tar.bz2 framework-arduino-stm32-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
#################################
####### CLEANUP #######
#################################
####### Cleanup Job #######
cleanup:
stage: cleanup
variables:
GIT_STRATEGY: none
script:
- echo "Cleaning up"
- rm -rf tmp/
when: always
only:
- tags
except:
- master
- branches