Skip to content

Commit 5b6f9f8

Browse files
committed
Add test and pypi upload via Github Actions
Since the Azure publish pipeline fell over, let's migrate to just using github actions natively.
1 parent 3309e3b commit 5b6f9f8

File tree

2 files changed

+65
-39
lines changed

2 files changed

+65
-39
lines changed

.azure-pipelines/azure-pipelines.yml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -90,42 +90,3 @@ stages:
9090
PYTHON_VERSION: 3.11
9191
steps:
9292
- template: ci.yml
93-
94-
- stage: deploy
95-
displayName: Publish release
96-
dependsOn:
97-
- tests
98-
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
99-
jobs:
100-
- job: pypi
101-
displayName: Publish pypi release
102-
pool:
103-
vmImage: ubuntu-20.04
104-
steps:
105-
- checkout: none
106-
107-
- task: UsePythonVersion@0
108-
displayName: Set up python
109-
inputs:
110-
versionSpec: 3.11
111-
112-
- task: DownloadBuildArtifacts@0
113-
displayName: Get pre-built package
114-
inputs:
115-
buildType: 'current'
116-
downloadType: 'single'
117-
artifactName: 'package'
118-
downloadPath: '$(System.ArtifactsDirectory)'
119-
120-
- script: |
121-
pip install --disable-pip-version-check twine
122-
displayName: Install twine
123-
124-
- task: TwineAuthenticate@1
125-
displayName: Set up credentials
126-
inputs:
127-
pythonUploadServiceConnection: pypi-workflows
128-
129-
- bash: |
130-
python -m twine upload -r pypi-workflows --config-file $(PYPIRC_PATH) $(System.ArtifactsDirectory)/package/pypi/*.tar.gz $(System.ArtifactsDirectory)/package/pypi/*.whl
131-
displayName: Publish package

.github/workflows/python.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and Test
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: Set up Python
11+
uses: actions/setup-python@v5
12+
with:
13+
python-version: "3.x"
14+
- name: Install dependencies
15+
run: |
16+
python -m pip install --upgrade pip
17+
pip install build
18+
- name: Build distribution
19+
run: python -m build
20+
- uses: actions/upload-artifact@v4
21+
with:
22+
path: ./dist/*
23+
24+
test:
25+
needs: build
26+
runs-on: ubuntu-latest
27+
strategy:
28+
matrix:
29+
python-version: ["3.9", "3.10", "3.11", "3.12"]
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: actions/download-artifact@v4
34+
with:
35+
name: artifact
36+
path: dist
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install -r requirements_dev.txt dist/*.whl
45+
- name: Test with pytest
46+
run: |
47+
pytest tests
48+
49+
pypi-publish:
50+
name: Upload release to PyPI
51+
needs: test
52+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
53+
runs-on: ubuntu-latest
54+
environment:
55+
name: release
56+
url: https://pypi.org/workflows
57+
permissions:
58+
id-token: write
59+
steps:
60+
- uses: actions/download-artifact@v4
61+
with:
62+
name: artifact
63+
path: dist
64+
- name: Publish package distributions to PyPI
65+
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450

0 commit comments

Comments
 (0)