This repository was archived by the owner on Jun 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
231 lines (188 loc) · 5.54 KB
/
ci.yaml
File metadata and controls
231 lines (188 loc) · 5.54 KB
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
name: Metacity CI
on:
push:
branches: [ release, dev ]
pull_request:
branches: [ dev ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
- name: Build Geometry package
run: |
pip install .
- name: Test with pytest
run: |
pytest ./tests/* --cov=metacity
- name: Upload to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
run: |
pip install coveralls
coveralls
build-image:
name: Build Docker Image test
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build Docker image
uses: docker/build-push-action@v3
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
make-wheels:
name: Make ${{ matrix.os }} wheels
if: github.event_name == 'push' && contains(github.ref, 'release')
needs: build-image
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
steps:
- name: "Checkout repo"
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: "Build wheels"
uses: pypa/cibuildwheel@v2.9.0
- name: Verify clean directory
run: git diff --exit-code
shell: bash
- name: "Upload wheel as artifact"
uses: actions/upload-artifact@v3
with:
name: artifact-${{ matrix.os }}-wheel
path: ./wheelhouse/*.whl
make-sdist:
name: Make source distribution
if: github.event_name == 'push' && contains(github.ref, 'release')
needs: build-image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Build SDist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v3
with:
name: artifact-source-dist
path: dist/*.tar.gz
tag-and-release:
name: Tag commit and create a release
needs: [make-wheels, make-sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install scikit-build
- name: "Get release version"
run: |
CURRENT_VERSION=$(python3 setup.py --version | tail -1)
echo "Current version: $CURRENT_VERSION"
echo "CURRENT_VERSION=v$CURRENT_VERSION" >> $GITHUB_ENV
- uses: rickstaa/action-create-tag@v1
with:
tag: ${{ env.CURRENT_VERSION }}
- uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true
tag: ${{ env.CURRENT_VERSION }}
upload:
name: Upload to PyPI
needs: tag-and-release
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: dist
- name: Copy artifacts to dist/ folder
run: |
echo "* Downloaded artifacts:"
ls dist/
cd dist/
echo "* Copying artifacts to dist/ folder:"
find . -mindepth 2 -maxdepth 2 -type f -print -exec mv {} . \;
echo "* Deleting empty directories:"
find . -maxdepth 1 -type d -empty -print -exec rmdir {} +
cd ..
echo "* Prepared artifacts:"
ls dist/
- name: Publish package
uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
build-and-push-image:
name: Upload to Container Registry
runs-on: ubuntu-latest
needs: tag-and-release
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}