-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (54 loc) · 1.88 KB
/
Copy pathshared-publish-package.yaml
File metadata and controls
63 lines (54 loc) · 1.88 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
name: Publish Package
on:
workflow_call:
inputs:
python-version:
description: 'Python version to use'
required: false
type: string
default: '3.11'
is-test-pypi:
description: 'Whether to publish to TestPyPI or PyPI'
required: false
type: boolean
default: true
outputs:
published-version:
description: 'The version that was published'
value: 'published'
jobs:
publish-package:
runs-on: macos-latest
environment: ${{ inputs.is-test-pypi && 'testpypi' || 'pypi-prod' }}
env:
pypi-repository: ${{ inputs.is-test-pypi && 'testpypi' || 'pypi' }}
permissions:
pull-requests: write
steps:
- name: 🐍 Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: 🚀 Install uv
uses: astral-sh/setup-uv@v8.1.0
- name: ⤵️ Download dist artifacts
uses: actions/download-artifact@v8
with:
name: python-package-dist
path: dist/
- name: Install Twine
run: uv pip install twine --system
- name: 📦 Publish to ${{ env.pypi-repository }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ inputs.is-test-pypi && secrets.TEST_PYPI_API_TOKEN || secrets.PYPI_API_TOKEN }}
run: twine upload --verbose --repository ${{ env.pypi-repository }} dist/*.whl dist/*.tar.gz
- name: Read version for comment
id: version_reader
run: echo "published_version=$(cat dist/VERSION.txt)" >> "$GITHUB_OUTPUT"
- name: 💬 Comment on PR with deployed version
if: github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v3
with:
message: |
Successfully published version **${{ steps.version_reader.outputs.published_version }}** to TestPyPI. 🚀