Skip to content

Commit 23f07b5

Browse files
Add PyPI publishing infrastructure
- Add GitHub Actions workflow for automated PyPI publishing on release - Add PUBLISHING.md with publishing documentation - Uses trusted publishing (no tokens needed) Supersedes PR #9 (Copilot's fix) - main already has package fix from 6a55406 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b716d7d commit 23f07b5

File tree

2 files changed

+175
-0
lines changed

2 files changed

+175
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch: # Allow manual triggering
7+
8+
jobs:
9+
build-and-publish:
10+
name: Build and publish to PyPI
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write # Required for trusted publishing
14+
contents: read
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.12'
24+
25+
- name: Install build dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install build
29+
30+
- name: Build package
31+
run: python -m build
32+
33+
- name: Publish to PyPI
34+
uses: pypa/gh-action-pypi-publish@release/v1
35+
with:
36+
# Uses trusted publishing - no token needed
37+
# Configure at https://pypi.org/manage/account/publishing/
38+
print-hash: true

PUBLISHING.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Publishing to PyPI
2+
3+
This document explains how to publish the `i2i-mcip` package to PyPI.
4+
5+
## Prerequisites
6+
7+
Before publishing, ensure:
8+
1. You have maintainer access to the PyPI project
9+
2. The package version has been updated in `pyproject.toml`
10+
3. All tests pass
11+
4. The changelog has been updated
12+
13+
## Publishing Methods
14+
15+
### Method 1: Automated Publishing via GitHub Releases (Recommended)
16+
17+
The easiest way to publish is to create a GitHub release. This will automatically trigger the publishing workflow.
18+
19+
1. **Update the version** in `pyproject.toml`:
20+
```toml
21+
[project]
22+
name = "i2i-mcip"
23+
version = "0.2.0" # Update this
24+
```
25+
26+
2. **Commit and push** your changes:
27+
```bash
28+
git add pyproject.toml
29+
git commit -m "Bump version to 0.2.0"
30+
git push
31+
```
32+
33+
3. **Create a new release** on GitHub:
34+
- Go to https://github.com/lancejames221b/i2i/releases/new
35+
- Create a new tag (e.g., `v0.2.0`)
36+
- Fill in the release title and description
37+
- Click "Publish release"
38+
39+
4. **Monitor the workflow**:
40+
- Go to the Actions tab
41+
- Watch the "Publish to PyPI" workflow
42+
- Once complete, verify the package on https://pypi.org/project/i2i-mcip/
43+
44+
### Method 2: Manual Publishing
45+
46+
If you need to publish manually:
47+
48+
1. **Install build tools**:
49+
```bash
50+
pip install build twine
51+
```
52+
53+
2. **Build the package**:
54+
```bash
55+
python -m build
56+
```
57+
58+
3. **Check the distribution**:
59+
```bash
60+
twine check dist/*
61+
```
62+
63+
4. **Upload to PyPI**:
64+
```bash
65+
# For TestPyPI (testing):
66+
twine upload --repository testpypi dist/*
67+
68+
# For production PyPI:
69+
twine upload dist/*
70+
```
71+
72+
## Setting Up Trusted Publishing (First Time Only)
73+
74+
For automated publishing to work, you need to configure trusted publishing on PyPI:
75+
76+
1. **Go to PyPI**:
77+
- Visit https://pypi.org/manage/account/publishing/
78+
- Log in with your PyPI account
79+
80+
2. **Add a new publisher**:
81+
- Project name: `i2i-mcip`
82+
- Owner: `lancejames221b`
83+
- Repository name: `i2i`
84+
- Workflow name: `publish-to-pypi.yml`
85+
- Environment name: (leave blank)
86+
87+
3. **Save** the publisher configuration
88+
89+
This allows GitHub Actions to publish without needing API tokens.
90+
91+
## Version Numbering
92+
93+
We follow [Semantic Versioning](https://semver.org/):
94+
95+
- **MAJOR** (1.0.0): Breaking changes
96+
- **MINOR** (0.1.0): New features, backwards compatible
97+
- **PATCH** (0.0.1): Bug fixes
98+
99+
## Testing the Package
100+
101+
Before publishing, test the package locally:
102+
103+
```bash
104+
# Build the package
105+
python -m build
106+
107+
# Install locally
108+
pip install dist/i2i_mcip-*.whl
109+
110+
# Test imports
111+
python -c "from i2i import AICP; print('Success!')"
112+
113+
# Uninstall
114+
pip uninstall i2i-mcip
115+
```
116+
117+
## Troubleshooting
118+
119+
### Package Already Exists
120+
- You cannot re-upload the same version
121+
- Bump the version number and rebuild
122+
123+
### Authentication Errors
124+
- For manual publishing, ensure your PyPI credentials are correct
125+
- For automated publishing, verify trusted publishing is configured
126+
127+
### Build Errors
128+
- Ensure all dependencies are listed in `pyproject.toml`
129+
- Check that the hatch build configuration is correct
130+
131+
## Post-Publishing Checklist
132+
133+
After publishing:
134+
- [ ] Verify the package appears on https://pypi.org/project/i2i-mcip/
135+
- [ ] Test installation: `pip install i2i-mcip`
136+
- [ ] Update GitHub release notes if needed
137+
- [ ] Announce the release (Twitter, blog, etc.)

0 commit comments

Comments
 (0)