-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (77 loc) · 2.25 KB
/
publish.yml
File metadata and controls
80 lines (77 loc) · 2.25 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Publish
on:
workflow_call:
inputs:
python-version:
description: "Python version for build"
required: false
type: string
default: "3.13"
tag-name:
description: "Git tag to release"
required: true
type: string
publish-to-pypi:
description: "Whether to publish to PyPI (true/false)"
required: false
type: boolean
default: false
secrets:
repo-token:
description: "GitHub token for release creation"
required: true
pypi-token:
description: "PyPI API token"
required: false
permissions:
contents: write
jobs:
build-release-publish:
runs-on: ubuntu-latest
# only run on a tag push, or on a manual dispatch *where* the user has
# selected a tag ref (i.e. github.ref starts with refs/tags/)
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# on push this is already the tag ref; on dispatch you must choose
# the tag in the UI so github.ref is the tag
ref: ${{ github.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ inputs.python-version }}
enable-cache: true
- name: Install project
run: uv sync
- name: Build
run: uv build
- name: Verify artifacts
run: ls -la dist/
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag-name }}
name: Release ${{ inputs.tag-name }}
generate_release_notes: true
files: |
dist/*.tar.gz
dist/*.whl
env:
GITHUB_TOKEN: ${{ secrets.repo-token }}
- name: Publish to PyPI
if: ${{ inputs.publish-to-pypi }}
env:
pypi_token: ${{ secrets.pypi-token }}
run: |
if [ -z "$pypi_token" ]; then
echo "No PyPI token provided, skipping publish."
else
uv publish --token "$pypi_token"
fi