Skip to content

Commit 2467a4a

Browse files
committed
ci(workflow): create python-publish.yml
1 parent 08782f6 commit 2467a4a

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# This workflow will upload a Python Package to PyPI when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
release-build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.x"
28+
29+
- name: Build release distributions
30+
run: |
31+
# NOTE: put your own distribution build steps here.
32+
# python -m pip install build
33+
# python -m build
34+
pip install uv
35+
uv build
36+
37+
- name: Upload distributions
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: release-dists
41+
path: dist/
42+
43+
pypi-publish:
44+
runs-on: ubuntu-latest
45+
needs:
46+
- release-build
47+
permissions:
48+
# IMPORTANT: this permission is mandatory for trusted publishing
49+
id-token: write
50+
51+
# Dedicated environments with protections for publishing are strongly recommended.
52+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
53+
environment:
54+
name: pypi
55+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
56+
# url: https://pypi.org/p/YOURPROJECT
57+
#
58+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
59+
# ALTERNATIVE: exactly, uncomment the following line instead:
60+
url: https://pypi.org/project/plotfig/${{ github.event.release.name }}
61+
62+
steps:
63+
- name: Retrieve release distributions
64+
uses: actions/download-artifact@v4
65+
with:
66+
name: release-dists
67+
path: dist/
68+
69+
- name: Publish release distributions to PyPI
70+
uses: pypa/gh-action-pypi-publish@release/v1
71+
with:
72+
packages-dir: dist/

0 commit comments

Comments
 (0)