Repository navigation
96 lines (83 loc) · 3.01 KB
/
Copy pathpython-publish.yml
File metadata and controls
96 lines (83 loc) · 3.01 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Publish to PyPI
# Tag-driven only. There is deliberately no workflow_dispatch: a manual
# trigger publishes whatever is on the runner, with no gate. Every release
# before 0.10.0 shipped that way. Releases now come from a v* tag, which
# comes from main, which CI gates.
#
# The filename is load-bearing: the PyPI trusted publisher is keyed to
# python-publish.yml. See py-canon STANDARD.md "Legacy publishers" -- keeping
# the legacy name means no pypi.org change is needed. py-canon normally splits
# build/release into a reusable workflow and leaves only publish here, but that
# needs cross-workflow artifact passing, so all three jobs are inlined instead.
on:
push:
tags: ["v*"]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
- name: Build distributions
run: uv build --no-sources
- name: Check metadata
run: uvx twine check dist/*
# Prevent a mistagged release from publishing the wrong project version.
- name: Confirm the built version matches the tag
run: |
set -euo pipefail
shopt -s nullglob
wheels=(dist/*.whl)
if [ ${#wheels[@]} -ne 1 ]; then
echo "::error::expected exactly one wheel, found ${#wheels[@]}"
exit 1
fi
name="${wheels[0]##*/}"
built="${name#rmcp-}"
built="${built%-py3-none-any.whl}"
expected="${GITHUB_REF_NAME#v}"
echo "tag=$expected built=$built"
if [ "$built" != "$expected" ]; then
echo "::error::Built version $built does not match tag $expected"
exit 1
fi
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
environment: pypi
permissions:
id-token: write # trusted publishing + attestations
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- name: Publish (trusted publishing, PEP 740 attestations)
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
with:
attestations: true
github-release:
needs: [build, publish]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- name: Create GitHub Release with generated notes
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" dist/* \
--repo "$GITHUB_REPOSITORY" --generate-notes --verify-tag