Publish test build to testpypi #12
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 test build to testpypi | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.build-step.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- name: Install pip and flake package | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --statistics | |
- name: Install poetry and project dependencies | |
run: | | |
python -m pip install poetry | |
poetry install | |
- name: Test with pytest | |
run: | | |
echo ${{ github.workspace }} | |
cd ${{ github.workspace }}/tests | |
poetry run pytest --github-action-run=True | |
- name: Build | |
id: build-step | |
run: | | |
poetry build | |
VERSION=$(poetry version -s) | |
echo "$VERSION" | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Output the release version of dwcahandler | |
run: | | |
echo "the version number is ${{ steps.build-step.outputs.version }}" | |
- name: Archive test artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dwcahandler-test-dist-v${{ steps.build-step.outputs.version }} | |
path: dist | |
publish-to-pypi: | |
name: Publish dwcahandler distribution to TestPyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: test | |
url: https://test.pypi.org/p/dwcahandler | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: dwcahandler-test-dist-v${{ needs.build.outputs.version }} | |
path: dist/ | |
- name: Publish dwcahandler distribution to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ |