v1.6.0 - Standardise Type Safety, Simplify Overloads, and Enhance Documentation #56
Workflow file for this run
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: CD | |
| on: | |
| # Only trigger when release is published | |
| release: | |
| types: | |
| - published | |
| # Allows you to run this workflow manually from the Actions tab | |
| # workflow_dispatch: | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
| concurrency: | |
| group: "deployment" | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write # <-- to allow assets to be uploaded to the release | |
| id-token: write # <-- to allow access to the tokens | |
| pages: write # <-- to allow publishing to GitHub Pages | |
| env: | |
| VERSION: ${{ github.event.release.tag_name }} | |
| PACKAGE_NAME: toolbox-python | |
| UV_LINK_MODE: copy | |
| UV_NO_SYNC: true | |
| UV_INDEX_STRATEGY: unsafe-best-match | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| REPOSITORY_NAME: data-science-extensions/toolbox-python | |
| GIT_BRANCH: ${{ github.event.release.target_commitish }} | |
| PYTHON_VERSION: '3.14' | |
| PYTHONIOENCODING: utf-8 | |
| jobs: | |
| test: | |
| name: Run Tests | |
| if: ${{ always() }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| id: checkout-repository | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ env.GIT_BRANCH }} | |
| - name: Set up UV | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Set up Python | |
| id: setup-python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install dependencies | |
| id: install-dependencies | |
| run: uv sync --no-cache --all-groups --upgrade --reinstall-package=${{ env.PACKAGE_NAME }} | |
| - name: Set up Git | |
| id: setup-git | |
| env: | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| run: | | |
| uv run ./src/utils/scripts.py add_git_credentials | |
| uv run ./src/utils/scripts.py git_switch_to_branch ${{ env.GIT_BRANCH }} | |
| uv run ./src/utils/scripts.py git_refresh_current_branch | |
| - name: Run checks | |
| id: run-checks | |
| run: uv run ./src/utils/scripts.py check | |
| - name: Add coverage report | |
| id: add-coverage-report | |
| run: uv run ./src/utils/scripts.py git_add_coverage_report | |
| - name: Upload coverage | |
| id: upload-coverage | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ env.CODECOV_TOKEN }} | |
| files: ./cov-report/xml/cov-report.xml | |
| verbose: true | |
| build-package: | |
| name: Build Package | |
| needs: test | |
| if: ${{ always() && needs.test.result == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| id: checkout-repository | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ env.GIT_BRANCH }} | |
| - name: Set up UV | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Setup Python | |
| id: setup-python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Check VERSION | |
| id: check-version | |
| run: | | |
| if [ -z "${{ env.VERSION }}" ]; then | |
| echo "/$VERSION is missing. Please try again." | |
| exit 1 | |
| fi | |
| - name: Install dependencies | |
| run: uv sync --no-cache --upgrade --reinstall-package=${{ env.PACKAGE_NAME }} | |
| - name: Setup Git | |
| id: setup-git | |
| run: | | |
| uv run ./src/utils/scripts.py add_git_credentials | |
| uv run ./src/utils/scripts.py git_switch_to_branch ${{ env.GIT_BRANCH }} | |
| uv run ./src/utils/scripts.py git_refresh_current_branch | |
| - name: Bump version | |
| id: bump-version | |
| run: uv version ${VERSION} | |
| - name: Update Git Version | |
| id: update-git-version | |
| run: uv run ./src/utils/scripts.py git_update_version_cli ${VERSION} | |
| - name: Build package | |
| id: build-package | |
| run: uv build --out-dir=dist | |
| - name: Upload assets | |
| id: upload-assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/* | |
| - name: Upload artifacts | |
| id: upload-artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/* | |
| retention-days: 5 | |
| overwrite: true | |
| - name: Fix tag reference | |
| id: fix-tag-reference | |
| run: uv run ./src/utils/scripts.py git_fix_tag_reference_cli ${{ env.VERSION }} | |
| deploy-package: | |
| name: Deploy to PyPI | |
| needs: build-package | |
| if: ${{ always() && needs.build-package.result == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| id: checkout-repository | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ env.GIT_BRANCH }} | |
| - name: Set up UV | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Setup Python | |
| id: setup-python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Download artifacts | |
| id: download-artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Publish package | |
| id: publish-package | |
| run: uv publish --token=${{ env.PYPI_TOKEN }} --no-cache dist/* | |
| - name: Check | |
| id: check | |
| run: | | |
| echo 'Package deployed to PyPI 👉 https://pypi.org/project/${{ env.PACKAGE_NAME }}' | |
| uvx pip install --dry-run --no-deps --no-cache ${{ env.PACKAGE_NAME }} | |
| install-package: | |
| needs: deploy-package | |
| if: ${{ always() && needs.deploy-package.result == 'success' }} | |
| strategy: | |
| matrix: | |
| os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] | |
| python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] | |
| fail-fast: false | |
| max-parallel: 30 | |
| name: Install Package on '${{ matrix.os }}' with '${{ matrix.python-version }}' | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout repository | |
| id: checkout-repository | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ env.GIT_BRANCH }} | |
| - name: Setup Python | |
| id: setup-python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install package | |
| id: install-package | |
| run: pip install --no-cache --verbose --no-python-version-warning "${{ env.PACKAGE_NAME }}==${{ env.VERSION }}" | |
| build-docs: | |
| needs: | |
| - test | |
| - deploy-package | |
| if: ${{ always() && needs.test.result == 'success' && needs.deploy-package.result == 'success' }} | |
| name: Build Docs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| id: checkout-repository | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ env.GIT_BRANCH }} | |
| - name: Set up UV | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Setup Python | |
| id: setup-python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install dependencies | |
| id: install-dependencies | |
| run: uv sync --no-cache --upgrade --group=docs --reinstall-package=${{ env.PACKAGE_NAME}} | |
| - name: Setup Git | |
| id: setup-git | |
| env: | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| run: | | |
| uv run ./src/utils/scripts.py add_git_credentials | |
| uv run ./src/utils/scripts.py git_switch_to_branch ${{ env.GIT_BRANCH }} | |
| uv run ./src/utils/scripts.py git_refresh_current_branch | |
| - name: Generate ChangeLog | |
| id: generate-changelog | |
| env: | |
| GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} | |
| REPOSITORY_NAME: ${{ env.REPOSITORY_NAME }} | |
| run: uv run ./src/utils/changelog.py | |
| - name: Commit ChangeLog | |
| id: commit-changelog | |
| run: | | |
| git add . | |
| git commit --message "Update changelog to \`${{ env.VERSION }}\` [skip ci]" || echo "No changes to commit" | |
| git push --force --no-verify | |
| git status | |
| - name: Build docs | |
| id: build-docs | |
| run: uv run ./src/utils/scripts.py build_versioned_docs_cli ${{ env.VERSION }} | |
| - name: Fix tag reference | |
| id: fix-tag-reference | |
| run: uv run ./src/utils/scripts.py git_fix_tag_reference_cli ${{ env.VERSION }} |