Skip to content

Commit 684c358

Browse files
committed
✨ publish action updated
1 parent 15620ab commit 684c358

File tree

1 file changed

+41
-25
lines changed

1 file changed

+41
-25
lines changed

.github/workflows/publish.yml

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,48 @@
1-
name: Publish Python Package
1+
name: Build and Publish Python Package
22

33
on:
4-
release:
5-
types: [published]
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
612

713
jobs:
814
publish:
9-
runs-on: ubuntu-latest
15+
if: contains(github.event.head_commit.message, 'publish:')
16+
runs-on: "ubuntu-latest"
17+
18+
permissions:
19+
contents: "read"
20+
id-token: "write"
1021

1122
steps:
12-
- name: Check out the code
13-
uses: actions/checkout@v2
14-
15-
- name: Set up Python
16-
uses: actions/setup-python@v2
17-
with:
18-
python-version: '3.12'
19-
20-
- name: Install dependencies
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install setuptools wheel twine
24-
25-
- name: Build the package
26-
run: python setup.py sdist bdist_wheel
27-
28-
- name: Publish to PyPI
29-
env:
30-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
31-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
32-
run: twine upload dist/*
23+
# 1. Checkout repo
24+
- name: Checkout repository
25+
uses: actions/checkout@v3
26+
27+
# 2. Set Python version
28+
- name: Set up Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: "3.12"
32+
33+
# 3. Install build tools
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install setuptools wheel twine
38+
39+
# 4. Build package
40+
- name: Build package
41+
run: "python setup.py sdist bdist_wheel"
42+
43+
# 5. Publish to PyPI using token
44+
- name: Publish to PyPI
45+
env:
46+
TWINE_USERNAME: "__token__"
47+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
48+
run: "twine upload dist/*"

0 commit comments

Comments
 (0)