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 diff --git a/README.md b/README.md index 1f0c79a..c1247ee 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,18 @@ spaid_gh_set_repo_settings -h spaid_gh_ruleset_basic_protect_main -h ``` +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. + ## Features - Use [uv](https://docs.astral.sh/uv/) to manage the Data Package. 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/.cz.toml b/template/.cz.toml new file mode 100644 index 0000000..499f22b --- /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", + "scripts/properties.py:version" +] +# Don't regenerate the changelog on every update +changelog_incremental = true 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/.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 }} diff --git a/template/README.md.jinja b/template/README.md.jinja index d993122..af5ad06 100644 --- a/template/README.md.jinja +++ b/template/README.md.jinja @@ -1,3 +1,16 @@ + ## Post-setup steps - Run `just list-todos` to get a list of TODO items you need to fill out. + +## 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 these conventions when making commits to this repository. 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 = [