Skip to content

0.12: general maintenance #10

0.12: general maintenance

0.12: general maintenance #10

Workflow file for this run

name: testpypi publish
# based on https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
on:
pull_request:
types:
- opened
- reopened
- synchronize # (when you commit/push to)
- ready_for_review
paths-ignore:
- 'doc/**'
- 'tests/**'
- 'CHANGELOG.md'
- 'TODO.md'
push:
branches:
# this allows to test if everything looks okay before doing a
# git release (which will trigger the definitive pypi publish).
- main
jobs:
publish-to-testpypi:
name: Build and publish distribution to TestPyPI
runs-on: ubuntu-latest
# only runs on PR that are ready-for-review
if: ${{ !github.event.pull_request.draft }}
outputs:
published_version: ${{steps.getversion.outputs.version}}
steps:
- uses: actions/checkout@v4
- name: Install Poetry
# poetry 1.8.4
run: pipx install git+https://github.com/python-poetry/poetry.git@6a071c181ad82ec3a5d4ecd54d50d08a75470e78
# XXX: TestPyPI expect an unique version for each deploy
# so we must create an unique version for each action run.
# Note that this doesn't change the version in 'kloch/__init__.py'
- name: Update version to be unique per run
run: poetry version $(poetry version --short).dev${{ github.run_id }}${{ github.run_number }}${{ github.run_attempt }}
- id: getversion
run: echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT"
- name: Configure poetry for TestPyPI
run: poetry config repositories.test-pypi https://test.pypi.org/legacy/
- name: Poetry build and publish to TestPyPI
run: poetry publish --build -u __token__ -p ${{ secrets.TESTPYPI_TOKEN }} --repository test-pypi
# this is only stored for debugging purposes
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
test-pip-install:
name: Pip install the package from TestPyPI
runs-on: ubuntu-latest
needs: publish-to-testpypi
steps:
# needed for pytest at the end
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.7
- name: Create venv
run: python -m venv .testvenv
- name: Activate venv
run: source .testvenv/bin/activate
- run: pip install -i https://test.pypi.org/simple/ kloch[tests]==${{needs.publish-to-testpypi.outputs.published_version}} --extra-index-url https://pypi.org/simple
- name: test installed package
run: python -m pytest ./tests