feat: initial template commit #1
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: tests | |
| on: | |
| push: | |
| branches: [master] | |
| tags: ['v[0-9]*', '[0-9]+.[0-9]+*'] # Match tags that resemble a version | |
| pull_request: # Run in every PR | |
| workflow_dispatch: # Allow manually triggering the workflow | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: >- | |
| ${{ github.workflow }}-${{ github.ref_type }}- | |
| ${{ github.event.pull_request.number || github.sha }} | |
| cancel-in-progress: true | |
| env: | |
| TOX_VERSION: "4.24.1" | |
| MIN_PYTHON_VERSION: "3.10" | |
| MAX_PYTHON_VERSION: "3.12" | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| wheel-distribution: ${{ steps.wheel-distribution.outputs.path }} | |
| VERSION: ${{ steps.get_version.outputs.VERSION }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # deep clone for setuptools-scm | |
| - uses: actions/setup-python@v5 | |
| id: setup-python | |
| with: | |
| python-version: ${{ env.MIN_PYTHON_VERSION }} | |
| - name: Run static analysis and format checkers | |
| run: >- | |
| pipx run | |
| --python '${{ steps.setup-python.outputs.python-path }}' | |
| --spec tox==${{ env.TOX_VERSION }} | |
| tox -e lint | |
| - name: Build package distribution files | |
| run: >- | |
| pipx run | |
| --python '${{ steps.setup-python.outputs.python-path }}' | |
| --spec tox==${{ env.TOX_VERSION }} | |
| tox -e clean,build | |
| - name: Record the path of wheel distribution | |
| id: wheel-distribution | |
| run: echo "path=$(ls dist/*.whl)" >> $GITHUB_OUTPUT | |
| - name: Extract version | |
| id: get_version | |
| run: | | |
| path=$(ls dist/*.whl) | |
| version=$(basename "$path" | sed -E 's/lob_hlpr-([^-]+)-py3-none-any\.whl/\1/') | |
| echo "VERSION=$version" >> $GITHUB_OUTPUT | |
| - name: Store the distribution files for use in other stages | |
| # `tests` and `publish` will use the same pre-built distributions, | |
| # so we make sure to release the exact same package that was tested | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-distribution-files | |
| path: dist/ | |
| retention-days: 1 | |
| test: | |
| needs: prepare | |
| strategy: | |
| matrix: | |
| python: | |
| - "3.10" | |
| - "3.12" | |
| platform: | |
| - ubuntu-24.04 | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| id: setup-python | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Retrieve pre-built distribution files | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-distribution-files | |
| path: dist/ | |
| - name: Run tests | |
| run: >- | |
| pipx run | |
| --python '${{ steps.setup-python.outputs.python-path }}' | |
| --spec tox==${{ env.TOX_VERSION }} | |
| tox --installpkg '${{ needs.prepare.outputs.wheel-distribution }}' | |
| -- -rFEx --durations 10 --color yes | |
| package: | |
| needs: [test, prepare] | |
| strategy: | |
| matrix: | |
| platform: | |
| - ubuntu-24.04 | |
| - windows-2022 | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # deep clone for setuptools-scm | |
| - uses: actions/setup-python@v5 | |
| id: setup-python | |
| with: | |
| python-version: ${{ env.MAX_PYTHON_VERSION }} | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [package, prepare] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true |