Skip to content

Commit 299d169

Browse files
authored
Update python-publish.yml
1 parent 6608a35 commit 299d169

File tree

1 file changed

+33
-56
lines changed

1 file changed

+33
-56
lines changed

.github/workflows/python-publish.yml

Lines changed: 33 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,42 @@
66
# separate terms of service, privacy policy, and support
77
# documentation.
88

9-
name: chordspy
9+
name: Publish Python Package
1010

1111
on:
12-
release:
13-
types: [published]
14-
15-
permissions:
16-
contents: read
12+
push:
13+
tags:
14+
- "v0.1.0
1715
1816
jobs:
19-
release-build:
17+
build-n-publish:
2018
runs-on: ubuntu-latest
21-
2219
steps:
23-
- uses: actions/checkout@v4
24-
25-
- uses: actions/setup-python@v5
26-
with:
27-
python-version: "3.13"
28-
29-
- name: Build release distributions
30-
run: |
31-
# NOTE: put your own distribution build steps here.
32-
python -m pip install build
33-
python -m build
34-
35-
- name: Upload distributions
36-
uses: actions/upload-artifact@v4
37-
with:
38-
name: release-dists
39-
path: dist/
40-
41-
pypi-publish:
42-
runs-on: ubuntu-latest
43-
needs:
44-
- release-build
45-
permissions:
46-
# IMPORTANT: this permission is mandatory for trusted publishing
47-
id-token: write
48-
49-
# Dedicated environments with protections for publishing are strongly recommended.
50-
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
51-
environment:
52-
name: pypi
53-
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
54-
# url: https://pypi.org/p/YOURPROJECT
55-
#
56-
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
57-
# ALTERNATIVE: exactly, uncomment the following line instead:
58-
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
59-
60-
steps:
61-
- name: Retrieve release distributions
62-
uses: actions/download-artifact@v4
63-
with:
64-
name: release-dists
65-
path: dist/
66-
67-
- name: Publish release distributions to PyPI
68-
uses: pypa/gh-action-pypi-publish@release/v1
69-
with:
70-
packages-dir: dist/
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.x'
26+
27+
- name: Install build dependencies
28+
run: python -m pip install --upgrade pip setuptools wheel build twine
29+
30+
- name: Build package
31+
run: python -m build
32+
33+
- name: Verify package
34+
run: twine check dist/*
35+
36+
- name: Publish to PyPI
37+
uses: pypa/gh-action-pypi-publish@release/v1
38+
with:
39+
password: ${{ secrets.PYPI_API_TOKEN }}
40+
41+
- name: Create GitHub Release
42+
uses: softprops/action-gh-release@v1
43+
with:
44+
files: dist/*
45+
generate_release_notes: true
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)