# Versioning

Liminalia's version (the engine version) is one number, and all of these use the same number.

- The engine's packages (`packages/*`)
- `lim --version` (`lim 0.2.0 (commit) Node v22…`)
- "About" in the authoring app (Liminalia Studio), and the version the app's updates compare against
- The VS Code extension
- The records of exported games (`engine` in `project/build.json`, and `build-history.jsonl` in the export folder)

The source is `version` in `package.json` at the top of the repository. Don't edit it by hand; change it with these commands.

```bash
npm run engine-version                          # the current version
npm run engine-version -- check                 # checks that everything matches (lists what doesn't and exits with 1)
npm run engine-version -- set 0.2.0             # raises the version
npm run engine-version -- set 0.2.0 --date 2026-12-01
npm run engine-version -- set 0.1.9 --force     # lowers it below the current version (stops without --force)
npm run engine-version -- tag                   # adds the tag v0.2.0 to HEAD after raising the version and committing (doesn't push)
npm run engine-version -- tag <commit>          # adds the tag later, to the commit that raised the version
npm run engine-version -- tag --dry-run         # only shows the tag and the commit
```

`set` rewrites `version` in the `package.json` at the top and in `packages/*`, their dependencies on `@liminalia/*`, and the same entries in `package-lock.json`,
changes the engine version that the game CI templates (the `.yml` files in `templates/ci`) take (`v0.2.0` in `LIMINALIA_ENGINE_REF`) to the new version's tag, turns "未公開" (unreleased) in [CHANGELOG.md](../CHANGELOG.md) into a "0.2.0 (date)" heading, and puts an empty "未公開" above it.
Without `--date`, the date is today's local date (not UTC). If nothing is written under "未公開", it still raises the version and says so.
A test (`packages/cli/test/version.test.ts`) also checks that everything matches.

## Number format

`major.minor.patch` (`1.2.3`). A version for trying out before release gets a suffix, as in `1.2.0-beta.1`.

## When to raise it

Raise the version when you make something to hand to people (building the authoring app to distribute, or adding a tag). Building without raising it makes different contents with the same number.

Before 1.0.0 (while it's 0.x):

| What to raise | When |
|---|---|
| Minor (0.1.17 → 0.2.0) | Changes that need games to be fixed: raising the script format version (`SCRIPT_FORMAT`; moved with `lim migrate`), the plugin API version (`PLUGIN_API_VERSION`) or the save format version (`SAVE_VERSION`), and changing what a `liminalia.json` setting means or a default behavior |
| Patch (0.1.17 → 0.1.18) | Everything else: bug fixes, new features that don't change how earlier games work, and changes to the authoring app only |

From 1.0.0:

| What to raise | When |
|---|---|
| Major | Changes that need games to be fixed (the same as "Minor" in the table above) |
| Minor | New features that earlier games keep working with |
| Patch | Bug fixes |

The three versions of the script format, the plugin API and the save format are counted separately from the engine version. Even when the engine version goes up,
earlier games and save data work as they are as long as these three don't change (the script format version is in [format.md](design/format.md), and the API version in [plugins.md](plugins.md)).

## How to raise it

1. Write the changes under "未公開" in CHANGELOG.md. Write the ones that affect game creators (the script, `liminalia.json`, saves, the plugin API and how exported games behave),
   and for the ones that need games to be fixed, start the line with "要対応" (action needed) and say how to fix it
2. `npm run engine-version -- set 0.2.0`
3. Pass the type check and the tests (including `npm run engine-version -- check`) and commit as `release: 0.2.0`
4. Add the tag `v0.2.0` with `npm run engine-version -- tag` (an annotated tag; it stops if there are uncommitted changes, the versions don't match, or changes are left under "未公開")
   and push it with `git push origin v0.2.0`. Pushing it runs the release workflow (`.github/workflows/release.yml`). The game CI templates (the three in `templates/ci` and the English one)
   and the export workflow Studio adds take this tag in `LIMINALIA_ENGINE_REF` instead of the engine's `main`, so CI from those templates can't get the engine until the tag is pushed.
   `lim new --ci` puts a template with the tag of that lim's version ([ci.md](ci.md), and "GitHub Pages" in [distribution.md](distribution.md)).
   For a version whose tag was forgotten, point at the commit that raised the version: `npm run engine-version -- tag <commit>`
5. Build the authoring app (`npm run studio:package -- mac`; the version defaults to the engine version). After publishing both Mac DMGs and the Windows installer in `skyt-a/liminalia-releases`, verify the downloads and update `studioVersion` in `site/src/data/version.ts`

`npm run studio:package -- mac --version <version>` can also build a trial authoring app with a number different from the engine version. The engine inside the app is then
given the same number (so `lim --version` inside the app and the export records match), and a warning says that it differs from the source. Build what you distribute after raising the version.

## How it differs from the game version

The game version (`version` in `liminalia.json`) is set by the game's creator. Each export records the game version and the engine version it used in the exported game's
`project/build.json` and in `build-history.jsonl` in the export folder ("Export records" in [distribution.md](distribution.md)).
Save data contains the game version, readable as `save.version` in expressions (how to move variables in older saves after an update is in "Save versions" in [format.md](design/format.md)).
