Merge pull request #1 from elifarley/elifarley-patch-1 #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to PyPI | |
on: | |
push: | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+' # Matches semantic versioning tags | |
- '[0-9]+.[0-9]+.[0-9]+-test.*' # Test releases | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.12'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies and run CI | |
run: | | |
python -m pip install --upgrade pip | |
make install-test test | |
publish: | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Verify tag version matches package version | |
run: | | |
python -m pip install --upgrade pip | |
make install-dist | |
PACKAGE_VERSION=$(python -m setuptools_scm) | |
TAG_VERSION=${GITHUB_REF#refs/tags/} # Remove 'refs/tags/' prefix | |
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then | |
echo "Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)" | |
exit 1 | |
fi | |
- name: Publish to TestPyPI | |
if: contains(github.ref, 'test') | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
run: make build && twine upload --repository testpypi dist/* | |
- name: Publish to PyPI | |
if: "!contains(github.ref, 'test')" | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: make dist | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: dist/* | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |