Skip to content

Commit e37e5b9

Browse files
authored
Merge pull request #4 from constructive-io/devin/1769051159-readme-pgsql-test
Devin/1769051159 readme pgsql test
2 parents 8fd907f + 37d9937 commit e37e5b9

5 files changed

Lines changed: 646 additions & 18 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Pets Rollback Example
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}-pets-rollback
16+
cancel-in-progress: true
17+
18+
jobs:
19+
test-rollback:
20+
name: Test per-test rollback with pets example
21+
runs-on: ubuntu-latest
22+
23+
env:
24+
PGHOST: localhost
25+
PGPORT: 5432
26+
PGUSER: postgres
27+
PGPASSWORD: password
28+
29+
services:
30+
pg_db:
31+
image: ghcr.io/constructive-io/docker/postgres-plus:17
32+
env:
33+
POSTGRES_USER: postgres
34+
POSTGRES_PASSWORD: password
35+
options: >-
36+
--health-cmd pg_isready
37+
--health-interval 10s
38+
--health-timeout 5s
39+
--health-retries 5
40+
ports:
41+
- 5432:5432
42+
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: "3.12"
51+
52+
- name: Install Poetry
53+
uses: snok/install-poetry@v1
54+
with:
55+
version: latest
56+
virtualenvs-create: true
57+
virtualenvs-in-project: true
58+
59+
- name: Install dependencies
60+
run: poetry install
61+
62+
- name: Run pets rollback example tests
63+
run: poetry run pytest tests/test_pets_rollback.py -v

PUBLISHING.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Publishing to PyPI
2+
3+
This guide explains how to publish `pgsql-test` to PyPI using Poetry.
4+
5+
## Prerequisites
6+
7+
1. **PyPI Account**: Create an account at https://pypi.org/account/register/
8+
2. **API Token**: Generate an API token at https://pypi.org/manage/account/token/
9+
3. **Poetry**: Already installed if you've been developing locally
10+
11+
## One-Time Setup
12+
13+
Configure Poetry with your PyPI token:
14+
15+
```bash
16+
poetry config pypi-token.pypi <your-token>
17+
```
18+
19+
Alternatively, you can use environment variables:
20+
21+
```bash
22+
export POETRY_PYPI_TOKEN_PYPI=<your-token>
23+
```
24+
25+
## Publishing Steps
26+
27+
### 1. Update Version
28+
29+
Update the version in `pyproject.toml`:
30+
31+
```toml
32+
[tool.poetry]
33+
name = "pgsql-test"
34+
version = "0.1.1" # Bump this
35+
```
36+
37+
Or use Poetry's version command:
38+
39+
```bash
40+
# Bump patch version (0.1.0 -> 0.1.1)
41+
poetry version patch
42+
43+
# Bump minor version (0.1.0 -> 0.2.0)
44+
poetry version minor
45+
46+
# Bump major version (0.1.0 -> 1.0.0)
47+
poetry version major
48+
49+
# Set specific version
50+
poetry version 1.0.0
51+
```
52+
53+
### 2. Run Tests
54+
55+
Ensure all tests pass before publishing:
56+
57+
```bash
58+
poetry run pytest -v
59+
poetry run ruff check .
60+
poetry run mypy src --ignore-missing-imports
61+
```
62+
63+
### 3. Build the Package
64+
65+
```bash
66+
poetry build
67+
```
68+
69+
This creates distribution files in the `dist/` directory:
70+
- `pgsql_test-0.1.1.tar.gz` (source distribution)
71+
- `pgsql_test-0.1.1-py3-none-any.whl` (wheel)
72+
73+
### 4. Publish to PyPI
74+
75+
```bash
76+
poetry publish
77+
```
78+
79+
Or build and publish in one command:
80+
81+
```bash
82+
poetry publish --build
83+
```
84+
85+
## Testing with TestPyPI
86+
87+
Before publishing to the real PyPI, you can test with TestPyPI:
88+
89+
### 1. Create TestPyPI Account
90+
91+
Register at https://test.pypi.org/account/register/
92+
93+
### 2. Configure TestPyPI
94+
95+
```bash
96+
poetry config repositories.testpypi https://test.pypi.org/legacy/
97+
poetry config pypi-token.testpypi <your-testpypi-token>
98+
```
99+
100+
### 3. Publish to TestPyPI
101+
102+
```bash
103+
poetry publish --build -r testpypi
104+
```
105+
106+
### 4. Test Installation
107+
108+
```bash
109+
pip install --index-url https://test.pypi.org/simple/ pgsql-test
110+
```
111+
112+
## GitHub Actions Automation
113+
114+
To automate publishing on releases, add this workflow to `.github/workflows/publish.yml`:
115+
116+
```yaml
117+
name: Publish to PyPI
118+
119+
on:
120+
release:
121+
types: [published]
122+
123+
jobs:
124+
publish:
125+
runs-on: ubuntu-latest
126+
steps:
127+
- uses: actions/checkout@v4
128+
129+
- name: Set up Python
130+
uses: actions/setup-python@v5
131+
with:
132+
python-version: "3.12"
133+
134+
- name: Install Poetry
135+
uses: snok/install-poetry@v1
136+
137+
- name: Build and publish
138+
env:
139+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
140+
run: poetry publish --build
141+
```
142+
143+
Then add your PyPI token as a repository secret named `PYPI_TOKEN`.
144+
145+
## Versioning Guidelines
146+
147+
Follow [Semantic Versioning](https://semver.org/):
148+
149+
- **MAJOR** (1.0.0): Breaking changes to the public API
150+
- **MINOR** (0.1.0): New features, backwards compatible
151+
- **PATCH** (0.0.1): Bug fixes, backwards compatible
152+
153+
For pre-release versions:
154+
- `0.1.0a1` - Alpha release
155+
- `0.1.0b1` - Beta release
156+
- `0.1.0rc1` - Release candidate
157+
158+
## Checklist Before Publishing
159+
160+
- [ ] All tests pass locally
161+
- [ ] Version number updated in `pyproject.toml`
162+
- [ ] CHANGELOG updated (if you have one)
163+
- [ ] README is up to date
164+
- [ ] Commit and push all changes
165+
- [ ] Create a git tag for the release
166+
167+
```bash
168+
git tag v0.1.1
169+
git push origin v0.1.1
170+
```
171+
172+
## Troubleshooting
173+
174+
### "File already exists" Error
175+
176+
PyPI doesn't allow overwriting existing versions. You must bump the version number.
177+
178+
### Authentication Failed
179+
180+
Verify your token is correct:
181+
182+
```bash
183+
poetry config pypi-token.pypi --unset
184+
poetry config pypi-token.pypi <new-token>
185+
```
186+
187+
### Package Name Conflict
188+
189+
If `pgsql-test` is taken, you may need to use a different name like `pgsql-test-py` or `constructive-pgsql-test`.

0 commit comments

Comments
 (0)