-
Notifications
You must be signed in to change notification settings - Fork 44
282 lines (238 loc) · 10.3 KB
/
deploy.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
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
name: Deploy
on:
push:
paths-ignore:
- "README.md"
- "**/docs/**"
- ".github/workflows/docs.yml"
pull_request:
branches:
- master
schedule:
- cron: "0 11 * * *"
jobs:
publish-pypi:
name: Publish to PyPi
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Build package
run: |
pip install wheel setuptools -U
python setup.py sdist
- name: Publish
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
skip-existing: true
test-publish-pypi:
name: Build & verify PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install twine
run: |
python -m pip install twine
- name: Build package
run: |
pip install wheel setuptools -U
python setup.py sdist
- name: List result
run: |
ls -lh dist
- name: Check long_description
run: |
python -m twine check dist/*
build-conda:
name: Build in Conda
if: startsWith(github.event.ref, 'refs/tags') == false
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.9]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}
# - name: Cache conda
# uses: actions/cache@v2
# env:
# # Increase this value to reset cache if etc/example-environment.yml has not changed
# CACHE_NUMBER: 0
# with:
# path: ~/conda_pkgs_dir
# key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('ci/environment.yml') }}
- name: Add conda ${{ matrix.python-version }} to system path
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: "test_env"
auto-activate-base: false
architecture: "x64"
miniforge-variant: Mambaforge
#miniforge-version: latest
python-version: ${{ matrix.python-version }}
auto-update-conda: true
environment-file: ci/environment.yml
use-only-tar-bz2: true
channel-priority: true
channels: conda-forge, xspecmodels, threeml
- name: Init Env
shell: bash -l {0}
run: |
# Make sure we fail in case of error
if [[ ${{matrix.os}} == ubuntu-latest ]];
then
miniconda_os=Linux
compilers="gcc_linux-64 gxx_linux-64 gfortran_linux-64"
else # osx
miniconda_os=MacOSX
compilers="clang_osx-64 clangxx_osx-64 gfortran_osx-64"
# On macOS we also need the conda libx11 libraries used to build xspec
# We also need to pin down ncurses, for now only on macos.
xorg="xorg-libx11"
fi
# Get the version in the __version__ environment variable
#python ci/set_minor_version.py --patch $TRAVIS_BUILD_NUMBER --version_file threeML/version.py
#export PKG_VERSION=$(cd threeML && python -c "import version;print(version.__version__)")
export PKG_VERSION=$(python -c "import versioneer;print(versioneer.get_version())")
echo "PKG_VERSION=$PKG_VERSION" >> $GITHUB_ENV
echo "HOME= ${HOME}"
echo "Building ${PKG_VERSION} ..."
#echo "Python version: ${{matrix.python-version}}"
conda install codecov pytest-cov
- name: Conda list
shell: bash -l {0}
run: |
conda list
- name: Build the Distribution
shell: bash -l {0}
run: |
# Build package
#conda install conda-build -n base
mamba install -c conda-forge boa
#conda build --python=${{matrix.python-version}} conda-dist/recipe
conda mambabuild --python=${{matrix.python-version}} conda-dist/recipe
conda install --use-local -c conda-forge astromodels
- name: Test conda build
shell: bash -l {0}
run: |
cd astromodels/tests
echo "======> importing XSPEC..."
python -c "import astromodels.xspec"
python -m pytest -vv --cov=astromodels --cov-report=xml
env:
OMP_NUM_THREADS: 1
MKL_NUM_THREADS: 1
NUMEXPR_NUM_THREADS: 1
MPLBACKEND: "Agg"
publish-conda:
name: Publish to Conda
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.9]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache conda
uses: actions/cache@v2
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('ci/environment.yml') }}
- name: Add conda ${{ matrix.python-version }} to system path
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: "test_env"
auto-activate-base: false
architecture: "x64"
#mamba-version: "*"
#conda-build-version: 3.21.6
python-version: ${{ matrix.python-version }}
auto-update-conda: true
environment-file: ci/environment.yml
use-only-tar-bz2: true
channel-priority: flexible
channels: conda-forge, xspecmodels, threeml
- name: Init Env
shell: bash -l {0}
run: |
# Make sure we fail in case of error
if [[ ${{matrix.os}} == ubuntu-latest ]];
then
miniconda_os=Linux
compilers="gcc_linux-64 gxx_linux-64 gfortran_linux-64"
else # osx
miniconda_os=MacOSX
compilers="clang_osx-64 clangxx_osx-64 gfortran_osx-64"
# On macOS we also need the conda libx11 libraries used to build xspec
# We also need to pin down ncurses, for now only on macos.
xorg="xorg-libx11"
fi
# Get the version in the __version__ environment variable
#python ci/set_minor_version.py --patch $TRAVIS_BUILD_NUMBER --version_file threeML/version.py
#export PKG_VERSION=$(cd threeML && python -c "import version;print(version.__version__)")
export PKG_VERSION=$(python -c "import versioneer;print(versioneer.get_version())")
echo "PKG_VERSION=$PKG_VERSION" >> $GITHUB_ENV
echo "HOME= ${HOME}"
echo "Building ${PKG_VERSION} ..."
echo "Python version: ${{matrix.python-version}}"
- name: Build the Distribution
shell: bash -l {0}
run: |
# Install conda build:
conda install conda-build -n base
#conda update conda-build
# Install mambabuild (boa):
# conda install -c conda-forge boa -n base
# Build package
conda build --python=${{matrix.python-version}} conda-dist/recipe
# Install the package
conda install astromodels --use-local
echo "=================== conda list ================================="
conda list
echo "===================================================="
- name: Publish to Conda
shell: bash -l {0}
run: |
conda install -c conda-forge anaconda-client
echo "Uploading ${{matrix.os}} IsDev: ${ISDEV} "
if [[ "${ISDEV}" == "true" ]]; then
LABEL="--label dev"
fi
if [[ ${{matrix.os}} == ubuntu-latest ]];
then
anaconda -v --show-traceback -t $UPLOAD_TOKEN upload -u threeml /usr/share/miniconda/conda-bld/linux-64/*.tar.bz2 --force $LABEL
else
anaconda -v --show-traceback -t $UPLOAD_TOKEN upload -u threeml /usr/local/miniconda/conda-bld/osx-64/*.tar.bz2 --force $LABEL
fi
env:
UPLOAD_TOKEN: ${{secrets.CONDA_UPLOAD_TOKEN}}
CURRENT_OS: ${{matrix.os}}
ISDEV: ${{contains(github.ref, 'dev')}}