-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (92 loc) · 3.04 KB
/
release-python.yml
File metadata and controls
113 lines (92 loc) · 3.04 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# .github/workflows/release-python.yml
# See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Release Python Package
on:
push:
branches:
- main
- master
workflow_dispatch:
jobs:
get_tag:
name: Get Tag
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.current_version.outputs.CURRENT_VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".github/workflows/.python-version"
- name: Get Current Version
id: current_version
run: echo "CURRENT_VERSION=v$(uvx --from commitizen cz version -p)" >> $GITHUB_OUTPUT
build_and_testpypi:
name: Build & Publish to TestPyPI
runs-on: ubuntu-latest
needs: get_tag
outputs:
tag: ${{ needs.get_tag.outputs.tag }}
permissions:
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".github/workflows/.python-version"
- name: Run package build
run: uvx nox -s build-python
- name: Upload built package artifacts
uses: actions/upload-artifact@v4
with:
name: distribution-packages-${{ needs.get_tag.outputs.tag }}
path: dist/
retention-days: 7
- name: Download built package artifacts
uses: actions/download-artifact@v4
with:
name: distribution-packages-${{ needs.get_tag.outputs.tag }}
path: dist/
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
publish_pypi_and_github:
name: Publish to Production PyPI and GitHub
runs-on: ubuntu-latest
needs: build_and_testpypi
permissions:
id-token: write
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".github/workflows/.python-version"
- name: Set up uv
uses: astral-sh/setup-uv@v6
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
name: distribution-packages-${{ needs.build_and_testpypi.outputs.tag }}
path: dist/
- name: Create Tag
run: |
git tag ${{ needs.build_and_testpypi.outputs.tag }}
git push origin ${{ needs.build_and_testpypi.outputs.tag }}
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish to GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ needs.build_and_testpypi.outputs.tag }} dist/* --clobber