Skip to content

Commit ca74cb9

Browse files
committed
feat: added pypi publishing
1 parent 0c95775 commit ca74cb9

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

.github/workflows/publish.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build and Publish to PyPI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- 'v*'
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
name: Build distribution
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.x'
25+
26+
- name: Install build dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install build
30+
31+
- name: Build package
32+
run: python -m build
33+
34+
- name: Store the distribution packages
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: python-package-distributions
38+
path: dist/
39+
40+
publish-to-pypi:
41+
name: Publish to PyPI
42+
needs: build
43+
runs-on: ubuntu-latest
44+
environment:
45+
name: pypi
46+
url: https://pypi.org/p/llm_session
47+
permissions:
48+
id-token: write
49+
50+
steps:
51+
- name: Download all the dists
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: python-package-distributions
55+
path: dist/
56+
57+
- name: Publish distribution to PyPI
58+
uses: pypa/gh-action-pypi-publish@release/v1
59+
60+
publish-to-testpypi:
61+
name: Publish to TestPyPI
62+
needs: build
63+
runs-on: ubuntu-latest
64+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
65+
environment:
66+
name: testpypi
67+
url: https://test.pypi.org/p/llm_session
68+
permissions:
69+
id-token: write
70+
71+
steps:
72+
- name: Download all the dists
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: python-package-distributions
76+
path: dist/
77+
78+
- name: Publish distribution to TestPyPI
79+
uses: pypa/gh-action-pypi-publish@release/v1
80+
with:
81+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)