Skip to content

Commit ff2abad

Browse files
colyerdengShawnDen-coder
authored andcommitted
feat: update template
1 parent a165b4d commit ff2abad

File tree

18 files changed

+329
-470
lines changed

18 files changed

+329
-470
lines changed

repo_scaffold/templates/template-python/cookiecutter.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"github_username": "ShawnDen-coder",
66
"project_slug": "{{ cookiecutter.repo_name.strip().lower().replace('-', '_') }}",
77
"description": "A short description of the project.",
8-
"min_python_version": ["3.9", "3.10", "3.11"],
9-
"max_python_version": ["3.12"],
8+
"min_python_version": ["3.9", "3.10", "3.11", "3.12", "3.13","3.14"],
9+
"max_python_version": ["3.9", "3.10", "3.11", "3.12", "3.13","3.14"],
1010
"use_docker": ["yes", "no"],
1111
"include_cli": ["yes", "no"],
1212
"use_github_actions": ["yes", "no"],
1313
"__prompts__": {
14-
"repo_name": "项目名称 (使用 - 分隔, 例如: my-awesome-project)",
14+
"repo_name": "项目名称 (my-awesome-project)",
1515
"full_name": "你的全名",
1616
"email": "你的邮箱地址",
1717
"github_username": "你的 GitHub 用户名",

repo_scaffold/templates/template-python/hooks/post_gen_project.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ def remove_cli():
99
if os.path.exists(cli_file):
1010
os.remove(cli_file)
1111

12+
def remove_docker():
13+
"""Remove GitHub Actions configuration if not needed."""
14+
file_name = [".dockerignore", "docker", ".github/workflows/docker_release.yaml"]
15+
if "{{cookiecutter.use_github_actions}}" == "no":
16+
for item in file_name:
17+
if os.path.exists(item):
18+
if os.path.isfile(item):
19+
os.remove(item)
20+
elif os.path.isdir(item):
21+
shutil.rmtree(item)
22+
1223

1324
def remove_github_actions():
1425
"""Remove GitHub Actions configuration if not needed."""
@@ -36,7 +47,7 @@ def init_project_depends():
3647
os.chdir(project_dir)
3748

3849
# 安装基础开发依赖
39-
subprocess.run(["uv", "sync", "--extra", "dev"], check=True)
50+
subprocess.run(["uv", "sync"], check=True)
4051

4152

4253
if __name__ == "__main__":
@@ -46,5 +57,8 @@ def init_project_depends():
4657
if "{{cookiecutter.use_github_actions}}" == "no":
4758
remove_github_actions()
4859
remove_docs()
60+
61+
if "{{cookiecutter.use_docker}}" == "no":
62+
remove_docker()
4963

5064
init_project_depends()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
commitizen:
2+
major_version_zero: true
3+
name: cz_conventional_commits
4+
tag_format: $version
5+
update_changelog_on_bump: true
6+
version_provider: uv
7+
version_scheme: semver2
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__pycache__
2+
*.pyc
3+
.git
4+
.pytest_cache
5+
docs/
6+
tests/
7+
mkdocs.yml
8+
.venv
Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,25 @@
11
name: Bump version
2-
32
on:
43
push:
54
branches:
65
- master
76
- main
8-
workflow_dispatch:
9-
inputs:
10-
increment:
11-
description: 'Version increment (major, minor, patch)'
12-
required: false
13-
type: choice
14-
options:
15-
- major
16-
- minor
17-
- patch
18-
default: patch
19-
207
permissions:
21-
contents: write # 用于创建和推送标签
22-
pull-requests: write # 用于创建 PR
23-
8+
contents: write # 用于创建和推送标签
9+
pull-requests: write # 用于创建 PR
2410
jobs:
2511
bump-version:
26-
if: "!startsWith(github.event.head_commit.message, 'bump:')"
12+
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
2713
runs-on: ubuntu-latest
28-
name: "Bump version and create changelog with commitizen"
14+
name: Bump version and create changelog with commitizen
2915
steps:
30-
- name: Load secret
31-
uses: 1password/load-secrets-action@v2
32-
with:
33-
export-env: true
34-
env:
35-
OP_SERVICE_ACCOUNT_TOKEN: {% raw %}${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}{% endraw %}
36-
PERSONAL_ACCESS_TOKEN: op://shawndengdev/github_access_token/credential
37-
3816
- name: Check out
3917
uses: actions/checkout@v4
4018
with:
4119
fetch-depth: 0
42-
token: {% raw %}'${{ env.PERSONAL_ACCESS_TOKEN }}'{% endraw %}
43-
20+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
4421
- name: Create bump and changelog
4522
uses: commitizen-tools/commitizen-action@master
4623
with:
47-
github_token: {% raw %}${{ env.PERSONAL_ACCESS_TOKEN }}{% endraw %}
24+
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
4825
branch: master
Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
11
name: Deploy Docs
2-
32
on:
43
push:
54
tags:
6-
- '[0-9]+.[0-9]+.[0-9]+' # 匹配类似 1.0.0, 2.1.3 等格式的标签
5+
- '[0-9]+.[0-9]+.[0-9]+' # 匹配类似 1.0.0, 2.1.3 等格式的标签
76
workflow_dispatch:
8-
97
permissions:
10-
contents: write # 用于部署到 GitHub Pages
11-
8+
contents: write # 用于部署到 GitHub Pages
129
jobs:
1310
deploy:
1411
runs-on: ubuntu-latest
1512
steps:
1613
- name: Checkout code
1714
uses: actions/checkout@v4
18-
19-
- name: Setup Python
20-
uses: actions/setup-python@v5
21-
with:
22-
python-version: "{{cookiecutter.max_python_version}}"
23-
15+
- name: Install Task
16+
uses: arduino/setup-task@v2
2417
- name: Install uv
2518
uses: astral-sh/setup-uv@v5
26-
27-
- name: Install dependencies
28-
run: uv sync --extra=docs
29-
3019
- name: Build and deploy documentation
31-
run: uv run mkdocs gh-deploy --force
20+
run: task deploy:gh-pages
3221
env:
33-
GITHUB_TOKEN: {% raw %}${{ github.token }}{% endraw %}
22+
GITHUB_TOKEN: ${{ github.token }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: docker release
2+
on:
3+
release:
4+
types: [published]
5+
workflow_dispatch:
6+
env:
7+
DOCKERHUB_IMAGE_NAME: shawndengdocker/homelab_airflow_dags
8+
GITHUB_IMAGE_NAME: ghcr.io/shawnden-coder/homelab_airflow_dags
9+
jobs:
10+
push_to_registry:
11+
name: Push Docker image to Docker Hub and GHCR
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out the repo
15+
uses: actions/checkout@v4
16+
- name: Login to Docker Hub
17+
uses: docker/login-action@v3
18+
with:
19+
username: ${{ secrets.DOCKERHUB_USERNAME }}
20+
password: ${{ secrets.DOCKERHUB_TOKEN }}
21+
- name: Login to GitHub Container Registry
22+
uses: docker/login-action@v3
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
- name: Docker meta
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: |
36+
${{ env.DOCKERHUB_IMAGE_NAME }}
37+
${{ env.GITHUB_IMAGE_NAME }}
38+
tags: |
39+
type=raw,value=latest,enable={{is_default_branch}}
40+
type=ref,event=tag
41+
type=ref,event=pr
42+
type=sha,format=short
43+
- name: Build and push Docker images
44+
uses: docker/build-push-action@v6
45+
with:
46+
context: .
47+
file: ./docker/Dockerfile
48+
platforms: linux/amd64,linux/arm64
49+
push: true
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/lint.yaml

Lines changed: 0 additions & 90 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: lint_and_unittest
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
permissions:
10+
contents: read
11+
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Install Task
18+
uses: arduino/setup-task@v2
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
21+
- name: Install dependencies
22+
run: task init
23+
- name: Run lint checks
24+
id: lint
25+
run: task lint
26+
- name: Run test all versions
27+
run: task test:all

0 commit comments

Comments
 (0)