Skip to content

Commit ba22b45

Browse files
author
johnhuang316
committed
Add GitHub Actions workflow for automatic PyPI publishing
1 parent 8a4fa8f commit ba22b45

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.10'
17+
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install build twine
22+
23+
- name: Extract version from tag
24+
id: get_version
25+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
26+
27+
- name: Update version in files
28+
run: |
29+
# Update pyproject.toml version
30+
sed -i "s/^version = .*/version = \"${{ env.VERSION }}\"/" pyproject.toml
31+
32+
# Update __init__.py version
33+
sed -i "s/__version__ = .*/__version__ = \"${{ env.VERSION }}\"/" src/code_index_mcp/__init__.py
34+
35+
- name: Build package
36+
run: python -m build
37+
38+
- name: Check package
39+
run: twine check dist/*
40+
41+
- name: Publish to PyPI
42+
uses: pypa/gh-action-pypi-publish@release/v1
43+
with:
44+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)