Repository navigation
74 lines (64 loc) · 1.8 KB
/
Copy pathpublish.yaml
File metadata and controls
74 lines (64 loc) · 1.8 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
name: Publish Python Package to PyPI
on:
workflow_dispatch:
# push:
# branches:
# - main
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Setup uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d
- name: Get version from pyproject.toml
id: get-version
run: |
VERSION=$(python setup.py --version)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Found version: $VERSION"
- name: Build package
run: uv build
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/
create-release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v7
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ needs.build.outputs.version }}" \
--title "Release v${{ needs.build.outputs.version }}" \
--draft=false \
--prerelease=false
publish:
runs-on: ubuntu-latest
needs: [build, create-release]
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1