-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
196 lines (164 loc) · 5.92 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
# Project: Arancino Library - Serial Manager
# Author: Sergio Tomasello <[email protected]>
# Created: 2018.10.11
# Notes: La pipeline esegue la creazione dell'archivio della libreria compatibile per Aduino IDE
# Internal Vars: Lista delle variabili definete internamente ed usate nella pipeline:
# DATE: data di esecuzione della pipeline
# PKG_NAME: nome del pacchetto
# REPO_NAME: nome del repository di produzione, composto da due parti:
# il nome del progetto -> $CI_PROJECT_NAME
# ambiente di lavoro: -> "staging" o "release"
# $CI_PROJECT_NAME-staging
# $CI_PROJECT_NAME-release
# REPO_DIR: nome della directory di upload del repository, composto da due parti:
# il nome del progetto -> $CI_PROJECT_NAME
# ambiente di lavoro: -> "staging" o "release"
# $CI_PROJECT_NAME/staging
# $CI_PROJECT_NAME/release
#
# External Vars: Lista delle variabili definite estarnamente ed usate nella pipeline:
# REPO_USR: nome utente del associato a dev ops per effettuare upload dell'artefatto
# REPO_PWD: password associata all'utente dev ops
# REPO_BASE_URL: url di base del repository: https://download.smartme.io
#
image: smartmeio/arancino-library-build
stages:
- start
- test
- package
- upload
- cleanup
#################################
####### START #######
#################################
####### START
start:
stage: start
only: ['tags']
except: ['master', 'branches']
variables:
GIT_STRATEGY: none
script:
- mkdir -p tmp
- echo `date +%Y-%m-%d` > tmp/date.tmp
- echo `date +%H-%M-%S` > tmp/time.tmp
artifacts:
paths:
- tmp/
expire_in: 1d
######## 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
#################################
####### TEST #######
#################################
####### CLI Sketch Test Job #######
cli-test:
stage: test
#only: ['tags']
#except: ['master', 'branches']
# copying the Library source to the Arduino libraries folder
before_script:
- sed -i "s/version=.*/version=${CI_COMMIT_TAG}/g" library.properties
- cp -r ${CI_PROJECT_DIR} ${HOME}/Arduino/libraries/Arancino
- chmod +x ./test/arduino-cli-test.sh
# we feed the test scripts the simple board to complete the FQBN entry
script:
- ./test/arduino-cli-test.sh arancino
- ./test/arduino-cli-test.sh arancino_mignon
####### Package Release #######
#esegue la compressione del pacchetto quando viene creato un tag (ovvero ad ogni release)
package_release:
stage: package
only: ['tags']
except: ['master', 'branches']
script:
#- apk add zip
#- DATE="$(cat tmp/date.tmp)"
# packaging for PlatformIO
- jq --arg tag_ver ${CI_COMMIT_TAG} '.version = $tag_ver' library.json|sponge library.json
- pio package pack -o /tmp
# standard packaging as ZIP archive
- sed -i "s/version=.*/version=${CI_COMMIT_TAG}/g" library.properties
- PKG_NAME=$CI_PROJECT_NAME-$CI_COMMIT_TAG
- echo $PKG_NAME > tmp/pgk_name.tmp
- echo $CI_PROJECT_NAME > tmp/repo_name.tmp
- echo $CI_COMMIT_TAG > tmp/target_path.tmp
- mv tmp/ ../tmp && cd ../
#- tar --exclude='*.git*' --exclude='*.DS_Store*' -zcvf $PKG_NAME.zip $CI_PROJECT_NAME/
- zip -r $PKG_NAME.zip $CI_PROJECT_NAME -x "$CI_PROJECT_NAME/check-version-tag.py" -x "$CI_PROJECT_NAME/*.git*" "$CI_PROJECT_NAME/*.DS_Store*"
- mv tmp/ $CI_PROJECT_NAME/
- mv $PKG_NAME.zip $CI_PROJECT_NAME/tmp/
dependencies:
- start
artifacts:
paths:
- tmp/
#################################
####### UPLOAD #######
#################################
####### Upload Staging and Release #######
#carica sul repository manager
upload:
stage: upload
only: ['tags']
except: ['master', 'branches']
variables:
GIT_STRATEGY: none
before_script:
- eval `python3 check-version-tag.py ${CI_COMMIT_TAG}`
script:
- DATE="$(cat tmp/date.tmp)"
- TIME="$(cat tmp/time.tmp)"
- PKG_NAME="$(cat tmp/pgk_name.tmp)"
- REPO_NAME="$(cat tmp/repo_name.tmp)"
- TARGET_PATH="$(cat tmp/target_path.tmp)"
#- apk add curl
- >
if [[ ${PRE_RELEASE} == "test" ]]; then
REPO_NAME=${REPO_NAME}-snapshot
fi
# Upload to Artifactory
- curl -u $REPO_USR:$REPO_PWD -T tmp/$PKG_NAME.zip "${REPO_BASE_URL}/artifactory/${REPO_NAME}/${TARGET_PATH}/${PKG_NAME}.zip"
# publishing to PlatformIO
- >
if [[ ${PRE_RELEASE} == "" ]]; then
pio package publish --owner smartme-io /tmp/Arancino-${CI_COMMIT_TAG}.tar.gz
fi
#################################
####### CLEANUP #######
#################################
####### Cleanup Job #######
cleanup:
stage: cleanup
#only: ['tags']
#except: ['master', 'branches']
variables:
GIT_STRATEGY: none
script:
- echo "Cleaning up"
- rm -rf tmp/