Repository navigation
110 lines (95 loc) · 3.67 KB
/
Copy pathrelease.yaml
File metadata and controls
110 lines (95 loc) · 3.67 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Release Please
on:
push:
branches:
- main
# Two merges in quick succession would otherwise start two runs that both mutate
# the release PR and, across a tag boundary, both reach `uv publish`. Queue rather
# than cancel: cancelling a half-finished publish is worse than waiting.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
release-please:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
id: release
with:
config-file: .release-please-config.json
manifest-file: .release-please-manifest.json
# State which branch was taken. Every later step keys on these outputs, so if
# release-please ever renames them the run would otherwise go green having
# silently done nothing.
- name: Report release-please outcome
run: |
echo "release_created=${{ steps.release.outputs.release_created }}"
echo "pr_updated=${{ steps.release.outputs.pr != '' }}"
# Update uv.lock when release PR is created/updated
- name: Checkout repository (for PR update)
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: ${{ steps.release.outputs.pr }}
with:
ref: ${{ fromJSON(steps.release.outputs.pr).headBranchName }}
- name: Setup uv (for PR update)
if: ${{ steps.release.outputs.pr }}
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
- name: Update uv.lock
if: ${{ steps.release.outputs.pr }}
run: |
uv lock
if git diff --quiet uv.lock; then
echo "uv.lock is already up to date"
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add uv.lock
git commit -m "chore: update uv.lock"
git push
fi
# Publishing lives in its own job so it can be gated. It previously ran in the
# release-please job with no dependency on CI at all: CI is a separate workflow,
# so a red main still merged the release PR and shipped to PyPI. The suite runs
# again here against the exact commit being published.
publish:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
# Configure a required reviewer on this environment in the repository settings.
environment: pypi
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Setup uv
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
python-version: "3.13"
- name: Setup pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- name: Setup Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: package.json
- name: Install dependencies
run: |
uv sync --all-extras --locked
pnpm install --frozen-lockfile
- name: Test the commit being published
run: uv run pytest
- name: Build and publish package
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
uv build
uv publish