-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
66 lines (59 loc) · 1.58 KB
/
cloudbuild.yaml
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
---
timeout: 1800s
options:
substitution_option: 'ALLOW_LOOSE'
env:
- 'VENV=/workspace/venv'
steps:
# Create virtualenv
- name: gcr.io/cloud-builders/gcloud
entrypoint: bash
args:
- -c
- |
apt-get -y update
apt-get -y install python3-pip
pip install virtualenv==16.7.9
virtualenv -p python3 "$$VENV"
source "$$VENV"/bin/activate
pip install twine
# Run unittests
- name: gcr.io/cloud-builders/gcloud
entrypoint: bash
args:
- -c
- |
source "$$VENV"/bin/activate
export TAG_NAME="$TAG_NAME"
python setup.py test
# Build package
- name: gcr.io/cloud-builders/gcloud
entrypoint: bash
args:
- -c
- |
source "$$VENV"/bin/activate
export TAG_NAME="$TAG_NAME"
python setup.py sdist bdist_wheel
# Test build output
- name: gcr.io/cloud-builders/gcloud
entrypoint: bash
args:
- -c
- |
source "$$VENV"/bin/activate
twine check dist/*
# Publish package when tagged
- name: gcr.io/cloud-builders/gcloud
entrypoint: bash
args:
- -c
- |
if [[ -n "$TAG_NAME" ]]
then
USERNAME=$(gcloud secrets versions access latest --secret="$PROJECT_ID"-username)
PASSWORD=$(gcloud secrets versions access latest --secret="$PROJECT_ID"-password)
REPO=$(gcloud secrets versions access latest --secret="$PROJECT_ID"-repo)
source "$$VENV"/bin/activate
twine upload -r "$$REPO" dist/* -u "$$USERNAME" -p "$$PASSWORD"
fi