Skip to content

Commit ec899d1

Browse files
author
esfiam
committed
πŸš€ Add GitHub Actions workflow for PyPI publishing
- Automated testing on Python 3.7-3.12 - Build and publish to PyPI on tag creation - Uses trusted publishers for secure deployment - Workflow: test β†’ build β†’ publish
1 parent 7b552ed commit ec899d1

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

β€Ž.github/workflows/publish.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install pytest
27+
28+
- name: Test package
29+
run: |
30+
python -c "import smartlogger.auto; print('Import successful')"
31+
python demo_smartlogger.py
32+
python -m pytest tests/ -v
33+
34+
build:
35+
needs: test
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Set up Python
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: '3.11'
45+
46+
- name: Install build dependencies
47+
run: |
48+
python -m pip install --upgrade pip
49+
pip install build
50+
51+
- name: Build package
52+
run: python -m build
53+
54+
- name: Upload artifacts
55+
uses: actions/upload-artifact@v3
56+
with:
57+
name: dist
58+
path: dist/
59+
60+
publish:
61+
needs: build
62+
runs-on: ubuntu-latest
63+
permissions:
64+
id-token: write
65+
66+
steps:
67+
- name: Download artifacts
68+
uses: actions/download-artifact@v3
69+
with:
70+
name: dist
71+
path: dist/
72+
73+
- name: Publish to PyPI
74+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
Β (0)