This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
297 lines (266 loc) · 8.59 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
default:
image: cirrusci/flutter:stable
cache:
key:
files:
- pubspec.lock
paths:
- .pub-cache/
variables:
DMG_BINARY: "txdx-${CI_COMMIT_TAG}.dmg"
SNAP_AMD64_BINARY: "txdx_${CI_COMMIT_TAG}_amd64.snap"
LINUX_X64_ARCHIVE: "txdx-${CI_COMMIT_TAG}-linux-x64.tar.gz"
WIN_PORTABLE_X64_ARCHIVE: "txdx_${CI_COMMIT_TAG}_portable_x64.zip"
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/txdx/${CI_COMMIT_TAG}"
stages:
- check
- build
- upload
- release
- package
analyze:
stage: check
script:
- flutter pub get
- flutter analyze
test:
stage: check
script:
- flutter pub global activate junitreport
- export PATH="$PATH":"$HOME/.pub-cache/bin"
- flutter pub get
- flutter test --coverage --machine | tojunit > testreport.xml
artifacts:
reports:
junit: testreport.xml
paths:
- coverage
test_beta:
stage: check
image: cirrusci/flutter:beta
allow_failure: true
script:
- flutter pub get
- flutter test
test_coverage:
stage: check
script:
- flutter test --coverage ./lib
- lcov -r coverage/lcov.info '*/__test*__/*' -o coverage/lcov_cleaned.info
- genhtml coverage/lcov_cleaned.info --output=coverage
artifacts:
paths:
- coverage
build_windows:
stage: build
rules:
- if: $CI_COMMIT_TAG
tags:
- win10
before_script:
- flutter channel stable
- flutter upgrade
- flutter clean
script:
- flutter pub get
- flutter build windows --release
artifacts:
paths:
- build/windows/runner/Release/
package_windows_zip:
stage: build
needs: ['build_windows']
image: alpine:latest
rules:
- if: $CI_COMMIT_TAG
script:
- apk add --no-cache zip
- cd build/windows/runner/Release
- zip -r txdx.zip .
- mv txdx.zip $CI_PROJECT_DIR/$WIN_PORTABLE_X64_ARCHIVE
- cd $CI_PROJECT_DIR
artifacts:
paths:
- "$WIN_PORTABLE_X64_ARCHIVE"
build_macos_dmg:
stage: build
rules:
- if: $CI_COMMIT_TAG
tags:
- macos
before_script:
- cd macos
- gem install bundler
- bundle install
- bundle update
- cd $CI_PROJECT_DIR
- flutter channel stable
- flutter upgrade
- flutter precache
- flutter clean
- echo $APPLE_AUTH_KEY | base64 -d > macos/authkey.p8
script:
- cd macos
- fastlane mac_dmg
- cd $CI_PROJECT_DIR
after_script:
- mv macos/output/$DMG_BINARY $CI_PROJECT_DIR/$DMG_BINARY
artifacts:
paths:
- "$DMG_BINARY"
build_linux_x64:
stage: build
rules:
- if: $CI_COMMIT_TAG
before_script:
[
sudo apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install keyboard-configuration -y && sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev libblkid-dev liblzma-dev libjsoncpp-dev cmake-data libjsoncpp1 libsecret-1-dev libsecret-1-0 librhash0 -y,
]
script:
- flutter config --enable-linux-desktop
- flutter pub get
- flutter build linux --release --verbose
- tar czf $LINUX_X64_ARCHIVE -C build/linux/x64/release/bundle/ .
artifacts:
when: on_success
paths:
- "$LINUX_X64_ARCHIVE"
upload_gitlab:
stage: release
image: curlimages/curl:latest
rules:
- if: $CI_COMMIT_TAG
script:
- sha256sum $DMG_BINARY > SHA256SUMS
- sha256sum $LINUX_X64_ARCHIVE > SHA256SUMS
- sha256sum $WIN_PORTABLE_X64_ARCHIVE >> SHA256SUMS
- |
curl -v --no-progress-meter --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $DMG_BINARY "${PACKAGE_REGISTRY_URL}/${DMG_BINARY}"
- |
curl -v --no-progress-meter --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_X64_ARCHIVE "${PACKAGE_REGISTRY_URL}/${LINUX_X64_ARCHIVE}"
- |
curl -v --no-progress-meter --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_PORTABLE_X64_ARCHIVE "${PACKAGE_REGISTRY_URL}/${WIN_PORTABLE_X64_ARCHIVE}"
- |
curl -v --no-progress-meter --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file SHA256SUMS "${PACKAGE_REGISTRY_URL}/SHA256SUMS"
release-gitlab:
stage: release
needs: ['upload_gitlab']
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
script:
- |
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"${DMG_BINARY}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${DMG_BINARY}\"}" \
--assets-link "{\"name\":\"${LINUX_X64_ARCHIVE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_X64_ARCHIVE}\"}" \
--assets-link "{\"name\":\"${WIN_PORTABLE_X64_ARCHIVE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_PORTALBLE_X64_ARCHIVE}\"}" \
--assets-link "{\"name\":\"SHA256SUMS\",\"url\":\"${PACKAGE_REGISTRY_URL}/SHA256SUMS\"}" \
package_arch_aur:
stage: package
needs: ['release-gitlab']
rules:
- if: $CI_COMMIT_TAG
tags:
- arch
script:
- cd ./pkg/aur
- VERSION=$CI_COMMIT_TAG
- echo "Determined binary version '$VERSION'"
- echo "Determining SHA checksums for remote files..."
- URL_BIN=https://gitlab.devroom.io/api/v4/projects/17/packages/generic/txdx/$VERSION/txdx-$VERSION-linux-x64.tar.gz
- 'echo "Selected bin URL: $URL_BIN"'
- URL_SOURCE=https://gitlab.devroom.io/ariejan/txdx/-/archive/$VERSION/txdx-$VERSION.tar.gz
- 'echo "Selected source URL: $URL_SOURCE"'
- echo "Determining sha256sum for remote binaries..."
- 'SHA_BIN=$(curl -sSL "$URL_BIN" | sha256sum | cut -d" " -f1)'
- 'echo "Got sha256sum: $SHA_BIN"'
- echo "Determining sha256sum for remote source..."
- 'SHA_SOURCE=$(curl -sSL "$URL_SOURCE" | sha256sum | cut -d" " -f1)'
- 'echo "Got sha256sum: $SHA_SOURCE"'
- echo "Updating PKGBUILDS with release information..."
- sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i txdx-bin/PKGBUILD
- sed "s/^source=(\".*\").*\$/source=(\"$(echo $URL_BIN | sed 's/\//\\\//g')\")/" -i txdx-bin/PKGBUILD
- sed "s/^sha256sums=.*\$/sha256sums=('$SHA_BIN')/" -i txdx-bin/PKGBUILD
- sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i txdx/PKGBUILD
- sed "s/^source=(\".*\").*\$/source=(\"$(echo $URL_SOURCE | sed 's/\//\\\//g')\")/" -i txdx/PKGBUILD
- sed "s/^sha256sums=.*\$/sha256sums=('$SHA_SOURCE')/" -i txdx/PKGBUILD
- echo "Installing required build packages..."
- sudo pacman -Syu --noconfirm --needed sudo base-devel fakeroot binutils openssh zenity cmake git openssl clang ninja unzip jdk-openjdk
- echo "Installing flutter..."
- yay -S flutter
- echo "Making bin package..."
- cd txdx-bin
- makepkg -sc
- makepkg --printsrcinfo > .SRCINFO
- cat .SRCINFO
- cd ..
- echo "Making source package..."
- cd txdx
- makepkg -sc
- makepkg --printsrcinfo > .SRCINFO
- cat .SRCINFO
- cd ..
- echo "Set up SSH for AUR publishing"
- echo $AUR_PUBLIC_KEY | base64 -d > ~/.ssh/aur.pub
- echo $AUR_PRIVATE_KEY | base64 -d > ~/.ssh/aur
- echo "Host aur.archlinux.org" > ~/.ssh/config
- echo " IdentityFile ~/.ssh/aur" >> ~/.ssh/config
- echo " User aur" >> ~/.ssh/config
- chmod 600 ~/.ssh/{aur*,config}
- eval `ssh-agent -s`
- ssh-add ~/.ssh/aur
- ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts
- git config --global user.name "Ariejan de Vroom"
- git config --global user.email "[email protected]"
- git clone ssh://[email protected]/txdx-bin.git aur-txdx-bin
- cd aur-txdx-bin
- cp ../txdx-bin/{PKGBUILD,.SRCINFO} ./
- git add PKGBUILD .SRCINFO
- git commit -m "Release $VERSION"
- git push
- cd ..
- git clone ssh://[email protected]/txdx.git aur-txdx
- cd aur-txdx
- cp ../txdx/{PKGBUILD,.SRCINFO} ./
- git add PKGBUILD .SRCINFO
- git commit -m "Release $VERSION"
- git push
- cd ..
package_snap:
stage: package
rules:
- if: $CI_COMMIT_TAG
tags:
- ubuntu
before_script:
- rm -rf *.snap
- snapcraft clean --use-lxd
script:
- snapcraft --use-lxd
- find . -name 'txdx*amd64.snap' -exec bash -c 'mv $0 $SNAP_AMD64_BINARY' {} \;
- echo $SNAPCRAFT_LOGIN_FILE | base64 --decode --ignore-garbage > snapcraft.login
- snapcraft login --with snapcraft.login
- snapcraft push $SNAP_AMD64_BINARY --release stable
package_apple_app_store:
stage: package
when: manual
allow_failure: true
rules:
- if: $CI_COMMIT_TAG
tags:
- macos
before_script:
- cd macos
- gem install bundler
- bundle install
- bundle update
- cd $CI_PROJECT_DIR
- flutter channel stable
- flutter upgrade
- flutter precache
- flutter clean
- echo $APPLE_AUTH_KEY | base64 -d > macos/authkey.p8
script:
- cd macos
- fastlane mac_pkg
- cd $CI_PROJECT_DIR