Skip to content

Commit 1d9cc47

Browse files
committed
Add pypi publishing
1 parent 9abbf71 commit 1d9cc47

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

.github/workflows/pypi.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Example:
2+
# - https://github.com/pallets/flask/blob/main/.github/workflows/tests.yaml
3+
# TODO:
4+
# GH release
5+
# Environment protection
6+
# - https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
7+
# Separate build & release
8+
9+
name: PyPI publish
10+
11+
12+
on:
13+
push:
14+
tags:
15+
- 'v*.*.*'
16+
workflow_dispatch:
17+
18+
19+
jobs:
20+
build:
21+
name: Build and publish
22+
23+
runs-on: ubuntu-latest
24+
25+
# TODO: recommended best practice
26+
# environment:
27+
# name: pypi-publish
28+
# url: ...
29+
30+
permissions:
31+
# required for pypa/gh-action-pypi-publish
32+
id-token: write
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
# https://docs.astral.sh/uv/guides/integration/github/#setting-up-python
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v5
40+
with:
41+
enable-cache: true
42+
cache-dependency-glob: "uv.lock"
43+
44+
- name: "Set up Python"
45+
uses: actions/setup-python@v5
46+
with:
47+
python-version-file: "pyproject.toml"
48+
49+
- name: Python prep & build
50+
run: |
51+
uv sync --locked
52+
53+
uv run hatch --version
54+
55+
echo "Project version: `uv run hatch version`"
56+
57+
uv run hatch build
58+
59+
- name: Publish package distributions to PyPI
60+
uses: pypa/gh-action-pypi-publish@release/v1

env-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
profile:
22
pypi:
33
HATCH_INDEX_USER: '__token__'
4-
HATCH_INDEX_AUTH: 'op://private/pypi.python.org/api-token'
4+
HATCH_INDEX_AUTH: 'op://my/private/pypi.python.org/api-token'

0 commit comments

Comments
 (0)