-
Notifications
You must be signed in to change notification settings - Fork 207
147 lines (127 loc) · 4.54 KB
/
release.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
name: Release
# This workflow builds the wheels "on tag".
# If run from the hyperspy/hyperspy repository, the wheels will be uploaded to pypi ;
# otherwise, the wheels will be available as a github artifact.
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
create_release:
permissions:
contents: write
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create Release
id: create_release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
build_wheels:
name: Wheels on ${{ matrix.os }}/py${{ matrix.python-version }}
needs: create_release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: ${{ matrix.python-version }}
- name: What OS and Python version
run: |
uname -a
python --version
which python
- name: install build and twine
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build wheels
run: |
python -m build
- name: Display content dist folder
run: |
ls dist/
- name: Install and test distribution
env:
MPLBACKEND: agg
run: |
pip install --pre --find-links dist hyperspy[tests]
pytest --pyargs hyperspy
- uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl
- name: Publish wheels to PyPI
if: github.repository_owner == 'hyperspy'
env:
# Github secret set in the hyperspy/hyperspy repository
# Not available from fork or pull request
# Secrets are not passed to workflows that are triggered by a pull request from a fork
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*.whl --verbose
build_wheels_linux:
name: Wheels on ubuntu-latest
needs: create_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build source distribution
run: |
pip install build
python -m build --sdist
- name: Build manylinux Python wheels
uses: RalfG/python-wheels-manylinux-build@ff8504699f7a33a08d3ff85b3c6d4e8f0e70462b
with:
python-versions: 'cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311'
build-requirements: 'cython'
- name: Display content dist folder
run: |
ls dist/
- name: Install and test distribution
env:
MPLBACKEND: agg
run: |
pip install --pre --find-links dist hyperspy[tests]
pytest --pyargs hyperspy
- uses: actions/upload-artifact@v3
if: always()
with:
path: |
./dist/*-manylinux*.whl
./sdist/*.tar.gz
- name: Publish wheels to PyPI
if: github.repository_owner == 'hyperspy'
env:
# Github secret set in the hyperspy/hyperspy repository
# Not available from fork or pull request
# Secrets are not passed to workflows that are triggered by a pull request from a fork
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*-manylinux*.whl --verbose
twine upload dist/*.tar.gz --verbose
# Don't use the pypa publish action for now as we need to filter the `linux` wheels
# With hyperspy 2.0, it will be noarch and the release workflow will refactor
# - name: Publish wheels to PyPI
# if: github.repository_owner == 'hyperspy'
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# # Github secret set in the hyperspy/hyperspy repository
# # Not available from fork or pull request
# # Secrets are not passed to workflows that are triggered by a pull request from a fork
# password: ${{ secrets.PYPI_API_TOKEN }}