Skip to content

Commit 889f18e

Browse files
committed
Initial commit
1 parent c378bd3 commit 889f18e

File tree

7 files changed

+173
-0
lines changed

7 files changed

+173
-0
lines changed

.github/workflows/release.yml

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

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
# django-community-playground
22
A sample project to test things out
3+
4+
5+
## Running tests
6+
7+
```shell
8+
python -m unittest
9+
```
10+
11+
## Manually building and uploading
12+
13+
```shell
14+
python3 -m pip install -U twine build
15+
python3 -m build
16+
python3 -m twine upload --repository testpypi dist/*
17+
```

pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "django_community_playground"
7+
version = "1.0.0"
8+
authors = [
9+
{ name="Tim Schilling", email="[email protected]" },
10+
]
11+
description = "A place to test things out"
12+
readme = "README.md"
13+
requires-python = ">=3.11"
14+
classifiers = [
15+
"Programming Language :: Python :: 3",
16+
"License :: OSI Approved :: MIT License",
17+
"Operating System :: OS Independent",
18+
]
19+
keywords = [
20+
"django",
21+
"django community",
22+
]
23+
24+
[project.urls]
25+
Homepage = "https://github.com/django-community/django-community-playground"
26+
Issues = "https://github.com/django-community/django-community-playground/issues"

src/django_community_playground/__init__.py

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def seesaw():
2+
while True:
3+
yield "see"
4+
yield "saw"

tests/__init__.py

Whitespace-only changes.

tests/test_playground.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from unittest import TestCase
2+
3+
from src.django_community_playground import playground
4+
5+
6+
class TestPlayground(TestCase):
7+
def test_seesaw(self):
8+
seesaw = playground.seesaw()
9+
self.assertEqual(next(seesaw), "see")
10+
self.assertEqual(next(seesaw), "saw")
11+
self.assertEqual(next(seesaw), "see")
12+
self.assertEqual(next(seesaw), "saw")
13+
self.assertEqual(next(seesaw), "see")
14+
self.assertEqual(next(seesaw), "saw")

0 commit comments

Comments
 (0)