Merge pull request #644 from ably/release/v2.1.3 #14
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 Python distribution to PyPI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - 'v[0-9]+.[0-9]+.[0-9]+*' | |
| jobs: | |
| build: | |
| name: Build distribution 📦 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| id: setup-python | |
| with: | |
| python-version: 3.12 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| - uses: actions/cache@v4 | |
| name: Define a cache for the virtual environment based on the dependencies lock file | |
| id: cache | |
| with: | |
| path: ./.venv | |
| key: venv-${{ runner.os }}-3.12-${{ hashFiles('uv.lock') }} | |
| - name: Install dependencies | |
| run: uv sync --extra crypto --extra dev | |
| - name: Generate rest sync code and tests | |
| run: uv run unasync | |
| - name: Build a binary wheel and a source tarball | |
| run: uv build | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Check that wheel and tarball contains ably/sync/ | |
| run: | | |
| # Check wheel | |
| WHEEL=$(ls dist/*.whl | head -n 1) | |
| echo "Checking wheel: $WHEEL" | |
| if unzip -l "$WHEEL" | grep -q "ably/sync/"; then | |
| echo "✅ Found ably/sync/ in wheel" | |
| else | |
| echo "❌ ably/sync/ not found in wheel" | |
| exit 1 | |
| fi | |
| # Check tarball | |
| TARBALL=$(ls dist/*.tar.gz | head -n 1) | |
| echo "Checking tarball: $TARBALL" | |
| if tar -tzf "$TARBALL" | grep -q "ably/sync/"; then | |
| echo "✅ Found ably/sync/ in tarball" | |
| else | |
| echo "❌ ably/sync/ not found in tarball" | |
| exit 1 | |
| fi | |
| publish-to-pypi: | |
| name: Publish Python distribution to PyPI | |
| if: startsWith(github.ref, 'refs/tags/v') # only publish to PyPI on tag pushes | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/ably | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Extract tag | |
| id: tag | |
| run: | | |
| TAG=${GITHUB_REF#refs/tags/v} | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| - name: Read VERSION_NAME from dist/ | |
| id: version | |
| run: | | |
| VERSION_NAME=$(basename dist/ably-*.tar.gz | sed -E 's/^ably-([^-]+)\.tar\.gz$/\1/') | |
| echo "version=$VERSION_NAME" >> $GITHUB_OUTPUT | |
| - name: Compare version with tag | |
| run: | | |
| if [ "$VERSION" != "$TAG" ]; then | |
| echo "VERSION ($VERSION) does not match tag ($TAG)." | |
| exit 1 | |
| fi | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| TAG: ${{ steps.tag.outputs.tag }} | |
| - 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/ably | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| 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/ |