-
Notifications
You must be signed in to change notification settings - Fork 8
178 lines (165 loc) · 6.53 KB
/
ci.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
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
---
name: CI
on: [push]
jobs:
deploy:
name: Deploy to GitHub and PyPI
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.repository_owner == 'pollination'
steps:
- uses: actions/checkout@v2
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: set up node # we need node for for semantic release
uses: actions/setup-node@v2.1.2
with:
node-version: 14.2.0
- name: install python dependencies
run: |
pip install -r dev-requirements.txt
pip install .
- name: install semantic-release
run: npm install @semantic-release/exec
- name: run semantic release
id: new_release
run: |
nextRelease="`npx semantic-release@^17.0.0 --dryRun | grep -oP 'Published release \K.*? ' || true`"
npx semantic-release@^17.0.0
echo "::set-output name=tag::$nextRelease"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYPI_USERNAME: ${{ secrets.POLLINATION_PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.POLLINATION_PYPI_PASSWORD }}
outputs:
tag: ${{ steps.new_release.outputs.tag }}
deploy-to-staging:
name: Deploy to Pollination Staging
runs-on: ubuntu-latest
needs: deploy
if: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'pollination' && contains(needs.deploy.outputs.tag, '.') }}
steps:
- uses: actions/checkout@v2
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: install python dependencies
run: pip install .
- name: deploy to staging
run: |
queenbee
pollination dsl push pollination-annual-daylight --tag ${{needs.deploy.outputs.tag}} -e https://api.staging.pollination.cloud -src https://api.staging.pollination.cloud/registries --push-dependencies
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
QB_POLLINATION_TOKEN: ${{ secrets.POLLINATION_STAGING_LADYBUGBOT_TOKEN }}
deploy-viz-and-full:
name: Deploy `viz` and `full` branches
runs-on: ubuntu-latest
needs: [deploy, deploy-to-staging]
if: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'pollination' && contains(needs.deploy.outputs.tag, '.') }}
strategy:
fail-fast: true
matrix:
branch: [full, viz]
max-parallel: 1
steps:
- uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: rebase ${{ matrix.branch }} branch
run: |
git config --global user.email "ci@pollination.cloud"
git config --global user.name "GitHub Actions"
git rebase origin/master
- name: install python additional dependencies
run: |
pip install -r dev-requirements.txt
pip install .[viz]
- name: deploy ${{ matrix.branch }} branch to staging
env:
TAG: ${{ needs.deploy.outputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
QB_POLLINATION_TOKEN: ${{ secrets.POLLINATION_STAGING_LADYBUGBOT_TOKEN }}
run: |
TAG=$(echo "${TAG:?}" | sed 's/[[:space:]]//g')
echo $TAG-${{ matrix.branch }}
queenbee
pollination dsl push pollination-annual-daylight --tag $TAG-${{ matrix.branch }} -e https://api.staging.pollination.cloud -src https://api.staging.pollination.cloud/registries --push-dependencies
- name: deploy ${{ matrix.branch }} branch to PyPI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYPI_USERNAME: ${{ secrets.POLLINATION_PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.POLLINATION_PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel --branch ${{ matrix.branch }}
echo "Pushing new version to PyPi"
twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD
deploy-to-production:
name: Deploy to Pollination Production
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/production' && github.repository_owner == 'pollination'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Get Job Context
id: get-context
run: |
TAG=$(git describe --tags | sed 's/v//')
echo "Releasing tag: ${TAG:?}"
echo "::set-output name=tag::$TAG"
- name: install python dependencies
run: |
pip install pollination-annual-daylight
pip install -r requirements.txt
- name: deploy to production
run: |
TAG=$(echo "${TAG:?}" | sed 's/[[:space:]]//g')
echo $TAG
queenbee
pollination dsl push pollination-annual-daylight --tag $TAG -e https://api.pollination.cloud -src https://api.pollination.cloud/registries --push-dependencies
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
QB_POLLINATION_TOKEN: ${{ secrets.POLLINATION_LADYBUGBOT_TOKEN }}
TAG: ${{ steps.get-context.outputs.tag }}
outputs:
tag: ${{ steps.get-context.outputs.tag }}
deploy-viz-and-full-to-production:
name: Deploy `viz` and `full` branches
runs-on: ubuntu-latest
needs: [deploy-to-production]
if: github.ref == 'refs/heads/production' && github.repository_owner == 'pollination'
strategy:
fail-fast: true
matrix:
branch: [full, viz]
max-parallel: 1
steps:
- uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: rebase ${{ matrix.branch }} branch
run: |
git config --global user.email "ci@pollination.cloud"
git config --global user.name "GitHub Actions"
git rebase origin/production
- name: install python viz dependencies
run: pip install .[viz]
- name: deploy ${{ matrix.branch }} to production
env:
TAG: ${{ needs.deploy-to-production.outputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
QB_POLLINATION_TOKEN: ${{ secrets.POLLINATION_LADYBUGBOT_TOKEN }}
run: |
TAG=$(echo "${TAG:?}" | sed 's/[[:space:]]//g')
echo $TAG-${{ matrix.branch }}
queenbee
pollination dsl push pollination-annual-daylight --tag $TAG-${{ matrix.branch }} -e https://api.pollination.cloud -src https://api.pollination.cloud/registries --push-dependencies