Skip to content

Commit 03c37a1

Browse files
committed
ci: Update CI/CD toolchain for uv and git-cliff
1 parent 7122300 commit 03c37a1

File tree

14 files changed

+2213
-2176
lines changed

14 files changed

+2213
-2176
lines changed

.github/actions/bootstrap-environ/action.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ inputs:
77
runner:
88
description: The Runner to build your environment on.
99

10+
env:
11+
# Configure a relative location for the uv cache
12+
UV_CACHE_DIR: ~/.cache/uv
13+
1014
runs:
1115
using: composite
1216
steps:
@@ -15,17 +19,12 @@ runs:
1519
git config user.email github-actions@github.com
1620
git config pull.ff true
1721
shell: bash
18-
- uses: actions/setup-python@v5
22+
- uses: astral-sh/setup-uv@v5
1923
with:
2024
python-version: ${{ inputs.python-version }}
21-
- uses: Gr1N/setup-poetry@v8
2225
- uses: actions/cache@v4
2326
with:
2427
path: ~/.cache/
25-
key: ${{ inputs.runner }}|${{ inputs.python-version }}|${{ hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
26-
- run: poetry --version
27-
shell: bash
28+
key: ${{ inputs.runner }}|${{ inputs.python-version }}|${{ hashFiles('uv.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
2829
- run: make install
2930
shell: bash
30-
- run: poetry env info
31-
shell: bash

.github/workflows/.build-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
python-version: ${{ inputs.python-version }}
2727
runner: ${{ inputs.runner }}
2828
- name: Build ${{ inputs.runner }} binaries
29-
run: poetry build
29+
run: uv build
3030
- name: Store dist artifacts
3131
uses: actions/upload-artifact@v4
3232
with:

.github/workflows/publish.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
python-version: 3.x
9898
runner: ubuntu-latest
9999
- name: Compile Release Notes
100-
run: make release-notes > release-notes.md
100+
run: make release-notes
101101
- name: Report Version
102102
run: |
103103
export "RELEASE_VERSION=v$(make report-version)";
@@ -116,11 +116,3 @@ jobs:
116116
inputs: >-
117117
./dist/*.tar.gz
118118
./dist/*.whl
119-
- name: Create GitHub Release
120-
uses: softprops/action-gh-release@v2
121-
with:
122-
body_path: release-notes.md
123-
tag_name: ${{ github.env.RELEASE_VERSION }}
124-
target_commitish: ${{ github.env.TARGET_COMMITISH }}
125-
make_latest: true
126-
files: dist/*
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
name: Trigger Release
1+
name: Create Tag
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
level:
7-
description: "The level to bump the current version"
8-
required: true
9-
default: "patch"
10-
options:
11-
- "patch"
12-
- "minor"
13-
- "major"
14-
- "prepatch"
15-
- "preminor"
16-
- "prerelease"
4+
push:
5+
branches:
6+
- 'main'
7+
tags-ignore:
8+
- '**'
179

1810
defaults:
1911
run:
@@ -26,7 +18,7 @@ jobs:
2618
fail-fast: false
2719
matrix:
2820
os: [ ubuntu-latest ]
29-
python-version: [ "3.9" ]
21+
python-version: [ "3.12" ]
3022
steps:
3123
- uses: actions/create-github-app-token@v1
3224
id: app-token
@@ -42,6 +34,6 @@ jobs:
4234
python-version: ${{ matrix.python-version }}
4335
runner: ${{ matrix.os }}
4436
- name: Tag New Version
45-
run: make release-version rule=${{ inputs.level }}
37+
run: make release-version
4638
- name: Push New Version
4739
run: git push --follow-tags origin ${{ github.ref_name }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,4 @@ venv.bak/
113113
/benchmark/.cases.json
114114
*.DS_Store
115115
coverage.db
116+
release-notes.md

.pre-commit-config.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
33
# Ruff version.
4-
rev: v0.6.3
4+
rev: v0.9.4
55
hooks:
66
# Run the linter.
77
- id: ruff
88
types_or: [ python, pyi ]
99
args: [ --fix, --config=pyproject.toml ]
10+
stages: [ pre-commit, manual ]
1011
# Run the formatter.
1112
- id: ruff-format
1213
types_or: [ python, pyi ]
1314
args: [ --config=pyproject.toml ]
15+
stages: [ pre-commit, manual ]
1416
- repo: https://github.com/pre-commit/mirrors-mypy
15-
rev: v1.11.2
17+
rev: v1.14.1
1618
hooks:
1719
- id: mypy
1820
args: [ --config-file=pyproject.toml ]
@@ -23,9 +25,21 @@ repos:
2325
- types-typed-ast
2426
- types-orjson
2527
files: "src/.*"
28+
stages: [ pre-commit, manual ]
2629
- repo: https://github.com/compilerla/conventional-pre-commit
27-
rev: v3.4.0
30+
rev: v4.0.0
2831
hooks:
2932
- id: conventional-pre-commit
3033
stages: [commit-msg]
3134
args: []
35+
- repo: https://github.com/astral-sh/uv-pre-commit
36+
# uv version.
37+
rev: 0.5.26
38+
hooks:
39+
- id: uv-sync
40+
args: ["--locked", "--all-packages"]
41+
stages:
42+
- pre-commit
43+
- post-checkout
44+
- post-merge
45+
- post-rewrite

Makefile

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,25 @@ SHELL := bash
55
MAKEFLAGS += --warn-undefined-variables
66
MAKEFLAGS += --no-builtin-rules
77

8-
ifeq ($(VIRTUAL_ENV), )
9-
RUN_PREFIX := poetry run
10-
else
11-
RUN_PREFIX :=
12-
endif
13-
8+
RUN_PREFIX := uv run --
149

1510
# region: environment
1611

17-
bootstrap: setup-poetry update install ## Bootstrap your local environment for development.
12+
quickstart: setup-uv install ## Bootstrap your local environment for development.
1813
.PHONY: bootstrap
1914

20-
setup-poetry: ## Set up your poetry installation and ensure it's up-to-date.
21-
@poetry self update -q
22-
.PHONY: setup-poetry
15+
setup-uv: ## Set up your poetry installation and ensure it's up-to-date.
16+
@curl -LsSf https://astral.sh/uv/install.sh | sh
17+
@uv self update
18+
.PHONY: setup-uv
2319

2420
install: ## Install or re-install your app's dependencies.
25-
@poetry install
21+
@uv sync --all-extras --dev --locked
2622
@$(RUN_PREFIX) pre-commit install && $(RUN_PREFIX) pre-commit install-hooks
2723
.PHONY: install
2824

2925
update: ## Update app dependencies
30-
@poetry update
26+
@uv sync --all-extras --dev
3127
@$(RUN_PREFIX) pre-commit autoupdate
3228
.PHONY: update
3329

@@ -40,17 +36,11 @@ ifneq ($(target), .)
4036
files := --files=$(target)
4137
endif
4238

43-
format: ## Manually run code-formatters for the app.
44-
@$(RUN_PREFIX) pre-commit run ruff-format $(files)
45-
@$(RUN_PREFIX) pre-commit run ruff $(files)
46-
.PHONY: format
47-
4839
# endregion
4940
# region: ci
5041

5142
lint: ## Run this app's linters. Target a specific file or directory with `target=path/...`.
52-
@$(RUN_PREFIX) pre-commit run ruff $(files)
53-
@$(RUN_PREFIX) pre-commit run mypy $(files)
43+
@$(RUN_PREFIX) pre-commit run --hook-stage=manual $(files)
5444
.PHONY: lint
5545

5646
test: ## Run this app's tests with a test db. Target a specific path `target=path/...`.
@@ -63,41 +53,42 @@ rule ?= patch
6353

6454

6555
release-version: ## Bump the version for this package.
66-
$(eval current_version := $(shell poetry version -s))
67-
$(eval new_version := $(shell poetry version -s $(rule)))
68-
$(eval message := "Release $(current_version) -> $(new_version)")
69-
git add pyproject.toml
70-
git commit -m $(message)
71-
git tag -a v$(new_version) -m $(message)
56+
$(eval message := "Release $(next_version)")
57+
#git tag -a $(next_version) -m $(message)
7258
.PHONY: release-version
7359

7460

61+
BUMP_CMD := git-cliff --bumped-version -o -
62+
7563
report-version: ## Show the current version of this library.
76-
@$(VERSION_CMD)
64+
@echo $(version)
7765
.PHONY: report-version
7866

7967
docs-version: ## Show the current version of this library as applicable for documentation.
80-
@$(VERSION_CMD) | $(SED_CMD) $(DOCS_FILTER)
68+
@echo $(docs_version)
8169
.PHONY: docs-version
8270

8371
docs: ## Build the versioned documentation
8472
@$(RUN_PREFIX) mike deploy -u --push $(version) $(alias)
8573
.PHONY: docs
8674

87-
VERSION_CMD ?= poetry version -s
75+
VERSION_CMD ?= hatchling version
8876
SED_CMD ?= sed -En
77+
CI_FILTER ?= 's/^([[:digit:]]+.[[:digit:]]+.[[:digit:]]+).*$$/v\1/p'
8978
DOCS_FILTER ?= 's/^([[:digit:]]+.[[:digit:]]+).*$$/v\1/p'
90-
version ?= $(shell $(VERSION_CMD) | $(SED_CMD) $(DOCS_FILTER))
79+
version ?= $(shell $(RUN_PREFIX) $(VERSION_CMD) | $(SED_CMD) $(CI_FILTER))
80+
docs_version ?= $(shell $(RUN_PREFIX) $(VERSION_CMD) | $(SED_CMD) $(DOCS_FILTER))
81+
next_version ?= $(shell $(RUN_PREFIX) $(BUMP_CMD))
9182
alias ?= latest
9283

9384
changelog: ## Compile the latest changelog for the current branch.
94-
@$(RUN_PREFIX) git-changelog
85+
@$(RUN_PREFIX) git-cliff --bump
9586
@git add docs/changelog.md
96-
@git commit -m "[skip ci] Update changelog." --allow-empty
87+
@git commit -m "[git-cliff] Update changelog." --allow-empty
9788
.PHONY: changelog
9889

9990
release-notes: ## Compile release notes for VCS
100-
@$(RUN_PREFIX) git-changelog --release-notes
91+
@$(RUN_PREFIX) git-cliff --bump --unreleased -o release-notes.md
10192
.PHONY: release-notes
10293

10394
# endregion

cliff.toml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# git-cliff ~ default configuration file
2+
# https://git-cliff.org/docs/configuration
3+
#
4+
# Lines starting with "#" are comments.
5+
# Configuration options are organized into tables and keys.
6+
# See documentation for more information on available options.
7+
8+
[remote.github]
9+
owner = "seandstewart"
10+
repo = "python-typelib"
11+
12+
[bump]
13+
features_always_bump_minor = false
14+
breaking_always_bump_major = false
15+
16+
[changelog]
17+
# template for the changelog header
18+
header = """
19+
# Changelog\n
20+
All notable changes to this project will be documented in this file.
21+
22+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
23+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n
24+
"""
25+
# template for the changelog body
26+
# https://keats.github.io/tera/docs/#introduction
27+
body = """
28+
{%- macro remote_url() -%}
29+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
30+
{%- endmacro -%}
31+
{%- macro version_ref() -%}
32+
[{{ version | trim_start_matches(pat="v") }}][{{ version | trim_start_matches(pat="v") }}]
33+
{%- endmacro -%}
34+
35+
36+
{% if version -%}
37+
## {{ self::version_ref() }} - {{ timestamp | date(format="%Y-%m-%d") }}
38+
{% else -%}
39+
## [Unreleased][unreleased]
40+
{% endif -%}
41+
42+
{% for group, commits in commits | group_by(attribute="group") %}
43+
### {{ group | upper_first }}
44+
{%- for commit in commits %}
45+
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
46+
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%}
47+
{% if commit.remote.pr_number %} in \
48+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
49+
{%- endif -%}
50+
{% endfor %}
51+
{% endfor %}
52+
53+
{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
54+
## New Contributors
55+
{%- endif -%}
56+
57+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
58+
* @{{ contributor.username }} made their first contribution
59+
{%- if contributor.pr_number %} in \
60+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
61+
{%- endif %}
62+
{%- endfor %}\n\n
63+
"""
64+
# template for the changelog footer
65+
footer = """
66+
{%- macro remote_url() -%}
67+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
68+
{%- endmacro -%}
69+
70+
{% for release in releases -%}
71+
{% if release.version -%}
72+
{% if release.previous.version -%}
73+
[{{ release.version | trim_start_matches(pat="v") }}]: \
74+
{{ self::remote_url() }}/compare/{{ release.previous.version }}..{{ release.version }}
75+
{% endif -%}
76+
{% else -%}
77+
[unreleased]: {{ self::remote_url() }}/compare/{{ release.previous.version }}..HEAD
78+
{% endif -%}
79+
{% endfor %}
80+
<!-- generated by git-cliff -->
81+
"""
82+
# remove the leading and trailing whitespace from the templates
83+
trim = true
84+
output = "docs/changelog.md"
85+
86+
[git]
87+
# parse the commits based on https://www.conventionalcommits.org
88+
conventional_commits = true
89+
# filter out the commits that are not conventional
90+
filter_unconventional = true
91+
# process each line of a commit as an individual commit
92+
split_commits = false
93+
# regex for preprocessing the commit messages
94+
commit_preprocessors = [
95+
# Replace issue numbers
96+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
97+
]
98+
# regex for parsing and grouping commits
99+
commit_parsers = [
100+
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
101+
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
102+
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
103+
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
104+
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
105+
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
106+
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
107+
{ message = "^chore\\(release\\): prepare for", skip = true },
108+
{ message = "^chore\\(deps.*\\)", skip = true },
109+
{ message = "^chore\\(pr\\)", skip = true },
110+
{ message = "^chore\\(pull\\)", skip = true },
111+
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
112+
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
113+
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
114+
{ message = ".*", group = "<!-- 10 -->💼 Other" },
115+
]
116+
# filter out the commits that are not matched by commit parsers
117+
filter_commits = false
118+
# sort the tags topologically
119+
topo_order = false
120+
# sort the commits inside sections by oldest/newest order
121+
sort_commits = "oldest"

0 commit comments

Comments
 (0)