-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (64 loc) · 2.2 KB
/
Copy pathcd.yml
File metadata and controls
76 lines (64 loc) · 2.2 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
name: Publish to PyPI
on:
workflow_dispatch:
# Deny-by-default at workflow level; each job opts into exactly what it needs.
# Flagged by CodeQL `actions/missing-workflow-permissions`.
permissions:
contents: read
concurrency:
group: deploy
cancel-in-progress: false
jobs:
ci:
uses: ./.github/workflows/ci.yml
publish:
needs: ci
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@v6
with:
fetch-tags: true
- uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: pip
cache-dependency-path: pyproject.toml
- name: Extract version
id: pkg
run: |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Publishing v$VERSION"
- name: Version guard
run: |
if git rev-parse "v${{ steps.pkg.outputs.version }}" >/dev/null 2>&1; then
echo "::error::Tag v${{ steps.pkg.outputs.version }} already exists. Bump the version first."
exit 1
fi
- name: Build
run: |
python -m pip install --upgrade pip
python -m pip install build
python -m build
- name: Generate SLSA build provenance attestation
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
with:
subject-path: 'dist/*'
- name: Publish to PyPI
# Floating `release/v1` is pypa's documented pin; the action self-updates within v1.
# OIDC trusted publishing — configure at:
# https://pypi.org/manage/project/my-mcp-server/settings/publishing/
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
- name: Create GitHub Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
tag_name: v${{ steps.pkg.outputs.version }}
name: v${{ steps.pkg.outputs.version }}
generate_release_notes: true