Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish to PyPI using Trusted Publishers #94

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build package

on:
push:
pull_request:
release:
types:
- published
workflow_dispatch:

permissions:
contents: read

jobs:
# Always build & lint package.
build-package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: hynek/build-and-inspect-python-package@v1

# Publish to Test PyPI on every commit on main.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
if: |
github.repository_owner == 'python'
&& github.event_name == 'push'
&& github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-package

permissions:
id-token: write

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

# Publish to PyPI on GitHub Releases.
release-pypi:
name: Publish to PyPI
# Only run for published releases.
if: |
github.repository_owner == 'python'
&& github.event.action == 'published'
runs-on: ubuntu-latest
needs: build-package

permissions:
id-token: write

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 3 additions & 1 deletion cherry_picker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
"""Backport CPython changes from main to maintenance branches."""
__version__ = "2.2.0"
import importlib.metadata

__version__ = importlib.metadata.version(__name__)
58 changes: 36 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
[build-system]
requires = ["flit_core>=3.2,<4"]
build-backend = "flit_core.buildapi"
build-backend = "hatchling.build"
requires = [
"hatch-vcs",
"hatchling",
]

[project]
name = "cherry_picker"
authors = [{ name = "Mariatta Wijaya", email = "[email protected]" }]
name = "cherry-picker"
readme = "readme.rst"
maintainers = [{ name = "Python Core Developers", email = "[email protected]" }]
authors = [{ name = "Mariatta Wijaya", email = "[email protected]" }]
requires-python = ">=3.8"
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = [
"description",
"version",
]
dependencies = [
"click>=6.0",
"gidgethub",
"requests",
"tomli>=1.1.0;python_version<'3.11'",
"click>=6",
"gidgethub",
"requests",
'tomli>=1.1; python_version < "3.11"',
]
readme = "readme.rst"
classifiers = [
"Programming Language :: Python :: 3.8",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
[project.optional-dependencies]
dev = [
"pytest",
"pytest-cov",
]
requires-python = ">=3.8"
dynamic = ["version", "description"]

[project.urls]
"Homepage" = "https://github.com/python/cherry-picker"

[project.scripts]
cherry_picker = "cherry_picker.cherry_picker:cherry_pick_cli"

[project.optional-dependencies]
dev = [
"pytest",
"pytest-cov",
]
[tool.hatch]
version.source = "vcs"

[tool.hatch.version.raw-options]
local_scheme = "no-local-version"