Merge pull request #66 from killiandesse/pep639 #30
This file contains hidden or 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: test | |
| on: [push, pull_request, workflow_dispatch] | |
| jobs: | |
| build-and-inspect: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| attestations: write | |
| contents: read | |
| outputs: | |
| python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Build and inspect package | |
| id: baipp | |
| uses: hynek/build-and-inspect-python-package@v2 | |
| with: | |
| attest-build-provenance-github: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} | |
| env: | |
| SETUPTOOLS_SCM_OVERRIDES_FOR_INICONFIG: ${{ github.ref == 'refs/heads/main' && 'local_scheme="no-local-version"' || '' }} | |
| test: | |
| needs: build-and-inspect | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: bash | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ${{ fromJSON(needs.build-and-inspect.outputs.python-versions) }} | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - name: Checkout test files | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| testing | |
| uv.lock | |
| sparse-checkout-cone-mode: false | |
| - name: Download built packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: Packages | |
| path: dist | |
| - name: Verify artifacts exist | |
| run: | | |
| ls -la dist/ | |
| test -f dist/*.whl || (echo "No wheel found!" && exit 1) | |
| test -f dist/*.tar.gz || (echo "No sdist found!" && exit 1) | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python ${{ matrix.python }} | |
| run: uv python install ${{ matrix.python }} | |
| - name: Run tests with built wheel | |
| run: uv run --with dist/*.whl --with pytest pytest testing --color=yes | |
| create-release: | |
| name: Create GitHub Release | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| needs: [test, build-and-inspect] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download built packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: Packages | |
| path: dist | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/* | |
| fail_on_unmatched_files: true | |
| generate_release_notes: true | |
| name: Version ${{ steps.version.outputs.VERSION }} | |
| publish-to-pypi: | |
| name: Publish to PyPI | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| needs: [test, build-and-inspect, create-release] | |
| runs-on: ubuntu-latest | |
| environment: pypi-upload | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download built packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: Packages | |
| path: dist | |
| - name: Publish package to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| publish-to-test-pypi: | |
| name: Publish to TestPyPI | |
| if: | | |
| github.repository == 'pytest-dev/iniconfig' && | |
| (github.event_name == 'push' && ( | |
| github.ref == 'refs/heads/main' || | |
| contains(github.ref, 'deploy') | |
| )) | |
| needs: [test, build-and-inspect] | |
| runs-on: ubuntu-latest | |
| environment: test-pypi-upload | |
| permissions: | |
| id-token: write | |
| attestations: write | |
| steps: | |
| - name: Download built packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: Packages | |
| path: dist | |
| - name: Publish package to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ |