Skip to content

Commit

Permalink
Add test and pypi upload via Github Actions
Browse files Browse the repository at this point in the history
Since the Azure publish pipeline fell over, let's migrate to just using
github actions natively.
  • Loading branch information
ndevenish committed May 1, 2024
1 parent 3309e3b commit 5b6f9f8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 39 deletions.
39 changes: 0 additions & 39 deletions .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,42 +90,3 @@ stages:
PYTHON_VERSION: 3.11
steps:
- template: ci.yml

- stage: deploy
displayName: Publish release
dependsOn:
- tests
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
jobs:
- job: pypi
displayName: Publish pypi release
pool:
vmImage: ubuntu-20.04
steps:
- checkout: none

- task: UsePythonVersion@0
displayName: Set up python
inputs:
versionSpec: 3.11

- task: DownloadBuildArtifacts@0
displayName: Get pre-built package
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'package'
downloadPath: '$(System.ArtifactsDirectory)'

- script: |
pip install --disable-pip-version-check twine
displayName: Install twine
- task: TwineAuthenticate@1
displayName: Set up credentials
inputs:
pythonUploadServiceConnection: pypi-workflows

- bash: |
python -m twine upload -r pypi-workflows --config-file $(PYPIRC_PATH) $(System.ArtifactsDirectory)/package/pypi/*.tar.gz $(System.ArtifactsDirectory)/package/pypi/*.whl
displayName: Publish package
65 changes: 65 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build and Test

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build distribution
run: python -m build
- uses: actions/upload-artifact@v4
with:
path: ./dist/*

test:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt dist/*.whl
- name: Test with pytest
run: |
pytest tests
pypi-publish:
name: Upload release to PyPI
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/workflows
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450

0 comments on commit 5b6f9f8

Please sign in to comment.