-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (61 loc) · 2.37 KB
/
pypi-publish.yml
File metadata and controls
71 lines (61 loc) · 2.37 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
name: Publish Python Package
# Publishes to
# - TestPyPI on new tags "v1.2.3" or "v1.2.3.something" on main branch
# - PyPI on releases created in GitHub UI
on:
push:
tags:
# GitHub glob matching is limited [1]. So we can't define a pattern matching
# pep 440 version definition [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
- 'v[0-9]+.[0-9]+.[0-9]+.?*'
release:
types: [published]
jobs:
build:
name: Build Python 🐍 distributions 📦 for publishing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
- name: Set up Python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
with:
python-version: 3.12
- name: Install uv
run: pipx install uv
- name: Build source and wheel archives
run: uvx --from build pyproject-build --installer uv
- name: Store built distribution
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
with:
name: distribution-files
path: dist/
pypi-publish:
name: Build and publish Python 🐍 package 📦 to PyPI and TestPyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi-release
url: https://pypi.org/p/cared-cli/
permissions:
id-token: write # this permission is mandatory for trusted publishing
steps:
- name: Download built distribution
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
with:
name: distribution-files
path: dist
- name: Publish package 📦 to Test PyPI
if: github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish package 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
# [1] https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
# Used actions: (updates managed by dependabot)
# - https://github.com/actions/checkout
# - https://github.com/actions/setup-python
# - https://github.com/actions/upload-artifact
# - https://github.com/actions/download-artifact
# - https://github.com/pypa/gh-action-pypi-publish/