-
Notifications
You must be signed in to change notification settings - Fork 19
89 lines (74 loc) · 2.33 KB
/
Copy pathrelease.yml
File metadata and controls
89 lines (74 loc) · 2.33 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
name: Release
on:
workflow_dispatch:
inputs:
subpackage:
description: Package name under packages/
required: true
type: string
version:
description: PEP 440 version to publish
required: true
type: string
permissions:
contents: read
concurrency:
group: release-${{ inputs.subpackage }}
cancel-in-progress: false
jobs:
publish:
name: Publish ${{ inputs.subpackage }} ${{ inputs.version }}
runs-on: ubuntu-latest
timeout-minutes: 15
environment:
name: pypi
permissions:
contents: read
id-token: write
env:
SUBPACKAGE: ${{ inputs.subpackage }}
VERSION: ${{ inputs.version }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
steps:
- name: Validate release inputs
shell: bash
run: |
set -euo pipefail
if [[ "$GITHUB_REF" != "refs/heads/$DEFAULT_BRANCH" ]]; then
echo "::error::Releases must run from the default branch: $DEFAULT_BRANCH"
exit 1
fi
if [[ ! "$SUBPACKAGE" =~ ^[a-z0-9]+(-[a-z0-9]+)*$ ]]; then
echo "::error::Invalid subpackage name: $SUBPACKAGE"
exit 1
fi
- name: Checkout
uses: actions/checkout@v6
- name: Set up Python and uv
uses: astral-sh/setup-uv@v8.1.0
with:
python-version: "3.12"
- name: Validate package
shell: bash
run: |
set -euo pipefail
package_file="packages/$SUBPACKAGE/pyproject.toml"
if [[ ! -f "$package_file" ]]; then
echo "::error::Subpackage does not exist: $SUBPACKAGE"
exit 1
fi
project_name="$(
python -c \
'import sys, tomllib; print(tomllib.load(open(sys.argv[1], "rb"))["project"]["name"])' \
"$package_file"
)"
if [[ "$project_name" != "$SUBPACKAGE" ]]; then
echo "::error::Directory name does not match project.name: $project_name"
exit 1
fi
- name: Set version
run: uv version --package "$SUBPACKAGE" --frozen "$VERSION"
- name: Build package
run: uv build --package "$SUBPACKAGE" --out-dir dist --clear
- name: Publish package
run: uv publish --trusted-publishing always dist/*