Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 48 additions & 6 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ name: Python application
on: [push, pull_request]

jobs:
build:

test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for versioning

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'

Expand All @@ -37,14 +38,55 @@ jobs:
run: |
uv run pytest --reruns 3 # githubs playwright sometimes fails

publish:
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write # Allows pushing tags

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for versioning
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install UV
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
uv sync

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
tag_prefix: v

- name: Build package
if: github.ref == 'refs/heads/main'
run: |
uv build

- name: Publish package to PyPI
if: github.ref == 'refs/heads/main'
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
uv publish

- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Dockerfile
example.py

# Auto-generated version file
hstream/_version.py

.*pyc
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
47 changes: 43 additions & 4 deletions CONTRIBUTE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,54 @@
## Deploy

1. increment version in `setup.py`
We use automatic versioning and deployment with hatch-vcs and GitHub Actions.

2. `rm -rf build/ hstream.egg-info/ dist/`
### How It Works:

3. `pip install twine build`
```
Push to main → Tests pass → Auto-create tag → Build with version → Publish to PyPI → Create GitHub release
```

4. `python -m build`
Every push to the main branch will:
1. Run all tests
2. Automatically create a new git tag (patch version bump: v0.1.58 → v0.1.59)
3. Build the package with the version from the tag
4. Publish to PyPI automatically
5. Create a GitHub release with changelog

### Important: Initial Setup Needed

Before the auto-versioning works, you need to create an initial tag:

```bash
# Switch to main branch and create initial tag
git checkout main
git tag v0.1.58 # Use the next version number
git push origin v0.1.58
```

After that, every push to main will auto-increment the patch version.

### Manual Version Bumps

The default is to bump the patch version (0.1.X), but you can control the version bump with commit messages:

- **Patch bump** (default): `git commit -m "fix: bug fix"`
- **Minor bump**: `git commit -m "feat: new feature"`
- **Major bump**: `git commit -m "feat!: breaking change"`

### Old Manual Process (Deprecated)

<details>
<summary>Click to see the old manual deployment process (no longer used)</summary>

1. increment version in `setup.py`
2. `rm -rf build/ hstream.egg-info/ dist/`
3. `pip install twine build`
4. `python -m build`
5. `twine upload dist/*`

</details>

## Kill orphaned uvicorn processes

`kill -9 $(lsof -t -i:8000)` (or whatever port they we're using)
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "hstream"
version = "0.1.57"
dynamic = ["version"]
description = ""
authors = [{ name = "Conrad", email = "conradbez1@gmail.com" }]
readme = "README.md"
Expand All @@ -16,6 +16,12 @@ dependencies = [
[project.scripts]
hstream = "hstream.cli:cli"

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "hstream/_version.py"

[tool.uv]
dev-dependencies = [
"black>=24.4.2",
Expand All @@ -32,5 +38,5 @@ dev-dependencies = [
]

[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
3 changes: 1 addition & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading