Subagents: JS, UI #254
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: Publish to PyPI | |
| on: | |
| release: | |
| types: [published] | |
| pull_request: | |
| paths: | |
| - 'pyproject.toml' | |
| - 'bluebox/**' | |
| - '.github/workflows/publish.yml' | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'pyproject.toml' | |
| - 'bluebox/**' | |
| - '.github/workflows/publish.yml' | |
| workflow_dispatch: | |
| jobs: | |
| # ------------------------- | |
| # PR + Release: build & test | |
| # ------------------------- | |
| build: | |
| name: Build & test wheel | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get-version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install build deps | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build hatchling | |
| - name: Build package | |
| run: python -m build | |
| - name: Extract version | |
| id: get-version | |
| run: | | |
| VERSION=$(ls dist/*.whl | sed 's/.*bluebox_sdk-\(.*\)-py3.*/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Verify wheel installs | |
| run: | | |
| pip install dist/*.whl | |
| python -c "import bluebox" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| # ------------------------- | |
| # Release only: TestPyPI | |
| # ------------------------- | |
| publish-testpypi: | |
| name: Publish to TestPyPI | |
| if: github.event_name == 'release' | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| id-token: write | |
| outputs: | |
| test_version: ${{ steps.get-version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install build deps | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build hatchling | |
| - name: Add dev suffix for TestPyPI | |
| run: | | |
| TIMESTAMP=$(date +%Y%m%d%H%M%S) | |
| VERSION=$(python - <<'PY' | |
| import tomllib | |
| print(tomllib.load(open("pyproject.toml","rb"))["project"]["version"]) | |
| PY | |
| ) | |
| DEV_VERSION="${VERSION}.dev${TIMESTAMP}" | |
| sed -i "s/version = \"$VERSION\"/version = \"$DEV_VERSION\"/" pyproject.toml | |
| echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_ENV | |
| - name: Clean dist | |
| run: rm -rf dist | |
| - name: Build TestPyPI artifacts | |
| run: python -m build | |
| - name: Extract TestPyPI version | |
| id: get-version | |
| run: | | |
| VERSION=$(ls dist/*.whl | sed 's/.*bluebox_sdk-\(.*\)-py3.*/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| test-install-testpypi: | |
| name: Verify install from TestPyPI | |
| if: github.event_name == 'release' | |
| needs: publish-testpypi | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: pip install uv | |
| - name: Install from TestPyPI | |
| run: | | |
| VERSION="${{ needs.publish-testpypi.outputs.test_version }}" | |
| for i in {1..10}; do | |
| # Package from TestPyPI, deps from PyPI | |
| if uv pip install --system --pre \ | |
| --index-url https://test.pypi.org/simple/ \ | |
| --extra-index-url https://pypi.org/simple/ \ | |
| --index-strategy unsafe-best-match \ | |
| "bluebox-sdk==$VERSION"; then | |
| python -c "import bluebox" | |
| exit 0 | |
| fi | |
| sleep 30 | |
| done | |
| exit 1 | |
| # ------------------------- | |
| # Release only: PyPI | |
| # ------------------------- | |
| publish-pypi: | |
| name: Publish to PyPI | |
| if: github.event_name == 'release' | |
| needs: test-install-testpypi | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| test-install-pypi: | |
| name: Verify install from PyPI | |
| if: github.event_name == 'release' | |
| needs: [build, publish-pypi] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: pip install uv | |
| - name: Install from PyPI | |
| run: | | |
| VERSION="${{ needs.build.outputs.version }}" | |
| for i in {1..10}; do | |
| if uv pip install --system "bluebox-sdk==$VERSION"; then | |
| python -c "import bluebox" | |
| exit 0 | |
| fi | |
| sleep 30 | |
| done | |
| exit 1 |