-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (54 loc) · 1.67 KB
/
Copy pathpublish.yml
File metadata and controls
57 lines (54 loc) · 1.67 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
name: publish
on:
release:
types: [published]
jobs:
build:
name: "Build distribution"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python 3.12
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install Poetry
uses: snok/install-poetry@a783c322200f0519c7926aa6faa857c4e23e9263 # v1
with:
version: "2.4.0"
- name: Check tag matches project version
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PROJECT_VERSION="$(poetry version --short)"
python3 -c "
import sys
norm = lambda v: '.'.join(str(int(p)) if p.isdigit() else p for p in v.split('.'))
tag, project = '$TAG_VERSION', '$PROJECT_VERSION'
if norm(tag) != norm(project):
print(f'Release tag ({tag}) does not match pyproject.toml version ({project})')
sys.exit(1)
"
- name: Build package
run: poetry build
- name: Store distribution artifacts
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
publish:
name: "Publish to PyPI"
runs-on: ubuntu-latest
needs: build
environment:
name: pypi
url: https://pypi.org/project/samples-python-template/
permissions:
id-token: write # required for PyPI trusted publishing (OIDC)
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1