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
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: release

on:
push:
branches:
- main
# TESTING: Uncomment the line below to allow releases from a branch with the following name.
# This makes it easy to test semantic release on any branch.
# To disable, comment out this line.
# - semantic-release
workflow_dispatch:
inputs:
dry_run:
description: 'Run in dry-run mode (no actual release)'
required: false
default: false
type: boolean

jobs:
release:
runs-on: ubuntu-latest
permissions:
# allow creation of commit/release/tags
contents: write
steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: |
make init-uv
make install

- name: Configure git
run: |
git config user.name "semantic-release"
git config user.email "[email protected]"

- name: Run semantic release (dry-run)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make release-dry-run

- name: Run semantic release
if: github.event_name != 'workflow_dispatch' || github.event.inputs.dry_run != true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make release
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# CHANGELOG

<!-- version list -->

## v1.0.0-rc.5 (2026-01-18)

### Bug Fixes

- Attempt to use action for release
([`dc8fe56`](https://github.com/dlstadther/sample-project-python/commit/dc8fe561c1b7bc621c45db8ed5b83a6b90d9df4d))

- Ensure uv is still available to support build_command
([`c743f9e`](https://github.com/dlstadther/sample-project-python/commit/c743f9ea35ffaf3c2aa775d64137a0cf7a1db03c))

- Include checkout
([`53b6f72`](https://github.com/dlstadther/sample-project-python/commit/53b6f726114d9edce3156aa814b897a3c34dce95))

- Revert semantic-release to make version; updates token to GH_TOKEN
([`26633eb`](https://github.com/dlstadther/sample-project-python/commit/26633eb756bda5b9c20d0ddf51ed1906ba331ce5))


## v1.0.0-rc.4 (2026-01-14)

### Bug Fixes

- Attempt workflow permission
([`bdc2a63`](https://github.com/dlstadther/sample-project-python/commit/bdc2a631b0bc8e5580a061f463c60216d1090901))

- Attempting pr write permission given github discussion comment
([`c755c4b`](https://github.com/dlstadther/sample-project-python/commit/c755c4b2745bc4e0d6db79f64d77d9c0b0fc3fb9))


## v1.0.0-rc.3 (2026-01-14)

### Bug Fixes

- Github token permissions
([`198dfc1`](https://github.com/dlstadther/sample-project-python/commit/198dfc122492d27210f9d428745e7388017cf6e6))


## v1.0.0-rc.2 (2026-01-13)

### Bug Fixes

- Allow github action token to create release
([`b735f71`](https://github.com/dlstadther/sample-project-python/commit/b735f714412aa0028ce793892af2c434d01d5202))


## v1.0.0-rc.1 (2026-01-13)

- Initial Release
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ test:

test-all:
uv run nox --reuse-venv=yes --no-install

# Release
release:
uv run semantic-release -v version --commit --tag --changelog --push --vcs-release

release-dry-run:
uv run semantic-release --noop version --print
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
![Test](https://github.com/dlstadther/sample-project-python/actions/workflows/tests.yml/badge.svg)

Sample structure and setup for a Python project which includes:

* prek hooks (static formatters and type checking)
* mkdoc generation from docstrings
* unittest execution


## Installation

```shell
# install requirements
make init
Expand All @@ -23,6 +24,7 @@ poetry run prek install
## Usage

### Run Prek Hooks

```shell
# To run the prek hooks against staged files before committing:
uv run prek run
Expand All @@ -43,6 +45,7 @@ uv run ruff src
```

### Run Unittests

```shell
# Run all unittests
make test
Expand All @@ -52,6 +55,7 @@ uv run pytest -vv tests/test_placeholder.py::test_Sample_init
```

### Run All Checks

```shell
# Run all tests, lints, and checks
make test-all
Expand All @@ -78,14 +82,17 @@ make build
# Only build wheel
uv build --wheel

# Test semantic release (dry-run, shows what would be released)
make release-dry-run

# Publish to PyPI
export UV_PUBLISH_TOKEN="<my-pypi-token>"
uv publish
uv publish --token "<my-pypi-token>"
```

## Prek Hooks

# Prek Hooks
Prek hooks run during `git commit ...` in order to apply checks for quality and format prior to commit.

The checks contained in this repo include (in the order in which they run):
Expand All @@ -105,6 +112,5 @@ If `# type: ignore` is added to the very top of a file, `ty` will ignore the ent

If you absolutely must commit without adhering to the prek hooks, then you can use `git commit -n ...` where `-n` is shorthand for `--no-verify`.


# TODOs
* [ ]
57 changes: 54 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "sample-project-python"
version = "0.3.1"
version = "1.0.0-rc.5"
description = "Sample Python Project"
license = "MIT"
authors = [{name = "Dillon Stadther"}, ]
Expand All @@ -30,6 +30,7 @@ dev = [
"prek >=0.1.0,<1",
"pytest >=8.3.2,<9",
"pytest-cov >=5.0.0,<6",
"python-semantic-release >=10.0.0,<11",
"ruff >=0.6.2,<1",
"sqlfluff >=3.1.1,<4",
"ty >=0.0.11,<1",
Expand All @@ -52,9 +53,9 @@ fail_under = 70
show_missing = true


######
####
# Ty
######
####
[tool.ty]


Expand Down Expand Up @@ -100,6 +101,56 @@ pythonpath = [
]


##################
# Semantic Release
##################
[tool.semantic_release]
build_command = """\
uv lock --upgrade-package "$PACKAGE_NAME"
git add uv.lock
uv build
"""
commit_message = """\
chore: release v{version}

Automatically generated by python-semantic-release
"""
commit_parser = "conventional"
version_toml = [
# "file:variable:[format_type]"
"pyproject.toml:project.version:nf",
]
version_variable = [
# "file:variable:format_type"
"src/sample/__init__.py:__version__:nf",
"pyproject.toml:project.version:nf",
]

[tool.semantic_release.changelog]
exclude_commit_patterns = [
"^Merge",
"^Revert",
]

[tool.semantic_release.branches.main]
match = "(main|master)"
prerelease_token = ""
prerelease = false

# TESTING: Uncomment the section below to allow releases from the current branch
# This makes it easy to test semantic release on any branch.
# To disable, comment out this entire section.
[tool.semantic_release.branches.test]
match = ".*" # Matches any branch name
prerelease_token = "rc"
prerelease = true

[tool.semantic_release.branches.pre_release]
match = "(pre-.*|beta.*|alpha.*)"
prerelease_token = "rc"
prerelease = true


##########
# Sqlfluff
##########
Expand Down
3 changes: 3 additions & 0 deletions src/sample/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Sample Python Project."""

__version__ = "0.3.1"
Loading