Skip to content

Commit c463f0e

Browse files
authored
Merge pull request #127 from django-commons/django-commons-release
Add Django Commons release GHA
2 parents aa37225 + 53a7e6d commit c463f0e

File tree

2 files changed

+142
-12
lines changed

2 files changed

+142
-12
lines changed

.github/workflows/release.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
##
2+
# Derived from:
3+
# https://github.com/django-commons/django-commons-playground/blob/main/.github/workflows/release.yml
4+
#
5+
6+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
7+
8+
on: push
9+
10+
env:
11+
PYPI_URL: https://pypi.org/p/django-typer
12+
PYPI_TEST_URL: https://test.pypi.org/project/django-typer
13+
14+
jobs:
15+
16+
build:
17+
name: Build distribution 📦
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.x"
26+
- name: Install pypa/build
27+
run:
28+
python3 -m pip install build --user
29+
- name: Build a binary wheel and a source tarball
30+
run: python3 -m build
31+
- name: Store the distribution packages
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: python-package-distributions
35+
path: dist/
36+
37+
publish-to-pypi:
38+
name: >-
39+
Publish Python 🐍 distribution 📦 to PyPI
40+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
41+
needs:
42+
- build
43+
runs-on: ubuntu-latest
44+
environment:
45+
name: pypi
46+
url: ${{ env.PYPI_URL }}
47+
permissions:
48+
id-token: write # IMPORTANT: mandatory for trusted publishing
49+
steps:
50+
- name: Download all the dists
51+
uses: actions/download-artifact@v3
52+
with:
53+
name: python-package-distributions
54+
path: dist/
55+
- name: Publish distribution 📦 to PyPI
56+
uses: pypa/gh-action-pypi-publish@release/v1.10
57+
58+
github-release:
59+
name: >-
60+
Sign the Python 🐍 distribution 📦 with Sigstore
61+
and upload them to GitHub Release
62+
needs:
63+
- publish-to-pypi
64+
runs-on: ubuntu-latest
65+
66+
permissions:
67+
contents: write # IMPORTANT: mandatory for making GitHub Releases
68+
id-token: write # IMPORTANT: mandatory for sigstore
69+
70+
steps:
71+
- name: Download all the dists
72+
uses: actions/download-artifact@v3
73+
with:
74+
name: python-package-distributions
75+
path: dist/
76+
- name: Sign the dists with Sigstore
77+
uses: sigstore/gh-action-sigstore-python@v3
78+
with:
79+
inputs: >-
80+
./dist/*.tar.gz
81+
./dist/*.whl
82+
- name: Create GitHub Release
83+
env:
84+
GITHUB_TOKEN: ${{ github.token }}
85+
run: >-
86+
gh release create
87+
'${{ github.ref_name }}'
88+
--repo '${{ github.repository }}'
89+
--notes ""
90+
- name: Upload artifact signatures to GitHub Release
91+
env:
92+
GITHUB_TOKEN: ${{ github.token }}
93+
# Upload to GitHub Release using the `gh` CLI.
94+
# `dist/` contains the built packages, and the
95+
# sigstore-produced signatures and certificates.
96+
run: >-
97+
gh release upload
98+
'${{ github.ref_name }}' dist/**
99+
--repo '${{ github.repository }}'
100+
101+
publish-to-testpypi:
102+
name: Publish Python 🐍 distribution 📦 to TestPyPI
103+
needs:
104+
- build
105+
runs-on: ubuntu-latest
106+
107+
environment:
108+
name: testpypi
109+
url: ${{ env.PYPI_TEST_URL }}
110+
111+
permissions:
112+
id-token: write # IMPORTANT: mandatory for trusted publishing
113+
114+
steps:
115+
- name: Download all the dists
116+
uses: actions/download-artifact@v3
117+
with:
118+
name: python-package-distributions
119+
path: dist/
120+
- name: Publish distribution 📦 to TestPyPI
121+
uses: pypa/gh-action-pypi-publish@release/v1.10
122+
with:
123+
repository-url: https://test.pypi.org/legacy/
124+
skip-existing: true

pyproject.toml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1+
[build-system]
2+
requires = ["poetry-core"]
3+
build-backend = "poetry.core.masonry.api"
4+
15
[tool.poetry]
26
name = "django-typer"
37
version = "2.2.2"
48
description = "Use Typer to define the CLI for your Django management commands."
5-
authors = ["Brian Kohan <[email protected]>"]
9+
authors = [
10+
"Brian Kohan <[email protected]>",
11+
]
612
license = "MIT"
713
readme = "README.md"
814
repository = "https://github.com/bckohan/django-typer"
915
homepage = "https://django-typer.readthedocs.io"
1016
keywords = ["django", "CLI", "management", "Typer", "commands"]
17+
packages = [
18+
{ include = "django_typer" }
19+
]
20+
exclude = ["django_typer/locale"]
1121
classifiers = [
1222
"Environment :: Console",
1323
"Framework :: Django",
@@ -37,18 +47,14 @@ classifiers = [
3747
]
3848

3949

40-
[project.urls]
41-
Homepage = "https://django-typer.readthedocs.io"
42-
Documentation = "https://django-typer.readthedocs.io"
43-
Repository = "https://github.com/bckohan/django-typer"
44-
Issues = "https://github.com/bckohan/django-typer/issues"
45-
Changelog = "https://django-typer.readthedocs.io/en/latest/changelog.html"
46-
Code_of_Conduct = "https://github.com/django-commons/membership/blob/main/CODE_OF_CONDUCT.md"
50+
[tool.poetry.urls]
51+
"Homepage" = "https://django-typer.readthedocs.io"
52+
"Documentation" = "https://django-typer.readthedocs.io"
53+
"Repository" = "https://github.com/bckohan/django-typer"
54+
"Issues" = "https://github.com/bckohan/django-typer/issues"
55+
"Changelog" = "https://django-typer.readthedocs.io/en/latest/changelog.html"
56+
"Code_of_Conduct" = "https://github.com/django-commons/membership/blob/main/CODE_OF_CONDUCT.md"
4757

48-
packages = [
49-
{ include = "django_typer" }
50-
]
51-
exclude = ["django_typer/locale"]
5258

5359
[tool.poetry.dependencies]
5460
python = ">=3.8,<4.0"

0 commit comments

Comments
 (0)