-
-
Notifications
You must be signed in to change notification settings - Fork 83
164 lines (162 loc) · 6.14 KB
/
publish-to-test-and-live-pypi.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
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
on:
pull_request:
push:
branches: [ main ]
tags: [ 'v*' ]
release:
types: [ published ]
jobs:
build_sdist:
name: Make SpiceyPy 🌶️ 🥧 Python 🐍 source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout 🌶️ 🥧
uses: actions/checkout@v4
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Display Python 🐍
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r test-requirements.txt
python -m pip install build coverage>=5.1.0 twine>=3.3.0
- name: Build 🛠️ sdist source and Install SpiceyPy 🌶️ 🥧
run: |
python -m build --sdist
echo "Running Pip install from sdist"
python -m pip install dist/*.tar.gz --user
- name: Test 🧪 with coverage 📈
run: |
coverage run --source spiceypy -m pytest --pyargs spiceypy
- name: Upload 🆙 coverage 📈 report to codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
verbose: true
- name: Check dists
run: |
twine check dist/*
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
build_wheels:
strategy:
matrix:
include:
- config: {"name": "Linux", "os": "ubuntu-latest", "arch": "x86_64"}
- config: {"name": "Linux", "os": "ubuntu-latest", "arch": "aarch64"}
- config: {"name": "macOS", "os": "macos-14", "arch": "x86_64"}
- config: {"name": "macOS", "os": "macos-14", "arch": "arm64"}
- config: {"name": "Windows", "os": "windows-latest", "arch": "AMD64"}
name: Build SpiceyPy 🌶️ 🥧 Python 🐍 wheels for ${{ matrix.config.os }} ${{ matrix.config.arch }}
env:
CSPICE_CACHE: 1
CIBW_ARCHS: ${{ matrix.config.arch }}
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout 🌶️ 🥧
uses: actions/checkout@v4
- name: Setup 🔬🍦🏗️
if: runner.os == 'Windows'
uses: ilammy/[email protected]
- name: set additional environment variables for macOS arm
if: runner.name == 'macOS' && matrix.config.arch == 'arm64'
run: |
echo "CIBW_ARCHS_MACOS=arm64" >> $GITHUB_ENV
echo "ARCHFLAGS='-arch arm64'" >> $GITHUB_ENV
- name: set additional environment variables for macOS x86
if: runner.name == 'macOS' && matrix.config.arch == 'x86_64'
run: |
echo "CIBW_ARCHS_MACOS=x86_64" >> $GITHUB_ENV
echo "ARCHFLAGS='-arch x86_64'" >> $GITHUB_ENV
- name: Set up QEMU for arm64 builds
if: matrix.config.arch == 'aarch64'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Cache libcspice.so for aarch64 builds because they take an hour to build with qemu
if: matrix.config.arch == 'aarch64'
uses: actions/cache@v4
with:
path: ./src/spiceypy/utils/libcspice.so
key: ${{ env.CSPICE_CACHE }}-${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ hashFiles('get_spice.py') }}-${{ hashFiles('setup.cfg') }}
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Display Python 🐍 Version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r ci-requirements.txt
python -m pip install cibuildwheel==2.19.1
- name: See if libcspice.so is available from cache
if: matrix.config.arch == 'aarch64'
run: |
pwd
ls src/spiceypy/utils -lahtr
- name: Build wheels for SpiceyPy 🌶️ 🥧
timeout-minutes: 120
run: |
env | grep CIBW
env | grep ARCH
python -m cibuildwheel --output-dir wheelhouse
- name: Extract libcspice.so for aarch64 builds
if: matrix.config.arch == 'aarch64'
run: |
pwd
ls -lahtr
ls src/ -lahtr
ls src/spiceypy/ -lahtr
ls src/spiceypy/utils -lahtr
ls wheelhouse/*
unzip -o wheelhouse/spiceypy-\*.whl 'spiceypy/utils/libcspice.so' -d src/
- name: Check dists
run: |
twine check wheelhouse/*
- name: Upload wheels for SpiceyPy 🌶️ 🥧
uses: actions/upload-artifact@v4
with:
name: artifact-${{ env.CSPICE_CACHE }}-${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ hashFiles('get_spice.py') }}-${{ hashFiles('setup.cfg') }}
path: ./wheelhouse/*.whl
publish_to_pypi:
name: Publish SpiceyPy 🌶️ 🥧 Python 🐍 distributions 📦 to PyPI and TestPyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
merge-multiple: true
path: dist
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Display Python 🐍
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install twine
- name: Check dists
run: |
twine check dist/*
- name: Publish distribution 📦 to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
run: |
twine upload --non-interactive --skip-existing --repository testpypi dist/*
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload --non-interactive --skip-existing dist/*