-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (45 loc) · 1.32 KB
/
python-publish.yml
File metadata and controls
57 lines (45 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Publish to PyPI
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Add uv to PATH
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Set package version from release tag
shell: bash
run: |
TAG=${{ github.event.release.tag_name }}
# strip leading "v" if present
TAG=${TAG#v}
echo "Setting version to $TAG"
# replace the version line under [project]
sed -E -i "s/^version = \".*\"$/version = \"$TAG\"/" pyproject.toml
# show the changed line for visibility
grep -n '^version' pyproject.toml || true
- name: Clean previous builds
run: rm -rf dist || true
- name: Build package
run: uv build
- name: Show built artifacts
run: ls -la dist || true
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
uv tool install twine
uv tool run twine upload dist/*