Skip to content

Commit c813511

Browse files
authored
Add Workflow for Publishing to (Test)PyPi (#7)
1 parent 1658d88 commit c813511

File tree

2 files changed

+119
-3
lines changed

2 files changed

+119
-3
lines changed

.github/workflows/release.yml

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

pyproject.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ classifiers = [
2525
dependencies = []
2626

2727
[project.urls]
28-
Documentation = "https://github.com/Hinrich Mahler/aiorem#readme"
29-
Issues = "https://github.com/Hinrich Mahler/aiorem/issues"
30-
Source = "https://github.com/Hinrich Mahler/aiorem"
28+
Documentation = "https://aiorem.readthedocs.io/"
29+
Issues = "https://github.com/Bibo-Joshi/aiorem/issues"
30+
Source = "https://github.com/Bibo-Joshi/aiorem"
3131

32+
# HATCH:
3233
[tool.hatch.version]
3334
path = "aiorem/__about__.py"
3435

36+
[tool.hatch.build]
37+
packages = ["aiorem"]
38+
3539
# BLACK:
3640
[tool.black]
3741
line-length = 99

0 commit comments

Comments
 (0)