-
Notifications
You must be signed in to change notification settings - Fork 13
250 lines (193 loc) · 5.82 KB
/
all.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
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
name: Tests, Docs, Deploy
on:
- push
- pull_request
permissions:
contents: read
jobs:
# Test Code for recent Python releases
test-code:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install tox
pip install tox-gh-actions
- name: Test Code
run: tox
# Test Code for older Python3 releases
test-code-older-py3:
runs-on: ubuntu-20.04
container:
image: python:${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
python-version: ['3.4.10', '3.5.10']
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install dependencies
shell: bash
run: |
if [[ ${{ matrix.python-version }} == 3.3* ]]; then
pip install virtualenv==15.2.0
pip install pluggy==0.5.2
pip install tox==2.9.1
fi
pip install tox
- name: Test Code
shell: bash
run: |
version_abbr=$( echo ${{ matrix.python-version }} | sed -r 's/^([0-9])\.([0-9]).*/\1\2/' )
envs=$( tox -listenvs | grep "py$version_abbr-" | tr '\n' ',' )
tox -e $envs
# Test Code for Python27
test-code-older-py27:
runs-on: ubuntu-20.04
container:
image: python:${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
python-version: ['2.7.18']
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install dependencies
run: |
pip install tox
pip install tox-gh-actions==2.8.1
- name: Test Code
run: tox
# Test Docs
test-docs:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install numpy
pip install sphinx
pip install numpydoc
- name: Test Docs
run: sphinx-build -W --keep-going doc _build/html
# Save Artifacts
create-save-artifacts:
runs-on: ubuntu-20.04
needs: [test-code, test-code-older-py3, test-code-older-py27, test-docs]
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install wheel
pip install numpy
pip install sphinx
pip install numpydoc
- name: Create artifacts
run: |
python setup.py sdist --formats=zip
python setup.py bdist_wheel
VERSION=$(python setup.py --version)
sphinx-build -W --keep-going doc _build/html
tar -C _build/html -zcf dist/docs-${VERSION}.tar.gz .
- name: Save artifacts to Github Actions
uses: actions/upload-artifact@v3
with:
name: docs, source zip, wheel
path: dist/*
if-no-files-found: error
- name: Deploy artifacts to GitHub Pages
shell: bash
run: |
SHORT_COMMIT=$(git rev-parse --short HEAD)
shopt -s extglob dotglob
rm -rf !(dist|.git|.|..)
cp dist/* .
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)"
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)"
git checkout -b gh-pages
git update-ref -d HEAD
git add --all
git commit -m "Artifacts for $SHORT_COMMIT"
git config push.default simple
git push origin gh-pages --force
if: github.event_name == 'push' &&
(github.ref == 'refs/heads/master'|| startsWith(github.ref, 'refs/tags') )
# Deploy to GitHub Releases
deploy-github-releases:
runs-on: ubuntu-20.04
needs: [create-save-artifacts]
if: success() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Deploy to GitHub Releases
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASES_TOKEN }}
run: |
VERSION=$(python setup.py --version)
cat > release-notes.md <<EOL
Version $VERSION of PDS4 Python Tools and PDS4 Viewer.
EOL
extra_flags=''
if [[ "$VERSION" == *"dev"* ]]; then
extra_flags='--draft'
fi
gh release create v$VERSION --notes-file release-notes.md $extra_flags
# Deploy to PyPi
deploy-pypi:
runs-on: ubuntu-20.04
needs: [create-save-artifacts]
if: success() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install wheel
- name: Create artifacts
run: |
python setup.py sdist --formats=zip
python setup.py bdist_wheel
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
password: ${{ secrets.PYPI_TOKEN }}
if: contains(github.ref, 'dev') == false