Skip to content

Commit e02f93e

Browse files
lwjohnst86signekb
andauthored
feat: ✨ add Commitizen version bump with GitHub workflow (#71)
# Description Adding auto-version update workflow via Commitizen. Right now though, I don't know if the `version_files` will work though, since it is basic "search and replace for version number in the given files". The `datapackage.json` file will/may have two `version` fields, one in the top level and another in the `sources` level. So this might also bump those versions too (like we had an issue with in Sprout). So we'll have to see how it goes. Closes #51 Closes #55 This PR needs a quick review. --------- Co-authored-by: Signe Kirk Brødbæk <[email protected]>
1 parent aba42e9 commit e02f93e

File tree

9 files changed

+70
-16
lines changed

9 files changed

+70
-16
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
with:
2222
enable-cache: true
2323

24-
- name: Install justfile
25-
run: sudo apt-get install -y just
24+
- name: Install justfile and zsh
25+
run: sudo apt install -y just zsh
2626

2727
- name: Test and check template creation
2828
run: just test

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ spaid_gh_set_repo_settings -h
3434
spaid_gh_ruleset_basic_protect_main -h
3535
```
3636

37+
Some configuration is needed after copying this template to a new
38+
repository, including configuration external to the repository.
39+
40+
- The template file `.github/workflows/release-package.yml` requires
41+
installing the
42+
[auto-release-token](https://github.com/apps/auto-release-token)
43+
GitHub App to be installed, as well as a GitHub secret called
44+
`UPDATE_VERSION_TOKEN` and a variable called `UPDATE_VERSION_APP_ID`
45+
to be set up in the repository (or organization) settings. See this
46+
[guide](https://guidebook.seedcase-project.org/operations/security#using-github-apps-to-generate-tokens)
47+
for more details on how to set this up.
48+
3749
## Features
3850

3951
- Use [uv](https://docs.astral.sh/uv/) to manage the Data Package.

copier.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
_subdirectory: template
22

33
# Questions:
4-
54
package_github_repo:
65
type: str
76
default: "NA"

justfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,20 @@ check-spelling:
3131

3232
test:
3333
#!/bin/zsh
34-
temp_dir="_temp/test-data-package"
35-
rm -rf $temp_dir
36-
mkdir -p $temp_dir
34+
test_dir="$(pwd)/_temp"
35+
test_name="test-data-package"
36+
rm -rf $test_dir
3737
# vcs-ref means the current commit/head, not a tag.
3838
# `.` means the current directory contains the template.
39-
uvx copier copy --vcs-ref=HEAD . $temp_dir \
39+
uvx copier copy --vcs-ref=HEAD . $test_dir/$test_name \
4040
--defaults \
41-
--data package_abbrev= "test-data-package" \
42-
--data package_github="first-last/test-data-package" \
41+
--data package_abbrev=$test_name \
42+
--data package_github_repo="first-last/${test_name}" \
4343
--data author_given_name="First" \
4444
--data author_family_name="Last" \
4545
--data author_email="[email protected]"
4646
# TODO: Other checks/tests?
4747

4848
cleanup:
4949
#!/bin/zsh
50-
temp_dir=$("_temp/test-data-package"))
51-
rm -rf $temp_dir
50+
rm -rf _temp

template/.cz.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[tool.commitizen]
2+
bump_message = "build(version): :bookmark: update version from $current_version to $new_version [skip ci]"
3+
update_changelog_on_bump = true
4+
version_provider = "uv"
5+
version_files = [
6+
"pyproject.toml:version",
7+
"scripts/properties.py:version"
8+
]
9+
# Don't regenerate the changelog on every update
10+
changelog_incremental = true

template/.github/workflows/add-to-project.yml.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: seedcase-project/.github/.github/workflows/reusable-add-to-project.yml@main
2020
with:
2121
board-number: 18
22-
app-id: ${{ vars.ADD_TO_BOARD_APP_ID }}
22+
app-id: {{ '${{ vars.ADD_TO_BOARD_APP_ID }}' }}
2323
secrets:
24-
add-to-board-token: ${{ secrets.ADD_TO_BOARD }}
25-
gh-token: ${{ secrets.GITHUB_TOKEN }}
24+
add-to-board-token: {{ '${{ secrets.ADD_TO_BOARD }}' }}
25+
gh-token: {{ '${{ secrets.GITHUB_TOKEN }}' }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Release package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
# Limit token permissions for security
9+
permissions: read-all
10+
11+
jobs:
12+
release:
13+
# This job outputs env variables `previous_version` and `current_version`.
14+
# Only give permissions for this job.
15+
permissions:
16+
contents: write
17+
uses: seedcase-project/.github/.github/workflows/reusable-release-project.yml@main
18+
with:
19+
app-id: ${{ vars.UPDATE_VERSION_APP_ID }}
20+
secrets:
21+
update-version-gh-token: ${{ secrets.UPDATE_VERSION_TOKEN }}

template/README.md.jinja

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
12
## Post-setup steps
23

34
- Run `just list-todos` to get a list of TODO items you need to fill out.
5+
6+
## Versioning and changelog
7+
8+
This project uses
9+
[Commitizen](https://commitizen-tools.github.io/commitizen/) to update
10+
versions and generate changelogs. Based on the [Conventional
11+
Commits](https://www.conventionalcommits.org/en/v1.0.0/) message, it
12+
will automatically update the version in both `pyproject.toml` and
13+
`datapackage.json`. The [Data Package](https://datapackage.org/)
14+
standard suggests using their version of [Semantic
15+
Versioning](https://datapackage.org/recipes/data-package-version/). So
16+
follow these conventions when making commits to this repository.

template/pyproject.toml.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ dependencies = [
2121
"seedcase-sprout>=0.46.3",
2222
]
2323

24-
{{ if package_github != "NA" }}
24+
{% if package_github_repo != "NA" %}
2525
[project.urls]
2626
issues = "https://github.com/{{ package_github_repo }}/issues"
2727
repository = "https://github.com/{{ package_github_repo }}"
28-
{{ endif }}
28+
{% endif %}
2929

3030
[dependency-groups]
3131
dev = [

0 commit comments

Comments
 (0)