diff --git a/.claude/LIBRARY_CREATION.md b/.claude/LIBRARY_CREATION.md index 2d8616b..e3c5cbd 100644 --- a/.claude/LIBRARY_CREATION.md +++ b/.claude/LIBRARY_CREATION.md @@ -22,38 +22,24 @@ Comprehensive library for X with Y features. **Why:** AI co-authorship appears in GitHub contributors and cannot be easily removed. -## 2. Files to Exclude from New Library Repositories +## 2. What Lives Where -The following files are **only for the template** and must NOT be committed to new library repositories: - -### Must Delete Before First Commit: -- `scripts/setup_repo.py` - Repository setup script (run once, then delete) -- `.claude/LIBRARY_CREATION.md` - This file (agent instructions for template) - -### Keep in Template Only: -- Template configuration files -- Copier/Cookiecutter files -- Template-specific documentation +`scripts/setup_repo.py` and this file belong to the template repository. A render +contains neither, so there is nothing of the kind to delete from a new library. The +render does contain `NEW_LIBRARY_CHECKLIST.md`, the operator's checklist; it is deleted +once its steps are done. ## 3. Repository Creation Workflow When creating a new library repository: -1. **Generate from template** (copier, cookiecutter, or manual) -2. **Run setup script** (if needed): - ```bash - python scripts/setup_repo.py org/repo-name - ``` -3. **Delete setup script**: +1. **Generate from template**: ```bash - git rm scripts/setup_repo.py + uvx --with jinja2-time copier copy --trust gh:bedrock-python/python-library-template my-library ``` -4. **Delete template-specific files**: - ```bash - git rm .claude/LIBRARY_CREATION.md - ``` -5. **Make initial commit WITHOUT Co-Authored-By**: +2. **Make initial commit WITHOUT Co-Authored-By**: ```bash + git init -b master git add . git commit -m "feat: initial release @@ -62,9 +48,13 @@ When creating a new library repository: - Feature B - Full documentation and tests" ``` -6. **Push to GitHub**: +3. **Create the GitHub repository and push**: + ```bash + gh repo create org/repo-name --public --source . --push + ``` +4. **After the first CI pass, run the setup script from the template repository**: ```bash - git push -u origin master + python /path/to/python-library-template/scripts/setup_repo.py org/repo-name ``` ## 4. Initial Release Version @@ -99,8 +89,6 @@ Keep the `` guidance comment out of the committed page. Before pushing the initial commit, verify: - [ ] No `Co-Authored-By:` in commit messages -- [ ] `scripts/setup_repo.py` deleted -- [ ] `.claude/LIBRARY_CREATION.md` deleted - [ ] No backup files (e.g., `.coverage (копия...)`, `file (copy).py`) - [ ] No cache files (`.mypy_cache`, `.ruff_cache`, `__pycache__`) - should be in `.gitignore` - [ ] `.release-please-manifest.json` contains `"0.0.0"` @@ -122,7 +110,6 @@ Before merging the Release Please PR: ## 8. Common Mistakes to Avoid ❌ Including AI agents in commits -❌ Committing `scripts/setup_repo.py` to the library repo ❌ Starting with version `0.1.0` instead of `0.0.0` ❌ Committing backup/cache files ❌ Creating multiple commits before initial push (messy history) @@ -136,6 +123,6 @@ Before merging the Release Please PR: - No AI co-authors - No template-specific files - Start from version 0.0.0 -- Run setup script, then delete it +- Run the setup script from the template repository Following these rules ensures a clean, professional repository from day one. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69591f5..523aadf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,8 +11,9 @@ existing ones. Treat it like library code. - `scripts/setup_repo.py` configures a freshly created GitHub repository to the org standard (ruleset on `master`, security settings, merge settings, topics). It is run once per new library and is also what keeps the existing repositories aligned. -- `NEW_LIBRARY_CHECKLIST.md.jinja` and `.claude/LIBRARY_CREATION.md` are the operator - and agent instructions. Keep them in step with what the template actually does. +- `template/NEW_LIBRARY_CHECKLIST.md.jinja` (rendered into every new library, deleted + there once set up) and `.claude/LIBRARY_CREATION.md` are the operator and agent + instructions. Keep them in step with what the template actually does. ## Checking a change diff --git a/README.md b/README.md index ea843f1..f42f401 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,10 @@ make check Then: 1. Create a GitHub repo: `gh repo create bedrock-python/my-library --public` -2. **Configure repo** (after the first CI pass, then delete the script): +2. **Configure repo** (after the first CI pass), from a checkout of this template + repository — the script lives here, not in the library: ```bash python scripts/setup_repo.py bedrock-python/my-library - git rm scripts/setup_repo.py .claude/LIBRARY_CREATION.md ``` Idempotent. Sets the org standard: a `pypi` environment only `master` may deploy to, the `github-pages` environment and Pages, @@ -82,7 +82,8 @@ and as `_commit` the template commit it was rendered from, or the closest one. See [`.claude/LIBRARY_CREATION.md`](.claude/LIBRARY_CREATION.md) for important rules: - **Never** add AI agents as co-authors in commits -- Delete `scripts/setup_repo.py` before initial commit +- Run `scripts/setup_repo.py` from this repository; a render contains neither it nor + `.claude/LIBRARY_CREATION.md` - Start with version `0.0.0` (Release Please creates `0.1.0`) ## What's included diff --git a/NEW_LIBRARY_CHECKLIST.md.jinja b/template/NEW_LIBRARY_CHECKLIST.md.jinja similarity index 89% rename from NEW_LIBRARY_CHECKLIST.md.jinja rename to template/NEW_LIBRARY_CHECKLIST.md.jinja index f158108..1389f7f 100644 --- a/NEW_LIBRARY_CHECKLIST.md.jinja +++ b/template/NEW_LIBRARY_CHECKLIST.md.jinja @@ -82,13 +82,16 @@ it bumps all three: `CHANGELOG.md`, `.release-please-manifest.json` **and** Merge the PR → tag `{{ project_slug }}-v0.1.0` is created → PyPI publish triggers. -Or to publish manually: +To publish a release tag that already exists by hand (when its publish failed, say), +run the Publish workflow from `master`: + ```bash -git tag {{ project_slug }}-v0.1.0 -git push origin {{ project_slug }}-v0.1.0 -# Then create a GitHub Release from that tag +gh workflow run publish.yml --ref master -f tag={{ project_slug }}-v0.1.0 ``` +Pushing a tag or creating a GitHub Release yourself publishes nothing. The Publish +workflow runs after Release Please and on this dispatch, and on nothing else. + ## Done ✓ - [ ] `make check` passes @@ -97,3 +100,4 @@ git push origin {{ project_slug }}-v0.1.0 - [ ] PyPI Trusted Publisher configured - [ ] `CODECOV_TOKEN` secret added - [ ] First release published to PyPI +- [ ] This file deleted