-
Notifications
You must be signed in to change notification settings - Fork 16
291 lines (291 loc) · 11.1 KB
/
development.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
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
name: Development
on:
pull_request:
push:
jobs:
test-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get changelog entry
id: changelog_reader
uses: guzman-raphael/changelog-reader-action@v5
with:
path: ./CHANGELOG.md
- name: Verify changelog parsing
env:
TAG_NAME: ${{steps.changelog_reader.outputs.version}}
RELEASE_NAME: Release ${{steps.changelog_reader.outputs.version}}
BODY: ${{steps.changelog_reader.outputs.changes}}
PRERELEASE: ${{steps.changelog_reader.outputs.status == 'prereleased'}}
DRAFT: ${{steps.changelog_reader.outputs.status == 'unreleased'}}
run: |
echo "TAG_NAME=${TAG_NAME}"
echo "RELEASE_NAME=${RELEASE_NAME}"
echo "BODY=${BODY}"
echo "PRERELEASE=${PRERELEASE}"
echo "DRAFT=${DRAFT}"
build:
needs: test-changelog
runs-on: ubuntu-latest
strategy:
matrix:
include:
- py_ver: 3.8
distro: alpine
image: djbase
- py_ver: 3.9
distro: alpine
image: djbase
env:
PY_VER: ${{matrix.py_ver}}
DISTRO: ${{matrix.distro}}
IMAGE: ${{matrix.image}}
DOCKER_CLIENT_TIMEOUT: "120"
COMPOSE_HTTP_TIMEOUT: "120"
steps:
- uses: actions/checkout@v2
- name: Compile image
run: |
export PHARUS_VERSION=$(cat pharus/version.py | grep -oP '\d+\.\d+\.\d+')
export HOST_UID=$(id -u)
docker compose -f docker-compose-build.yaml up --exit-code-from pharus --build
IMAGE=$(docker images --filter "reference=datajoint/pharus*" \
--format "{{.Repository}}")
TAG=$(docker images --filter "reference=datajoint/pharus*" --format "{{.Tag}}")
docker save "${IMAGE}:${TAG}" | \
gzip > "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
- name: Add image artifact
uses: actions/upload-artifact@v4
with:
name: image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
path: "image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-\
${{matrix.distro}}.tar.gz"
retention-days: 1
- name: Add pip artifacts
uses: actions/upload-artifact@v4
with:
name: pip-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}
path: dist
retention-days: 1
test:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
include:
- py_ver: 3.8
distro: alpine
image: djbase
- py_ver: 3.9
distro: alpine
image: djbase
env:
PY_VER: ${{matrix.py_ver}}
DISTRO: ${{matrix.distro}}
IMAGE: ${{matrix.image}}
DOCKER_CLIENT_TIMEOUT: "120"
COMPOSE_HTTP_TIMEOUT: "120"
AS_SCRIPT: "TRUE"
steps:
- uses: actions/checkout@v2
- name: Determine package version
run: |
PHARUS_VERSION=$(cat pharus/version.py | grep -oP '\d+\.\d+\.\d+')
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
- name: Fetch image artifact
uses: actions/download-artifact@v4
with:
name: image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
- name: Run primary tests
run: |
export HOST_UID=$(id -u)
docker load < "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
docker compose -f docker-compose-test.yaml up --exit-code-from pharus
publish-release:
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
(
github.repository_owner == 'datajoint' ||
github.repository_owner == 'datajoint-company' ||
github.repository_owner == 'dj-sciops'
)
needs: test
runs-on: ubuntu-latest
env:
TWINE_USERNAME: ${{secrets.twine_username}}
TWINE_PASSWORD: ${{secrets.twine_password}}
outputs:
release_upload_url: ${{steps.create_gh_release.outputs.upload_url}}
steps:
- uses: actions/checkout@v2
- name: Determine package version
run: |
PHARUS_VERSION=$(cat pharus/version.py | grep -oP '\d+\.\d+\.\d+')
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
- name: Get changelog entry
id: changelog_reader
uses: guzman-raphael/changelog-reader-action@v5
with:
path: ./CHANGELOG.md
version: ${{env.PHARUS_VERSION}}
- name: Create GH release
id: create_gh_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{steps.changelog_reader.outputs.version}}
release_name: Release ${{steps.changelog_reader.outputs.version}}
body: ${{steps.changelog_reader.outputs.changes}}
prerelease: ${{steps.changelog_reader.outputs.status == 'prereleased'}}
draft: ${{steps.changelog_reader.outputs.status == 'unreleased'}}
- name: Fetch image artifact
uses: actions/download-artifact@v4
with:
name: image-pharus-${{env.PHARUS_VERSION}}-py3.8-alpine
- name: Fetch 3.8 pip artifacts
uses: actions/download-artifact@v4
with:
name: pip-pharus-${{env.PHARUS_VERSION}}-py3.8
path: dist
- name: Fetch 3.9 pip artifacts
uses: actions/download-artifact@v4
with:
name: pip-pharus-${{env.PHARUS_VERSION}}-py3.8
path: dist
- name: Publish pip release
run: |
export HOST_UID=$(id -u)
docker load < "image-pharus-${PHARUS_VERSION}-py3.8-alpine.tar.gz"
docker compose -f docker-compose-build.yaml run \
-e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} pharus \
sh -lc "pip install twine && python -m twine upload dist/*"
- name: Determine pip artifact paths
run: |
echo "PHARUS_WHEEL_PATH=$(ls dist/pharus-*.whl)" >> $GITHUB_ENV
echo "PHARUS_SDIST_PATH=$(ls dist/pharus-*.tar.gz)" >> $GITHUB_ENV
- name: Upload 3.8 pip wheel asset to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
asset_path: ${{env.PHARUS_WHEEL_PATH}}
asset_name: pip-pharus-${{env.PHARUS_VERSION}}-py3.8.whl
asset_content_type: application/zip
- name: Upload 3.9 pip wheel asset to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
asset_path: ${{env.PHARUS_WHEEL_PATH}}
asset_name: pip-pharus-${{env.PHARUS_VERSION}}-py3.9.whl
asset_content_type: application/zip
- name: Upload 3.8 pip sdist asset to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
asset_path: ${{env.PHARUS_SDIST_PATH}}
asset_name: pip-pharus-${{env.PHARUS_VERSION}}-py3.8.tar.gz
asset_content_type: application/gzip
- name: Upload 3.9 pip sdist asset to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
asset_path: ${{env.PHARUS_SDIST_PATH}}
asset_name: pip-pharus-${{env.PHARUS_VERSION}}-py3.9.tar.gz
asset_content_type: application/gzip
- name: Upload deploy docker environment
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
asset_path: docker-compose-deploy.yaml
asset_name: docker-compose-deploy.yaml
asset_content_type: application/yaml
publish-images:
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
(
github.repository_owner == 'datajoint' ||
github.repository_owner == 'datajoint-company' ||
github.repository_owner == 'dj-sciops'
)
needs: publish-release
runs-on: ubuntu-latest
strategy:
matrix:
include:
- py_ver: 3.8
distro: alpine
image: djbase
- py_ver: 3.9
distro: alpine
image: djbase
env:
PY_VER: ${{matrix.py_ver}}
DISTRO: ${{matrix.distro}}
IMAGE: ${{matrix.image}}
steps:
- uses: actions/checkout@v2
- name: Determine package version
run: |
PHARUS_VERSION=$(cat pharus/version.py | grep -oP '\d+\.\d+\.\d+')
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
- name: Fetch image artifact
uses: actions/download-artifact@v4
with:
name: image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{secrets.docker_username}}
password: ${{secrets.docker_password}}
- name: Publish image
run: |
docker load < "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
IMAGE=$(docker images --filter "reference=datajoint/*" --format "{{.Repository}}")
TAG=$(docker images --filter "reference=datajoint/*" --format "{{.Tag}}")
docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-py${PY_VER}"
docker push "${IMAGE}:${TAG}-py${PY_VER}"
docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-py${PY_VER}-${GITHUB_SHA:0:7}"
docker push "${IMAGE}:${TAG}-py${PY_VER}-${GITHUB_SHA:0:7}"
[ "$PY_VER" == "3.9" ] && [ "$DISTRO" == "alpine" ] \
&& docker push "${IMAGE}:${TAG}" \
&& docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
&& docker push "${IMAGE}:latest" \
|| echo "skipping 'latest' tag..."
- name: Upload image to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{needs.publish-release.outputs.release_upload_url}}
asset_path: "image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-\
${{matrix.distro}}.tar.gz"
asset_name: "image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-\
${{matrix.distro}}.tar.gz"
asset_content_type: application/gzip
publish-docs:
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
(
github.repository_owner == 'datajoint' ||
github.repository_owner == 'datajoint-company' ||
github.repository_owner == 'dj-sciops'
)
needs: publish-release
uses: datajoint/.github/.github/workflows/mkdocs_release.yaml@main
permissions:
contents: write