1- ---
21name : Publish Python Package
32
4- # Publishes with trusted publishing to
5- # - PyPI on releases created in GitHub UI if status is published.
6- # For draft status, nothing happens.
7- # - TestPyPI on new tags "v1.2.3" or "v1.2.3.something" on main branch
8- #
9- # More on trusted publishing: https://docs.pypi.org/trusted-publishers/
10-
11- on : # yamllint disable-line rule:truthy
12- push :
13- tags :
14- # GitHub glob matching is limited [1]. So we can't define a pattern matching
15- # pep 440 version definition [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
16- - ' v[0-9]+.[0-9]+.[0-9]+.?*'
17- - ' v[0-9]+.[0-9]+.[0-9]+rc[0-9]'
3+ on :
4+ workflow_dispatch :
185 release :
19- types : [published]
20-
21- permissions : {}
6+ types : [created]
227
238jobs :
24- build :
25- name : Build Python 🐍 distributions 📦 for publishing
9+ build-n-publish :
10+ name : Build and publish Python 🐍 distributions 📦 to PyPI
2611 runs-on : ubuntu-latest
27-
12+ environment : release
13+ permissions :
14+ id-token : write
2815 steps :
29- # https://github.com/actions/checkout
30- - name : Check out repository
31- uses : actions/checkout@v4.2.2
32- with :
33- persist-credentials : false
16+ - uses : actions/checkout@v4
3417
35- # https://github.com/astral-sh/setup-uv
3618 - name : Install uv
37- uses : astral-sh/setup-uv@v6.4.3
38- with :
39- python-version : 3.13
40- enable-cache : true
19+ uses : astral-sh/setup-uv@v6
4120
42- # https://github.com/actions/setup-python
4321 - name : Set up Python
44- uses : actions/setup-python@v5.6.0
22+ uses : actions/setup-python@v5
4523 with :
46- python-version : 3.13
24+ python-version : ' 3.12 '
4725
48- - name : Install just
49- run : |
50- uv tool install rust-just
26+ - name : Install dependencies
27+ run : uv sync --all-extras
5128
5229 - name : Build source and wheel archives
5330 run : uv build
5431
55- # https://github.com/actions/upload-artifact
56- - name : Store built distribution
57- uses : actions/upload-artifact@v4.6.2
58- with :
59- name : distribution-files
60- path : dist/
61-
62- pypi-publish :
63- name : Build and publish Python 🐍 package 📦 to PyPI and TestPyPI
64- needs : build
65- runs-on : ubuntu-latest
66- environment :
67- name : pypi-release
68- url : https://pypi.org/p/valuesets
69- permissions :
70- id-token : write # this permission is mandatory for trusted publishing
71- steps :
72- # https://github.com/actions/download-artifact
73- - name : Download built distribution
74- uses : actions/download-artifact@v4.3.0
75- with :
76- name : distribution-files
77- path : dist
78-
79- # https://github.com/pypa/gh-action-pypi-publish
80- - name : Publish package 📦 to Test PyPI
81- if : github.event_name == 'push'
82- uses : pypa/gh-action-pypi-publish@v1.12.4
83- with :
84- repository-url : https://test.pypi.org/legacy/
85- verbose : true
86-
87- - name : Publish package 📦 to PyPI
88- if : github.event_name == 'release'
89- uses : pypa/gh-action-pypi-publish@v1.12.4
32+ - name : Publish
33+ uses : pypa/gh-action-pypi-publish@release/v1
9034 with :
91- verbose : true
92-
93- # [1] https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
94- # Used actions: (updates managed by dependabot)
95- # - https://github.com/actions/checkout
96- # - https://github.com/astral-sh/setup-uv
97- # - https://github.com/actions/setup-python
98- # - https://github.com/actions/upload-artifact
99- # - https://github.com/actions/download-artifact
100- # - https://github.com/pypa/gh-action-pypi-publish/
35+ verbose : true
0 commit comments