-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate from poetry to uv and enable testpypi publishing
- Loading branch information
Showing
12 changed files
with
1,617 additions
and
1,977 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ on: | |
branches: ["main"] | ||
|
||
env: | ||
POETRY_VERSION: 1.8.3 | ||
UV_VERSION: 0.4.5 | ||
PACKAGE_NAME: firebase_messaging | ||
|
||
jobs: | ||
linting: | ||
|
@@ -22,12 +23,12 @@ jobs: | |
uses: ./.github/actions/setup | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
poetry-version: ${{ env.POETRY_VERSION }} | ||
poetry-install-options: "" | ||
uv-version: ${{ env.UV_VERSION }} | ||
uv-install-options: "" | ||
cache-pre-commit: true | ||
- name: "Run pre-commit checks" | ||
run: | | ||
poetry run pre-commit run --all-files | ||
uv run pre-commit run --all-files --verbose | ||
docs: | ||
name: "Build docs" | ||
|
@@ -42,11 +43,11 @@ jobs: | |
uses: ./.github/actions/setup | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
poetry-version: ${{ env.POETRY_VERSION }} | ||
poetry-install-options: "--extras docs --without dev" | ||
- name: Make docs poetry | ||
uv-version: ${{ env.UV_VERSION }} | ||
uv-install-options: "--extra docs --no-dev" | ||
- name: Make docs | ||
run: | | ||
poetry run make -C docs html | ||
uv run make -C docs html | ||
tests: | ||
name: Tests - Python ${{ matrix.python-version}} on ${{ matrix.os }} | ||
|
@@ -64,15 +65,27 @@ jobs: | |
uses: ./.github/actions/setup | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
poetry-version: ${{ env.POETRY_VERSION }} | ||
uv-version: ${{ env.UV_VERSION }} | ||
uv-install-options: "" | ||
- name: Run tests | ||
run: > | ||
poetry run pytest tests/ | ||
--cov=firebase_messaging --cov-report=xml | ||
uv run pytest tests/ | ||
--cov=${{ env.PACKAGE_NAME }} --cov-report=xml | ||
--cov-report=term-missing --import-mode importlib | ||
- name: Coveralls GitHub Action | ||
uses: coverallsapp/[email protected] | ||
with: | ||
file: coverage.xml | ||
debug: true | ||
parallel: true | ||
if: ${{ success() && matrix.python-version == '3.12' }} | ||
|
||
finish: | ||
name: Finish coverage build | ||
needs: tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Close parallel build | ||
uses: coverallsapp/[email protected] | ||
with: | ||
parallel-finished: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,124 @@ | ||
# This workflows will upload a Python Package using Twine when a release is created | ||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | ||
|
||
name: Upload Python Package | ||
name: Publish Python distribution to PyPI and TestPyPI | ||
|
||
on: | ||
release: | ||
types: [published] | ||
push: | ||
branches: ["main", "feat/poetry_to_uv"] | ||
tags: | ||
- '*' | ||
env: | ||
UV_VERSION: 0.4.5 | ||
PYPI_PROJECT: firebase-messaging | ||
|
||
# GITHUB_TOKEN must have write access | ||
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/signing-the-distribution-packages | ||
|
||
jobs: | ||
deploy: | ||
build: | ||
name: Build distribution | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
- name: Install uv | ||
run: |- | ||
pipx install uv==${{ env.UV_VERSION }} --python "${{ steps.setup-python.outputs.python-path }}" | ||
- name: Build with uv | ||
run: uv build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: >- | ||
Publish to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/firebase-messaging | ||
url: https://pypi.org/p/${{ env.PYPI_PROJECT }} | ||
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 PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
github-release: | ||
name: >- | ||
Create github release | ||
needs: | ||
- publish-to-pypi | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Repo clone is required for --notes-from-tag to work | ||
run: | | ||
gh repo clone '${{ github.repository }}' | ||
cd ${{ github.event.repository.name }} | ||
gh release create '${{ github.ref_name }}' --verify-tag --notes-from-tag --title '${{ github.ref_name }}' ${{ contains(github.ref_name, 'dev') && '--prerelease --latest=false' || '--latest=true' }} | ||
cd .. | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ github.ref_name }}' dist/** | ||
--repo '${{ github.repository }}' | ||
publish-to-testpypi: | ||
name: Publish to TestPyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: testpypi | ||
url: https://test.pypi.org/p/${{ env.PYPI_PROJECT }} | ||
|
||
permissions: | ||
# IMPORTANT: this permission is mandatory for trusted publishing | ||
id-token: write | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python3 -m pip install --user pipx | ||
python3 -m pipx ensurepath | ||
pipx install poetry==1.8.3 | ||
- name: Build | ||
run: | | ||
poetry build | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
verbose: true | ||
- 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/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
__pycache__/ | ||
.vscode/ | ||
|
||
.coverage | ||
.tox | ||
htmlcov/ | ||
docs/build | ||
dist | ||
.venv |
This file contains 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
Oops, something went wrong.