- Shell 100%
| hooks | ||
| auto-tag.sh | ||
| auto-version.sh | ||
| lib.sh | ||
| README.md | ||
| setup.sh | ||
| test.sh | ||
foundry-vtt-autorelease
"AI" disclosure
Some or all of the code in this repository was generated with the assistance of LLM-based tools.
AI-generated code is not automatically owned by the person who generated it. No claim of ownership is made over third-party code or material included in this repository.
If you believe any code in this repository infringes your copyright, please contact me with the relevant details and I will review the matter and remove the material if appropriate.
This repository is intended for personal use only. The code is provided "as is", without warranties of any kind. I accept no responsibility or liability for any damage, data loss, security issues or other consequences resulting from its use.
Use this code at your own risk. You have been warned.
About
Shared git hooks that version, tag and release Foundry VTT modules. Add this repo as a git submodule to a module repo. Everything module-specific is read from the module's module.json and its origin remote, so the same scripts work for every module.
What it does
On every commit in the module repo:
- pre-commit (
auto-version.sh)- bumps the patch version in
module.json(0.1.4→0.1.5). The base is the higher ofmodule.json's version and the latestvX.Y.Ztag, so a version is never reused. - rewrites
url,manifestanddownloadfrom theoriginremote (see URL rules). - stages
module.jsoninto the commit.
- bumps the patch version in
- post-commit (
auto-tag.sh)- amends
module.jsoninto the commit if a pathspec commit (git commit -- file) left it out. - creates the annotated tag
v<version>on the commit. - on the default branch, runs
git push origin HEAD --follow-tags. ThemanifestURL points at the branch, so the branch and the tag must both reach the remote for Foundry to see the update.
- amends
The version in module.json must be strict X.Y.Z. To bump minor or major, set e.g. "version": "0.2.0" by hand. The next commit will release 0.2.1.
Requirements
- bash, git
jqmodule.jsonat the root of the module repo, withidandversion- an
originremote. Without one, onlyversionis bumped and nothing is pushed.
Install in a module repo
git submodule add https://code.chuggybumba.com/thanius/foundry-vtt-autorelease.git foundry-vtt-autorelease
./foundry-vtt-autorelease/setup.sh
git commit -m "Add foundry-vtt-autorelease"
setup.sh sets core.hooksPath in the module repo to foundry-vtt-autorelease/hooks. The submodule can live at any path; setup.sh works out the relative path itself.
After cloning a module repo
core.hooksPath is local git config and is not cloned. Run setup once per clone:
git clone --recurse-submodules <module repo url>
cd <module repo>
./foundry-vtt-autorelease/setup.sh
If you cloned without --recurse-submodules, run git submodule update --init first.
Updating the hooks
git submodule update --remote foundry-vtt-autorelease
git commit -m "Update foundry-vtt-autorelease"
URL rules
The web URL comes from git remote get-url origin. These forms all become https://host/owner/repo:
| origin | web URL |
|---|---|
git@host:owner/repo.git |
https://host/owner/repo |
ssh://git@host:2222/owner/repo.git |
https://host/owner/repo (ssh port dropped) |
https://user@host:3000/owner/repo.git |
https://host:3000/owner/repo (http port kept) |
The default branch is the target of origin/HEAD, or main if that is not set (set it with git remote set-head origin --auto).
| field | Forgejo / Gitea / Codeberg | GitHub |
|---|---|---|
url |
https://host/owner/repo |
https://github.com/owner/repo |
manifest |
<url>/raw/branch/<branch>/module.json |
https://raw.githubusercontent.com/owner/repo/<branch>/module.json |
download |
<url>/archive/v<version>.zip |
<url>/archive/refs/tags/v<version>.zip |
Any host other than github.com gets the Forgejo/Gitea paths. GitLab is not supported.
Skipping
| variable | effect |
|---|---|
AUTORELEASE_SKIP_AUTOVERSION=1 |
no version bump on this commit |
AUTORELEASE_SKIP_AUTOTAG=1 |
no tag or push on this commit |
AUTORELEASE_SKIP_AUTOVERSION=1 AUTORELEASE_SKIP_AUTOTAG=1 git commit -m "docs only"
git commit --no-verify skips pre-commit only. post-commit still runs and tags the unchanged version, or fails if that tag already exists.
Migrating from per-repo copies
Old repos may carry their own auto-version.sh, auto-tag.sh, setup-git-hooks.sh and .githooks/. To switch:
git rm auto-version.sh auto-tag.sh setup-git-hooks.sh .githooks/pre-commit .githooks/post-commit
git submodule add https://code.chuggybumba.com/thanius/foundry-vtt-autorelease.git foundry-vtt-autorelease
./foundry-vtt-autorelease/setup.sh
git commit -m "Use foundry-vtt-autorelease"
Rename any <MODULE>_SKIP_AUTOVERSION / <MODULE>_SKIP_AUTOTAG env vars to the AUTORELEASE_ names.
Testing
bash test.sh
Builds a throwaway module repo with this repo as a submodule, commits through the hooks, and checks the version, tags, URLs and pushes to a local bare repo. No network needed.