Skip to content
Draft
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
14 changes: 14 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ repository_namespace:
help: Your repository namespace
default: "trobz"

git_platform:
type: str
help: Git platform hosting the repository
default: github.com
choices:
- github.com
- gitlab.trobz.com

repository_name:
type: str
help: |
Expand All @@ -48,8 +56,14 @@ author_email:
enable_github_action:
type: bool
default: False
when: "{{ git_platform == 'github.com' }}"

publish_to_pypi:
type: bool
default: False
when: "{{ enable_github_action }}"

enable_gitlab_action:
type: bool
default: False
when: "{{ git_platform == 'gitlab.com' }}"
25 changes: 23 additions & 2 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
]

[project.urls]
Repository = "https://github.com/trobz/{{project_name}}"
Repository = "https://{{git_platform}}/trobz/{{project_name}}"

[project.scripts]
{{ project_name }} = "{{ package_name }}.main:app"
Expand Down Expand Up @@ -42,12 +42,33 @@ module-name = "{{ package_name }}"
module-root = ""


{% if enable_github_action -%}
{% if enable_github_action or enable_gitlab_action -%}
[project.optional-dependencies]
build = ["uv ~= 0.7.12"]

[tool.semantic_release]
version_toml = ["pyproject.toml:project.version"]
{% if enable_gitlab_action -%}
type = "gitlab"
{% endif -%}

# Commit parser - this should be at the top level
commit_parser = "conventional"

# Allow 0.x.x versions (prevents jumping straight to 1.0.0)
allow_zero_version = true

# Don't do major version bumps when in 0.x.x
major_on_zero = false

# Tag format
tag_format = "v{version}"

# Branch configuration
[tool.semantic_release.branches.main]
match = "main"
prerelease = false

build_command = """
python -m pip install -e '.[build]'
uv lock --upgrade-package {{project_name}}
Expand Down
3 changes: 3 additions & 0 deletions template/ty.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[rules.invalid-argument-type]
ignore = []

[environment]
python = "./.venv"
python-version = "3.12"
52 changes: 52 additions & 0 deletions template/{% if enable_gitlab_action %}.gitlab-ci{% endif%}.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
stages:
- test
- release

test:
stage: test
image: python:3.13
script:
- make test
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "main"'

# Semantic release job
semantic-release:
stage: release
image: python:3.13

# Critical variables for GitLab integration
variables:
GIT_STRATEGY: clone
GIT_DEPTH: 0 # Full git history needed for semantic-release
# Ensure we can make commits
GIT_AUTHOR_NAME: "GitLab CI"
GIT_AUTHOR_EMAIL: "$GITLAB_USER_EMAIL"
GIT_COMMITTER_NAME: "GitLab CI"
GIT_COMMITTER_EMAIL: "$GITLAB_USER_EMAIL"

before_script:
# Configure git for making commits
- git config --global user.name "GitLab CI"
- git config --global user.email "$GITLAB_USER_EMAIL"
# Checkout the branch (important for pushing changes back)
- git checkout -B "$CI_COMMIT_REF_NAME"
# Ensure we have the remote configured properly for pushing
- git remote set-url origin "https://gitlab-ci-token:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"

script:
# Install python-semantic-release
- pip install python-semantic-release
# Run semantic release
- semantic-release version --print
- semantic-release version
- semantic-release changelog
- semantic-release publish

rules:
# Only run on main branch pushes (not merge requests)
- if: '$CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"'

# Allow manual triggering for testing
when: on_success