forked from cryptoadvance/specter-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
154 lines (142 loc) · 5.88 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
# this image contains python, bitcoind and docker
# check docker/python-bitcoind on how it's built
image: registry.gitlab.com/cryptoadvance/specter-desktop/python-bitcoind:v0.20.1
variables:
# Cache documentation: https://docs.gitlab.com/ee/ci/caching/
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
# enable per-job and per-branch caching
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
- .cache/pip
- .env/
stages:
- testing
- releasing
before_script:
- docker info || echo "no docker-command found" # Print out docker version for debugging
- echo CI_PROJECT_NAMESPACE = $CI_PROJECT_NAMESPACE
- echo CI_PROJECT_ROOT_NAMESPACE = $CI_PROJECT_ROOT_NAMESPACE
- python -V # Print out python version for debugging
- apt update
- apt install -y libusb-1.0-0-dev libudev-dev # usb-support in hidapi
- pip3 install virtualenv
- virtualenv --python=python3 .env
- source .env/bin/activate
test:
stage: testing
# We assume here that people who want to get code into the master-branch are
# relying on PRs and people who are working on gitlab-forks are working
# on CI which probably want fast feedback on the releasing-jobs
# and therefore skip the test-job
# tem deactivated as it did not work as expected
#only:
# - $CI_PROJECT_ROOT_NAMESPACE =~ "cryptoadvance"
script:
- pip3 install -r requirements.txt
- pip3 install -e .
- pip3 install -r test_requirements.txt
# pytest --docker not working? Uncomment this for better debugging:
# - python3 tests/conftest.py
- py.test --cov-report term --cov cryptoadvance --docker
test-cypress:
image: registry.gitlab.com/k9ert/specter-desktop/cypress-python:20201111231032
stage: testing
script:
# start the server in the background
- pip3 install -e .
- pip3 install -r test_requirements.txt
- npm i
- ./utils/test-cypress.sh --docker --debug run
- docker ps || echo "probably no docker available anyway"
artifacts:
when: always
paths:
- cypress/videos/**/*.mp4
- cypress/screenshots/**/*.png
expire_in: 1 day
release_pip:
stage: releasing
only:
- tags
script:
- pip3 install setuptools wheel twine
# verifying the version number follows vx.y.z (e.g. "v1.2.3")
- if ! [[ $CI_COMMIT_TAG =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then exit 1; fi
# set version number in setup.py
- echo Releasing $CI_COMMIT_TAG
- sed -i "s/version=\".*/version=\"$CI_COMMIT_TAG\",/" setup.py
- cat setup.py
- python3 setup.py sdist bdist_wheel
- ls -l dist
# twine reads the password from the env-var TWINE_PASSWORD
# Either testing it or doing the real thing depending on which gitlab-project we're running:
- if ! [[ ${CI_PROJECT_ROOT_NAMESPACE} = "cryptoadvance" ]]; then python3 -m twine upload --verbose --user __token__ dist/* --repository-url https://test.pypi.org/legacy/ ; fi
- if [[ ${CI_PROJECT_ROOT_NAMESPACE} = "cryptoadvance" ]]; then python3 -m twine upload --verbose --user __token__ dist/* ; fi
- sha256sum dist/cryptoadvance.specter-*.tar.gz > ./dist/SHA256SUMS-pip.txt
- python ./utils/github.py upload ./dist/SHA256SUMS-pip.txt
- python ./utils/github.py upload ./dist/cryptoadvance.specter-*.tar.gz
artifacts:
when: always
paths:
- dist/*
expire_in: 1 day
release_binary_windows:
stage: releasing
only:
- tags
tags:
- windows
before_script:
- python -V
- pip3 install virtualenv
- virtualenv --python=python3 .env
- .\.env\Scripts\activate
script:
# This script won't execute if the script before that fails
# No need to check the version-scheme again
- whoami
- echo "Releasing for ${CI_PROJECT_ROOT_NAMESPACE}"
- cd pyinstaller
- .\build-win-ci.bat $CI_COMMIT_TAG
- python ../utils/github.py upload ./release/specterd-$CI_COMMIT_TAG-win64.zip
artifacts:
when: always
paths:
- pyinstaller/release/*
expire_in: 1 day
release_electron_linux_windows:
image: registry.gitlab.com/cryptoadvance/specter-desktop/electron-builder:latest
stage: releasing
only:
- tags
before_script:
- python -V # Print out python version for debugging
- apt update
- apt install -y unzip libusb-1.0-0-dev libudev-dev # usb-support in hidapi
- pip3 install virtualenv
# Only difference to default befor_script: (ToDo fix this)
- python3 -m virtualenv --python=python3 .env
- source .env/bin/activate
script:
- echo "Releasing for ${CI_PROJECT_ROOT_NAMESPACE}"
- export CI_PROJECT_ROOT_NAMESPACE # needed in the build-script to download the right windows-binary
- cd pyinstaller
- ./build-ci.sh $CI_COMMIT_TAG "make-hash"
- ls -l release-linux
- ls -l release-win
- sha256sum ./release-linux/specterd-${CI_COMMIT_TAG}-x86_64-linux-gnu.zip ./release-linux/specter_desktop-${CI_COMMIT_TAG}-x86_64-linux-gnu.tar.gz ./release-win/Specter-Setup-${CI_COMMIT_TAG}.exe > ./SHA256SUMS.txt
- cat ./SHA256SUMS.txt
- if [[ -f /credentials/private.key ]]; then gpg --import /credentials/private.key; echo $GPG_PASSPHRASE | gpg --detach-sign --batch --yes --passphrase-fd 0 --pinentry-mode loopback ./SHA256SUMS.txt; fi
- python ../utils/github.py upload ./release-win/Specter-Setup-${CI_COMMIT_TAG}.exe
- python ../utils/github.py upload ./release-linux/specterd-${CI_COMMIT_TAG}-x86_64-linux-gnu.zip
- python ../utils/github.py upload ./release-linux/specter_desktop-${CI_COMMIT_TAG}-x86_64-linux-gnu.tar.gz
- python ../utils/github.py upload ./SHA256SUMS.txt
- if [[ -f /credentials/private.key ]]; then python3 ../utils/github.py upload ./SHA256SUMS.txt.sig ; fi
artifacts:
when: always
paths:
- pyinstaller/release-linux/*
- pyinstaller/release-win/*
- pyinstaller/SHA256SUMS.txt
expire_in: 1 day