From 0514f97aa15253548529573f4989ee56306b745b Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Mon, 14 Jul 2025 14:10:04 +0200 Subject: [PATCH 1/8] feat: :sparkles: add Commitizen version bump with GitHub workflow --- template/.cz.toml | 10 +++++++++ .../.github/workflows/release-package.yml | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 template/.cz.toml create mode 100644 template/.github/workflows/release-package.yml diff --git a/template/.cz.toml b/template/.cz.toml new file mode 100644 index 0000000..3c64c6c --- /dev/null +++ b/template/.cz.toml @@ -0,0 +1,10 @@ +[tool.commitizen] +bump_message = "build(version): :bookmark: update version from $current_version to $new_version [skip ci]" +update_changelog_on_bump = true +version_provider = "uv" +version_files = [ + "pyproject.toml:version", + "datapackage.json:version" +] +# Don't regenerate the changelog on every update +changelog_incremental = true diff --git a/template/.github/workflows/release-package.yml b/template/.github/workflows/release-package.yml new file mode 100644 index 0000000..be74c03 --- /dev/null +++ b/template/.github/workflows/release-package.yml @@ -0,0 +1,21 @@ +name: Release package + +on: + push: + branches: + - main + +# Limit token permissions for security +permissions: read-all + +jobs: + release: + # This job outputs env variables `previous_version` and `current_version`. + # Only give permissions for this job. + permissions: + contents: write + uses: seedcase-project/.github/.github/workflows/reusable-release-project.yml@main + with: + app-id: ${{ vars.UPDATE_VERSION_APP_ID }} + secrets: + update-version-gh-token: ${{ secrets.UPDATE_VERSION_TOKEN }} From ea527f9d087b8bf5ffd6792b2607a078de435daa Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Mon, 14 Jul 2025 14:17:35 +0200 Subject: [PATCH 2/8] feat: :memo: explain how to do versioning in template README --- template/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 template/README.md diff --git a/template/README.md b/template/README.md new file mode 100644 index 0000000..939d2df --- /dev/null +++ b/template/README.md @@ -0,0 +1,11 @@ +## Versioning and changelog + +This project uses +[Commitizen](https://commitizen-tools.github.io/commitizen/) to update +versions and generate changelogs. Based on the [Conventional +Commits](https://www.conventionalcommits.org/en/v1.0.0/) message, it +will automatically update the version in both `pyproject.toml` and +`datapackage.json`. The [data package](https://datapackage.org/) +standard suggests using their version of [Semantic +Versioning](https://datapackage.org/recipes/data-package-version/). So +follow this guide when making commits to this repository. From aa25b622bdbcac8ddcd5d032078e2831bdc073c3 Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 15 Jul 2025 09:06:58 +0200 Subject: [PATCH 3/8] refactor: :recycle: move content into jinja version of README --- template/README.md | 11 ----------- template/README.md.jinja | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 template/README.md diff --git a/template/README.md b/template/README.md deleted file mode 100644 index 939d2df..0000000 --- a/template/README.md +++ /dev/null @@ -1,11 +0,0 @@ -## Versioning and changelog - -This project uses -[Commitizen](https://commitizen-tools.github.io/commitizen/) to update -versions and generate changelogs. Based on the [Conventional -Commits](https://www.conventionalcommits.org/en/v1.0.0/) message, it -will automatically update the version in both `pyproject.toml` and -`datapackage.json`. The [data package](https://datapackage.org/) -standard suggests using their version of [Semantic -Versioning](https://datapackage.org/recipes/data-package-version/). So -follow this guide when making commits to this repository. diff --git a/template/README.md.jinja b/template/README.md.jinja index e69de29..939d2df 100644 --- a/template/README.md.jinja +++ b/template/README.md.jinja @@ -0,0 +1,11 @@ +## Versioning and changelog + +This project uses +[Commitizen](https://commitizen-tools.github.io/commitizen/) to update +versions and generate changelogs. Based on the [Conventional +Commits](https://www.conventionalcommits.org/en/v1.0.0/) message, it +will automatically update the version in both `pyproject.toml` and +`datapackage.json`. The [data package](https://datapackage.org/) +standard suggests using their version of [Semantic +Versioning](https://datapackage.org/recipes/data-package-version/). So +follow this guide when making commits to this repository. From b0357430eb698b8b8279474286cc3f1ca6999d18 Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 15 Jul 2025 09:17:05 +0200 Subject: [PATCH 4/8] docs: :memo: add instructions for setting up `release-project.yml` --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 18aad12..9cfea76 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ gh repo create NAME --template seedcase-project/template-data-package To add uv: -1. Delete the `pyproject.toml` file. -2. In the terminal run `uv init`. -3. Look at the Git pane and take what was removed and move it over into +1. Delete the `pyproject.toml` file. +2. In the terminal run `uv init`. +3. Look at the Git pane and take what was removed and move it over into the new `pyproject.toml` file. You can mimic what was done in `example-seed-beetle` repo. @@ -32,3 +32,17 @@ uv add --dev ruff commitizen pre-commit typos Use the commands found in [`spaid`](https://github.com/seedcase-project/spaid) repo to run the next setup steps. + +## Post-copy setup + +Some configuration is needed after copying this template to a new +repository, including configuration external to the repository. + +- The template file `.github/workflows/release-package.yml` requires + installing the + [auto-release-token](https://github.com/apps/auto-release-token) + GitHub App to be installed, as well as a GitHub secret called + `UPDATE_VERSION_TOKEN` and a variable called `UPDATE_VERSION_APP_ID` + to be set up in the repository (or organization) settings. See this + [guide](https://guidebook.seedcase-project.org/operations/security#using-github-apps-to-generate-tokens) + for more details on how to set this up. From 4baa13ae5c179dfb32d206d7846d5de19c56f38b Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 15 Jul 2025 14:48:47 +0200 Subject: [PATCH 5/8] refactor: :recycle: use `scripts/properties.py` version field instead --- template/.cz.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/.cz.toml b/template/.cz.toml index 3c64c6c..499f22b 100644 --- a/template/.cz.toml +++ b/template/.cz.toml @@ -4,7 +4,7 @@ update_changelog_on_bump = true version_provider = "uv" version_files = [ "pyproject.toml:version", - "datapackage.json:version" + "scripts/properties.py:version" ] # Don't regenerate the changelog on every update changelog_incremental = true From 7595f7ed5cf73124a4c2830c424d0a59b9e8cd93 Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 15 Jul 2025 15:47:39 +0200 Subject: [PATCH 6/8] fix: :bug: fix falling tests --- copier.yaml | 1 - justfile | 15 +++++++-------- .../.github/workflows/add-to-project.yml.jinja | 6 +++--- template/pyproject.toml.jinja | 4 ++-- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/copier.yaml b/copier.yaml index 00f2384..59254cd 100644 --- a/copier.yaml +++ b/copier.yaml @@ -1,7 +1,6 @@ _subdirectory: template # Questions: - package_github_repo: type: str default: "NA" diff --git a/justfile b/justfile index 314d9fc..1b9950f 100644 --- a/justfile +++ b/justfile @@ -31,15 +31,15 @@ check-spelling: test: #!/bin/zsh - temp_dir="_temp/test-data-package" - rm -rf $temp_dir - mkdir -p $temp_dir + test_dir="$(pwd)/_temp" + test_name="test-data-package" + rm -rf $test_dir # vcs-ref means the current commit/head, not a tag. # `.` means the current directory contains the template. - uvx copier copy --vcs-ref=HEAD . $temp_dir \ + uvx copier copy --vcs-ref=HEAD . $test_dir/$test_name \ --defaults \ - --data package_abbrev= "test-data-package" \ - --data package_github="first-last/test-data-package" \ + --data package_abbrev=$test_name \ + --data package_github_repo="first-last/${test_name}" \ --data author_given_name="First" \ --data author_family_name="Last" \ --data author_email="first.last@example.com" @@ -47,5 +47,4 @@ test: cleanup: #!/bin/zsh - temp_dir=$("_temp/test-data-package")) - rm -rf $temp_dir + rm -rf _temp diff --git a/template/.github/workflows/add-to-project.yml.jinja b/template/.github/workflows/add-to-project.yml.jinja index 5e50cce..c2c5d94 100644 --- a/template/.github/workflows/add-to-project.yml.jinja +++ b/template/.github/workflows/add-to-project.yml.jinja @@ -19,7 +19,7 @@ jobs: uses: seedcase-project/.github/.github/workflows/reusable-add-to-project.yml@main with: board-number: 18 - app-id: ${{ vars.ADD_TO_BOARD_APP_ID }} + app-id: {{ '${{ vars.ADD_TO_BOARD_APP_ID }}' }} secrets: - add-to-board-token: ${{ secrets.ADD_TO_BOARD }} - gh-token: ${{ secrets.GITHUB_TOKEN }} + add-to-board-token: {{ '${{ secrets.ADD_TO_BOARD }}' }} + gh-token: {{ '${{ secrets.GITHUB_TOKEN }}' }} diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index 6cb8105..998d740 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -21,11 +21,11 @@ dependencies = [ "seedcase-sprout>=0.46.3", ] -{{ if package_github != "NA" }} +{% if package_github_repo != "NA" %} [project.urls] issues = "https://github.com/{{ package_github_repo }}/issues" repository = "https://github.com/{{ package_github_repo }}" -{{ endif }} +{% endif %} [dependency-groups] dev = [ From 35d7e636c5cf48846fc421181640d877fb730493 Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 15 Jul 2025 15:48:09 +0200 Subject: [PATCH 7/8] docs: :pencil2: edits from review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Signe Kirk Brødbæk <40836345+signekb@users.noreply.github.com> --- template/README.md.jinja | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/README.md.jinja b/template/README.md.jinja index 216c43a..af5ad06 100644 --- a/template/README.md.jinja +++ b/template/README.md.jinja @@ -10,7 +10,7 @@ This project uses versions and generate changelogs. Based on the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) message, it will automatically update the version in both `pyproject.toml` and -`datapackage.json`. The [data package](https://datapackage.org/) +`datapackage.json`. The [Data Package](https://datapackage.org/) standard suggests using their version of [Semantic Versioning](https://datapackage.org/recipes/data-package-version/). So -follow this guide when making commits to this repository. +follow these conventions when making commits to this repository. From 03d9eef4317629ce0e6768e1592410f62a0d6f98 Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 15 Jul 2025 15:52:02 +0200 Subject: [PATCH 8/8] ci: :construction_worker: install zsh in workflow to fix test --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 64faeb9..89faf49 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,8 +21,8 @@ jobs: with: enable-cache: true - - name: Install justfile - run: sudo apt-get install -y just + - name: Install justfile and zsh + run: sudo apt install -y just zsh - name: Test and check template creation run: just test