CI Pipeline #1
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_run: | |
| workflows: | |
| - Update PCI Database | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| - name: Install dependencies | |
| run: |- | |
| python -m pip install --upgrade pip | |
| pip install build wheel pytest toml requests | |
| - name: Copy tests | |
| if: steps.check-version.outputs.publish == 'true' | |
| 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 | |
| permissions: | |
| contents: read | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: build | |
| path: dist | |
| - name: Dummy Test Command | |
| run: |- | |
| echo Running tests... | |
| ls dist | |
| find . | |
| cd dist | |
| pip install *.whl | |
| pip show torchruntime | |
| python -m torchruntime --help # test invocation | |
| pytest --pyargs torchruntime # run tests | |
| permissions: | |
| contents: read | |
| needs: build | |
| deploy_to_pypi: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: build | |
| path: dist | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| - name: Install dependencies | |
| run: |- | |
| python -m pip install --upgrade pip | |
| pip install build toml requests | |
| - name: Check PyPI version | |
| id: check-version | |
| run: |- | |
| 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/torchruntime/json'); print(None if r.status_code == 404 else r.json()['info']['version'])") | |
| 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: Dummy | |
| run: | | |
| echo "Ready to deploy to PyPI" | |
| ls | |
| find . | |
| # - name: Publish to PyPI | |
| # if: steps.check-version.outputs.publish == 'true' | |
| # uses: pypa/gh-action-pypi-publish@release/v1 | |
| # with: | |
| # verbose: true | |
| permissions: | |
| contents: read | |
| id-token: write | |
| if: github.event_name == 'release' && github.event.action == 'created' | |
| needs: test |