CI Pipeline #102
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
| # Generated initially using github-actions-wizard (https://github.com/cmdr2/github-actions-wizard) | |
| name: CI Pipeline | |
| run-name: CI Pipeline | |
| on: | |
| release: | |
| types: | |
| - created | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| cache: pip | |
| - name: Install dependencies | |
| run: |- | |
| python -m pip install --upgrade pip | |
| pip install build wheel | |
| - name: Copy tests | |
| run: | | |
| cp -R tests torchruntime/ | |
| - name: Build package | |
| run: |- | |
| python -m build | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build | |
| path: |- | |
| dist | |
| pyproject.toml | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: build | |
| steps: | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: build | |
| path: . | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| cache: pip | |
| - name: Install dependencies | |
| run: |- | |
| python -m pip install --upgrade pip | |
| pip install pytest | |
| - name: Install and test the package | |
| run: |- | |
| find . | |
| cd dist | |
| pip install *.whl | |
| pip show torchruntime | |
| python -m torchruntime --help # test invocation | |
| pytest --pyargs torchruntime # run tests | |
| deploy_to_pypi_on_release_created: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| if: github.event_name == 'release' && github.event.action == 'created' | |
| needs: test | |
| steps: | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: build | |
| path: . | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| cache: pip | |
| - run: |- | |
| python -m pip install --upgrade pip | |
| pip install toml requests | |
| - name: Check PyPI version | |
| id: check-version | |
| run: |- | |
| PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])") | |
| TOML_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") | |
| PYPI_VERSION=$(python -c "import requests; r = requests.get('https://pypi.org/pypi/$PACKAGE_NAME/json'); print(None if r.status_code == 404 else r.json()['info']['version'])") | |
| echo "Package name: $PACKAGE_NAME" | |
| echo "Local version: $TOML_VERSION" | |
| echo "PyPI version: $PYPI_VERSION" | |
| if [ "$TOML_VERSION" = "$PYPI_VERSION" ]; then | |
| echo "Versions match. Skipping publish." | |
| echo "publish=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Versions differ. Proceeding with publish." | |
| echo "publish=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to PyPI | |
| if: steps.check-version.outputs.publish == 'true' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| verbose: true |