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
| # | |
| # File: https://github.com/cloud-helpers/python-plugin-data-loader/blob/main/.github/workflows/publish-pypi.yml | |
| # | |
| # Doc: | |
| # * https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
| # | |
| name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI | |
| # workflow_dispatch: | |
| on: push | |
| jobs: | |
| build: | |
| name: Build distribution 📦 | |
| runs-on: ubuntu-latest | |
| steps: | |
| # https://github.com/actions/checkout | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files | |
| - name: Branch and version | |
| id: source_metadata | |
| run: | | |
| echo "SOURCE_SHA=${GITHUB_SHA}" >> "$GITHUB_ENV" | |
| echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> "$GITHUB_ENV" | |
| echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> "$GITHUB_ENV" | |
| echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV" | |
| # https://github.com/actions/setup-python | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| # https://docs.astral.sh/uv/guides/integration/github/#installation | |
| # https://github.com/astral-sh/setup-uv | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Install Python dependencies and build the Python wheel | |
| run: | | |
| make init | |
| make update | |
| make build | |
| make tests | |
| shell: bash | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| publish-to-pypi: | |
| name: >- | |
| Publish Python 🐍 distribution 📦 to PyPI | |
| if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/data-loader-plugin | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution 📦 to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| publish-to-testpypi: | |
| name: Publish Python 🐍 distribution 📦 to TestPyPI | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/p/data-loader-plugin | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution 📦 to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |