Skip to content

Add support for setting ZMK version#53

Merged
joelspadin merged 4 commits intozmkfirmware:mainfrom
joelspadin:zmk-versioning
Jan 11, 2026
Merged

Add support for setting ZMK version#53
joelspadin merged 4 commits intozmkfirmware:mainfrom
joelspadin:zmk-versioning

Conversation

@joelspadin
Copy link
Collaborator

@joelspadin joelspadin commented Jan 10, 2026

Added a new zmk version command, which can get the current ZMK version, change the version, and print available versions.

Updated zmk init with new options including one to set the ZMK version immediately.

Implements #52

@joelspadin joelspadin added the enhancement New feature or request label Jan 10, 2026
@caksoylar
Copy link
Contributor

Looks good thanks, I think we need to update the version in https://github.com/zmkfirmware/unified-zmk-config-template/blob/main/.github/workflows/build.yml as well.


# ls-remote output is "<hash> refs/tags/<tag>" for each tag.
# Return only the text after "refs/tags/".
tags = (line.split()[-1].removeprefix("refs/tags/") for line in lines)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to append main here or assume folks who need it would know to do zmk version main (which is also mentioned in the help message)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering the ability to specify a particular commit or branch as more of a power user thing. Having main show up in zmk version --list but not any other branches feels a little weird, but I guess it is more of a special case branch.

I think I'm leaning towards leaving it out, and if anyone complains, we can add it.

@joelspadin
Copy link
Collaborator Author

Looks good thanks, I think we need to update the version in https://github.com/zmkfirmware/unified-zmk-config-template/blob/main/.github/workflows/build.yml as well.

Done. Also changed it to set the default revision instead of the revision on the "zmk" project to match the current config template, plus fixed some issues that were changing the formatting of the file unintentionally.

name: Annotated[
str | None,
typer.Argument(help="Directory name where the repo should be cloned."),
] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth making one of these an Option, e.g. to be able to specify the name without the url. I'd vote for url to be an option and name to stay an argument.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following https://git-scm.com/docs/git-clone for this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess using the interactive mode asks for both separately, so it isn't very important either way.

Added a new "zmk version" command which can print the current ZMK
version, list available tagged versions, and switch to a new version.

Also added a new Remote class, which queries information about remote
Git repositories, and some new utility methods on Repo to get remote and
West manifest information. Updated some existing commands to use these.

Partially implements zmkfirmware#52
The "zmk init" command now supports arguments for setting the URL and
clone directory directly instead of prompting for them.

It also now has a --zmk-version option, which switches to the given
revision of ZMK prior to running "west update". If the selected revision
does not exist, then it leaves the version unchanged.

Finishes implementing zmkfirmware#52
Updated the YAML editing code to work around an issue where blank lines
and multi-line comments weren't handled correctly, resulting in blank
lines getting deleted and new blank lines getting inserted in comments.

Also changed the default indentation to match what is used in the ZMK
config template, and enabled preserving quotes by default.
Provided the user is still using the default GitHub workflow, the
"zmk version" command will now update that to point to the correct
revision of ZMK as well.

Also reworked the logic for updating the version in the West manifest
to set manifest.defaults.revision instead of setting the revision on the
ZMK project. This matches what is now done in the config template, which
allows updating the version in one place for any modules that tag
commits to match ZMK versions.
@joelspadin joelspadin merged commit d1bf5b6 into zmkfirmware:main Jan 11, 2026
1 check passed
@joelspadin joelspadin deleted the zmk-versioning branch January 11, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants