Repository navigation
94 lines (77 loc) · 2.5 KB
/
Copy pathpython-publish.yml
File metadata and controls
94 lines (77 loc) · 2.5 KB
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
name: Build and publish release
on:
release:
types: [published]
permissions:
contents: read
jobs:
test:
name: Test on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out the release tag
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.13"
- name: Install the project and test dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --index-url https://download.pytorch.org/whl/cpu torch
python -m pip install --editable . pytest tmm
- name: Run the test suite
run: python -m pytest
build:
name: Build distributions
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out the release tag
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.13"
- name: Install the project and release tools
run: |
python -m pip install --upgrade pip
python -m pip install --index-url https://download.pytorch.org/whl/cpu torch
python -m pip install --editable . build twine
- name: Build and validate distributions
run: |
python -m build
python -m twine check dist/*
- name: Verify the built wheel
run: |
python -m pip install --force-reinstall --no-deps dist/*.whl
python -c "import os; from importlib.metadata import version; assert version('tmm-fast') == os.environ['GITHUB_REF_NAME'].removeprefix('v')"
python -c "from tmm_fast import materials; assert materials.available() == ['Au', 'Nb2O5', 'SiO2']"
- name: Store distributions for publishing
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/
publish:
name: Publish distributions to PyPI
needs: build
runs-on: ubuntu-latest
steps:
- name: Download distributions
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
- name: Publish distributions
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}