forked from ochubar/SRW
-
Notifications
You must be signed in to change notification settings - Fork 1
168 lines (141 loc) · 4.92 KB
/
pypi_publish.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
name: PyPI Publish
on:
release:
types: [published]
push:
pull_request:
workflow_dispatch:
jobs:
build-n-publish:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
name: ${{ matrix.host-os }} / Python ${{ matrix.python-version }} / OpenMP ${{ matrix.openmp }}
runs-on: ${{ matrix.host-os }}
strategy:
matrix:
host-os: ["ubuntu-latest", "windows-latest", "macos-13", "macos-14"]
# python-version: ["3.8", "3.9", "3.10", "3.11"]
openmp: ["off"]
fail-fast: false
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- name: Set OpenMP mode
if: matrix.openmp == 'on'
run: |
export MODE="omp"
echo "MODE=${MODE}" >> $GITHUB_ENV
- name: Build wheels
uses: pypa/[email protected]
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
# - name: Set MacOS Deployment Target
# if: runner.os == 'macOS'
# run: |
# export MACOSX_DEPLOYMENT_TARGET="10.15"
# echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" >> $GITHUB_ENV
# - uses: conda-incubator/setup-miniconda@v2
# with:
# activate-environment: testenv
# allow-softlinks: true
# auto-activate-base: false
# auto-update-conda: true
# channel-priority: flexible
# channels: conda-forge
# miniconda-version: "latest"
# python-version: ${{ matrix.python-version }}
# show-channel-urls: true
# use-only-tar-bz2: false
# - name: Set up Visual Studio shell
# if: runner.os == 'Windows'
# uses: egor-tensin/vs-shell@v2
# with:
# arch: x64
# - name: Install build requirements with conda
# if: runner.os != 'Linux'
# run: |
# set -vxeuo pipefail
# conda install -y cmake
# - name: Install OpenMP for macOS with conda
# if: runner.os == 'macOS' && matrix.openmp == 'on'
# run: |
# set -vxeuo pipefail
# conda install -y -c conda-forge llvm-openmp
# # NOTE: This step is not needed for fast tests.
# # - name: Install mpi4py for Unix with conda
# # if: runner.os != 'Windows'
# # run: |
# # set -vxeuo pipefail
# # conda install -y -c conda-forge mpi4py openmpi
# - name: Install cibuildwheel on Linux
# if: runner.os == 'Linux'
# run: |
# set -vxeuo pipefail
# python -m pip install --upgrade pip
# python -m pip install cibuildwheel
# echo "CIBW_BEFORE_ALL=pip install cmake" >> $GITHUB_ENV
# PYTH_VER=${{ matrix.python-version }}
# PYTH_VER=${PYTH_VER//.}
# echo "CIBW_BUILD="cp$PYTH_VER-manylinux*"" >> $GITHUB_ENV
# - name: Build wheel on Linux
# if: runner.os == 'Linux'
# run: |
# set -vxeuo pipefail
# python -VV
# python -m cibuildwheel --output-dir dist env/python
# ls -la dist/*
# - name: Build wheel on Windows/Mac
# if: runner.os != 'Linux'
# run: |
# set -vxeuo pipefail
# cd env/python
# python -VV
# python setup.py bdist_wheel
# ls -la dist/*
# mkdir -p ../../dist
# cp dist/*.whl ../../dist/
# - name: Publish wheels to GitHub artifacts
# uses: actions/upload-artifact@v3
# with:
# name: wheels
# path: dist/*
- name: Install the package and test requirements
run: |
set -vxeuo pipefail
pip install -v wheelhouse/*.whl
# Smoke import test:
python -c "import srwpy; import srwpy.srwlpy"
# Check CLI tools:
srw-viewer --help
python -m pip install -r env/python/requirements-dev.txt
python -m pip list
- name: Run fast tests
run: |
set -vxeuo pipefail
cd env/python
pytest -k fast
publish-to-pypi:
# Hints from:
# - https://github.com/pypa/gh-action-pypi-publish/discussions/28
# - https://github.com/Lightning-AI/lightning/blob/master/.github/workflows/release-pypi.yml
if: github.event_name == 'release'
name: Publish to PyPI
needs: build-n-publish
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Download wheels from GitHub artifacts
uses: actions/download-artifact@v3
with:
name: wheels
path: dist/
- name: Publish wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./dist/