diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index aaa8825..6a503db 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -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' @@ -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 }} diff --git a/.gitignore b/.gitignore index ecc9912..56719c5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ Dockerfile example.py +# Auto-generated version file +hstream/_version.py + .*pyc # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index 72ceb9a..ee15d7a 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -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) + +
+Click to see the old manual deployment process (no longer used) + +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/*` +
+ ## Kill orphaned uvicorn processes `kill -9 $(lsof -t -i:8000)` (or whatever port they we're using) diff --git a/pyproject.toml b/pyproject.toml index 989956d..f4170d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "hstream" -version = "0.1.57" +dynamic = ["version"] description = "" authors = [{ name = "Conrad", email = "conradbez1@gmail.com" }] readme = "README.md" @@ -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", @@ -32,5 +38,5 @@ dev-dependencies = [ ] [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" diff --git a/uv.lock b/uv.lock index 24de1e9..fb7d564 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 2 +revision = 3 requires-python = ">=3.10" resolution-markers = [ "python_full_version >= '3.12'", @@ -364,7 +364,6 @@ wheels = [ [[package]] name = "hstream" -version = "0.1.57" source = { editable = "." } dependencies = [ { name = "beautifulsoup4" },