-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (81 loc) · 3.03 KB
/
Copy pathrelease.yml
File metadata and controls
85 lines (81 loc) · 3.03 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
name: Release
# Build, publish to PyPI, and create a GitHub Release when a v* tag is pushed.
#
# Concerns are split into three jobs, each with the minimum permissions it
# needs, so the powerful id-token (PyPI) and contents:write (repo) scopes never
# coexist in one job:
# build -> no special permissions
# publish-to-pypi -> id-token: write (Trusted Publishing / OIDC, no tokens)
# github-release -> contents: write (create the release + upload assets)
#
# One-time prerequisite on PyPI — add a "pending publisher" at
# https://pypi.org/manage/account/publishing/ matching:
# owner = minixalpha, repo = nanoPyCodeAgent,
# workflow = release.yml, environment = (leave blank; this workflow sets none).
on:
push:
tags:
- "v*"
jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # full history + tags so hatch-vcs can derive the version
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Build
run: uv build
- name: Check distribution metadata
run: uvx twine check dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
publish-to-pypi:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write # required for Trusted Publishing (OIDC)
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
# No checkout in this job, so the cache-dependency glob (pyproject.toml,
# uv.lock) matches nothing; uv publish needs no resolved-dep cache anyway.
enable-cache: false
- name: Publish to PyPI
# --check-url makes re-runs idempotent: files already on the index are
# skipped instead of failing the job on "file already exists".
run: uv publish --check-url https://pypi.org/simple/
github-release:
name: Create GitHub Release
needs: publish-to-pypi # only after a successful PyPI publish
runs-on: ubuntu-latest
permissions:
contents: write # required to create the release and upload assets
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
# --generate-notes builds notes from merged PRs since the previous tag;
# dist/* attaches the wheel and sdist as assets. Idempotent: skip if a
# release for this tag already exists, so re-runs don't fail.
run: |
gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 \
|| gh release create "$GITHUB_REF_NAME" dist/* --generate-notes