Bugfix release action #7
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: Upload Python Package to PyPI | |
on: | |
release: | |
types: [published] | |
jobs: | |
build: | |
name: Build and deploy | |
environment: test | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set environment variables | |
id: set_env_variables | |
run: | | |
echo "PYTHONPATH=." >> "$GITHUB_ENV" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
pip install -r requirements.txt | |
- name: Test with pytest | |
run: | | |
pip install pytest | |
pytest test/ --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml | |
- name: Extract tag name | |
id: tag | |
run: echo "PKG_VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> "$GITHUB_OUTPUT" | |
- name: Update version in pyproject.toml | |
run: >- | |
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.PKG_VERSION }}/g" pyproject.toml | |
- name: Build package | |
run: python -m build | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: | | |
dist/ | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: ${{ vars.PYPI_URL }} | |
password: ${{ secrets.PYPI_API_TOKEN }} |