-
Notifications
You must be signed in to change notification settings - Fork 2
70 lines (57 loc) · 1.71 KB
/
python-publish.yml
File metadata and controls
70 lines (57 loc) · 1.71 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
# Publish Python Package to PyPI when a release is created
name: Publish to PyPI
on:
release:
types: [published]
workflow_dispatch:
inputs:
use_test_pypi:
description: 'Publish to Test PyPI instead of PyPI'
required: false
default: false
type: boolean
permissions:
contents: read
id-token: write # Required for trusted publishing
jobs:
test-before-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Set up Python 3.11
run: |
uv python install 3.11
uv venv
- name: Install and test package
run: |
uv pip install -e .[test]
uv run pytest tests/ --tb=short -q
publish:
runs-on: ubuntu-latest
needs: test-before-publish
environment:
name: ${{ github.event.inputs.use_test_pypi == 'true' && 'test-pypi' || 'pypi' }}
url: ${{ github.event.inputs.use_test_pypi == 'true' && 'https://test.pypi.org/p/allocator' || 'https://pypi.org/p/allocator' }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python 3.11
run: |
uv python install 3.11
uv venv
- name: Build package
run: |
uv build
- name: Check package quality
run: |
uv tool run twine check dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.13.0
with:
repository-url: ${{ github.event.inputs.use_test_pypi == 'true' && 'https://test.pypi.org/legacy/' || '' }}