-
Notifications
You must be signed in to change notification settings - Fork 2
74 lines (61 loc) · 1.91 KB
/
Copy pathpython-publish.yml
File metadata and controls
74 lines (61 loc) · 1.91 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
# Publish Python Package to PyPI when a release is created
name: Publish to PyPI
on:
push:
tags:
- 'v*'
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@v7
- name: Install uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python 3.11
run: uv python install 3.11
# From the lock, like ci.yml and docs.yml. A release gate resolving fresh can
# pass or fail on what PyPI published that morning, which is the last place
# you want that.
- name: Install and test package
run: |
uv sync --locked --extra test --all-groups
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@v7
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v9.0.0
- 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.14.2
with:
repository-url: ${{ github.event.inputs.use_test_pypi == 'true' && 'https://test.pypi.org/legacy/' || '' }}