Repository navigation
85 lines (70 loc) · 2.39 KB
/
Copy pathpython-publish.yml
File metadata and controls
85 lines (70 loc) · 2.39 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: Publish Python Package
on:
release:
types: [published]
permissions:
contents: read
jobs:
release-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
- name: "Set up Python"
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v6
with:
python-version-file: "pyproject.toml"
- name: Build
run: uv build
- name: Upload distributions
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: release-dists
path: dist/
pypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
permissions:
id-token: write
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
packages-dir: dist/
notify-failure:
if: failure()
runs-on: ubuntu-latest
needs:
- release-build
- pypi-publish
permissions:
issues: write
steps:
- name: Open and pin an issue for the failed publish
env:
ASSIGNEES: "ishymko,mykytanetipa"
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
printf '%s\n\n%s\n' \
"$TAG is not on PyPI. The publish workflow failed." \
"Failed run: $RUN_URL" > body.md
url="$(gh issue create --repo "$REPO" \
--title "Publish failed for $TAG" \
--label 'component: tooling' \
--body-file body.md)"
echo "Opened $url"
# Assigning and pinning must never discard the alert itself.
gh issue edit "$url" --add-assignee "$ASSIGNEES" \
|| echo "::warning::Could not assign $url"
gh issue pin "$url" \
|| echo "::warning::Could not pin $url. A repository allows at most 3 pinned issues."