Skip to content

Commit

Permalink
Publish to PyPI using Trusted Publishers (#94)
Browse files Browse the repository at this point in the history
Co-authored-by: Mariatta <Mariatta@users.noreply.github.com>
  • Loading branch information
hugovk and Mariatta authored Oct 12, 2023
1 parent 1957e38 commit 38fcdad
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 23 deletions.
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 = "mariatta@python.org" }]
name = "cherry-picker"
readme = "readme.rst"
maintainers = [{ name = "Python Core Developers", email = "core-workflow@python.org" }]
authors = [{ name = "Mariatta Wijaya", email = "mariatta@python.org" }]
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"

0 comments on commit 38fcdad

Please sign in to comment.