Merge pull request #1984 from transformerlab/fix/copy-file-mounts-exp… #134
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
| # This workflow will upload a Python Package to PyPI when a release is created | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | |
| name: Build and Upload SDK Python Package | |
| on: | |
| release: | |
| types: [published] | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "lab-sdk/**" | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-release-distributions: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: lab-sdk | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Check if version already exists on PyPI | |
| run: | | |
| PKG_NAME=$(grep -E '^name\s*=\s*' pyproject.toml | head -1 | sed 's/name\s*=\s*"\(.*\)"/\1/') | |
| PKG_VERSION=$(grep -E '^version\s*=\s*' pyproject.toml | head -1 | sed 's/version\s*=\s*"\(.*\)"/\1/') | |
| echo "Package name: $PKG_NAME" | |
| echo "Package version: $PKG_VERSION" | |
| echo "Checking if version exists on PyPI..." | |
| EXISTS=$(curl -s https://pypi.org/pypi/$PKG_NAME/json | grep -F "\"$PKG_VERSION\"" || true) | |
| if [ -n "$EXISTS" ]; then | |
| echo "Error: Version $PKG_VERSION of $PKG_NAME already exists on PyPI." >&2 | |
| exit 1 | |
| fi | |
| - name: Build release distributions | |
| run: | | |
| python -m pip install build | |
| python -m build | |
| - name: Upload distributions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: lab-sdk/dist/ | |
| pypi-publish: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-release-distributions | |
| environment: | |
| name: pypi | |
| steps: | |
| - name: Retrieve release distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| - name: Publish release distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/ | |
| password: ${{ secrets.PYPI_API_TOKEN }} |