release-python #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
| name: release-python | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install release dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r test-requirements.txt | |
| pip install . | |
| - name: Verify tag and package version | |
| run: python scripts/sdkctl.py verify-release --tag "${GITHUB_REF_NAME}" | |
| - name: Validate docs | |
| run: python scripts/sdkctl.py validate-examples | |
| - name: Run tests | |
| run: python -m pytest | |
| - name: Build distribution artifacts | |
| run: python -m build | |
| - name: Check distribution metadata | |
| run: python -m twine check dist/* | |
| - name: Smoke install built wheel | |
| env: | |
| RELEASE_VERSION: ${{ github.ref_name }} | |
| run: | | |
| python -m venv .release-venv | |
| . .release-venv/bin/activate | |
| pip install dist/*.whl | |
| python - <<'PY' | |
| import os | |
| import justserpapi | |
| expected = os.environ["RELEASE_VERSION"].removeprefix("v") | |
| assert justserpapi.__version__ == expected | |
| client = justserpapi.Client(api_key="test-api-key") | |
| assert type(client).__name__ == "Client" | |
| assert type(client.google).__name__ == "GoogleResource" | |
| client.close() | |
| PY | |
| - name: Upload distribution artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-dist | |
| path: dist/* | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/justserpapi/ | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Download distribution artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-dist | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| files: dist/* | |
| generate_release_notes: true |