-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcopier.yaml
More file actions
215 lines (198 loc) · 6.72 KB
/
copier.yaml
File metadata and controls
215 lines (198 loc) · 6.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
project_name:
type: str
help: What is the name of the project?
default: space-monkey
validator: |
{% if project_name|length < 4 or project_name|length > 40 %}
project_name must be between 4 and 40 characters
{% endif %}
{% if not (project_name | regex_search('^[a-z][a-z0-9\-]+$')) %}
project_name must start with a letter, followed one or more letters, digits or dashes (all lowercase).
{% endif %}
project_summary:
type: str
help: Provide a short summary of the project.
default: It's a trial run
author_name:
type: str
help: What is the author's name?
default: Tucker Beck
author_email:
type: str
help: What is the author's email address?
default: tucker.beck@gmail.com
module_name:
type: str
help: What is the Python module name?
default: "{{ project_name.replace('-', '_') }}"
validator: |
{% if module_name|length < 4 or module_name|length > 40 %}
module_name must be between 4 and 40 characters
{% endif %}
{% if not (module_name | regex_search('^[a-z][a-z0-9_]+$')) %}
module_name must start with a letter, followed one or more letters, digits or underscores (all lowercase).
{% endif %}
python_versions:
type: str
help: What Python versions will be supported?
default:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
multiselect: true
choices:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
validator: |
{% set all_ver = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] %}
{% if all_ver.index(python_versions[-1]) - all_ver.index(python_versions[0]) + 1 != python_versions|length %}
python_versions must be a consecutive list of versions
{% endif %}
default_python_version:
type: str
help: What is the default Python version to use?
default: "{{python_versions[-1]}}"
choices: |
{% for ver in python_versions %}
- "{{ver}}"
{% endfor %}
run_qa_checks:
type: bool
help: Should I run quality checks after building?
default: false
initialize_git:
type: bool
help: Should I initialize this project as a git repository?
default: true
push_to_github:
type: bool
help: Should I publish this project to github?
default: "{{ initialize_git }}"
when: "{{ initialize_git }}"
github_account:
type: str
help: What is the github account I should use?
default: dusktreader
when: "{{ push_to_github }}"
publish_to_pypi:
type: bool
help: Should I set up trusted publishing to PyPI?
default: "{{ push_to_github }}"
when: "{{ push_to_github }}"
include_demo:
type: bool
help: Should I include a demo module?
default: false
include_examples:
type: bool
help: Should I include an examples directory?
default: false
_subdirectory: template
_exclude:
- "{% if not include_demo %}{{project_name}}/src/{{module_name}}_demo{% endif %}"
- "{% if not include_examples %}{{project_name}}/examples{% endif %}"
# These should probably only trigger on new projects not updates
_tasks:
- working_directory: "{{ project_name }}"
command: "uv sync"
- working_directory: "{{ project_name }}"
command: "make qa/full"
when: "{{ run_qa_checks }}"
- working_directory: "{{ project_name }}"
command: "git init ."
when: "{{ initialize_git }}"
- working_directory: "{{ project_name }}"
command: "git add README.md"
when: "{{ initialize_git }}"
- working_directory: "{{ project_name }}"
command: "git commit -m 'Initial Commit'"
when: "{{ initialize_git }}"
- working_directory: "{{ project_name }}"
command: "git add ."
when: "{{ initialize_git }}"
- working_directory: "{{ project_name }}"
command: "git commit -m 'feat: Bootstrapped the {{ project_name }} project'"
when: "{{ initialize_git }}"
- working_directory: "{{ project_name }}"
command: >
GH_TOKEN=$(gh auth token --user {{ github_account }})
gh repo create
--description="{{ project_summary }}"
--source=.
--homepage="https://{{ github_account }}.github.io/{{ project_name }}"
--public
{{ project_name }}
when: "{{ push_to_github }}"
- working_directory: "{{ project_name }}"
command: "git push -u origin main"
when: "{{ push_to_github }}"
- working_directory: "{{ project_name }}"
command: >
GH_TOKEN=$(gh auth token --user {{ github_account }})
gh api
--silent
--method=PUT
-H "Accept: application/vnd.github+json"
"/repos/{{ github_account }}/{{ project_name }}/environments/pypi"
when: "{{ publish_to_pypi }}"
- command: >
echo "ACTION REQUIRED: Register a pending trusted publisher at
https://pypi.org/manage/account/publishing/ with these settings:
PyPI project name: {{ project_name }}
Owner: {{ github_account }}
Repository: {{ project_name }}
Workflow: deploy.yml
Environment: pypi"
when: "{{ publish_to_pypi }}"
- working_directory: "{{ project_name }}"
command: >
while [ -z "$(GH_TOKEN=$(gh auth token --user {{ github_account }}) gh run list --json databaseId,name | jq '.[] | select(.name == "build-docs")')" ]; do
echo "Waiting for docs build action to start" && sleep 1;
done
when: "{{ push_to_github }}"
- working_directory: "{{ project_name }}"
command: >
GH_TOKEN=$(gh auth token --user {{ github_account }})
gh run list --json databaseId,name
| jq '.[] | select(.name == "build-docs")'
| jq '.databaseId'
| xargs gh run watch --exit-status
when: "{{ push_to_github }}"
- working_directory: "{{ project_name }}"
command: >
GH_TOKEN=$(gh auth token --user {{ github_account }})
gh api
--silent
--method=POST
-H "Accept: application/vnd.github+json"
"/repos/{{ github_account }}/{{ project_name }}/pages"
-f "source[branch]=gh-pages"
-f "source[path]=/"
-f "build_type=legacy"
when: "{{ push_to_github }}"
- working_directory: "{{ project_name }}"
command: >
while [ -z "$(GH_TOKEN=$(gh auth token --user {{ github_account }}) gh run list --json databaseId,name | jq '.[] | select(.name == "pages build and deployment")')" ]; do
echo "Waiting for page deploy action to start" && sleep 1;
done
when: "{{ push_to_github }}"
- working_directory: "{{ project_name }}"
command: >
GH_TOKEN=$(gh auth token --user {{ github_account }})
gh run list --json databaseId,name
| jq '.[] | select(.name == "pages build and deployment")'
| jq '.databaseId'
| xargs gh run watch --exit-status
when: "{{ push_to_github }}"
- command: >
echo "Finished bootstrapping {{ project_name }}!"
- command: >
echo "Check it out at https://github.com/{{ github_account }}/{{ project_name }}"
when: "{{ push_to_github }}"