Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically generate/detect mod version #165

Open
MattSturgeon opened this issue Feb 4, 2024 · 0 comments
Open

Dynamically generate/detect mod version #165

MattSturgeon opened this issue Feb 4, 2024 · 0 comments
Labels
dev Only affects developers

Comments

@MattSturgeon
Copy link
Member

MattSturgeon commented Feb 4, 2024

Currently we set the mod version in gradle.properties and bump this value before doing a new release.

It may be useful to generate it instead, potentially reducing release friction and opening the door to "snapshot" builds, etc.

This may not be something you actually want; manually defining the version inherently comes with more control and less complexity. Feel free to label this issue wontfix.

Implementation

The algorithm would be something along the lines of:

  • Get some data from git;
    • Most recent ancestor tag (filtered by regex)
    • Number of commits since tag
    • Current branch name
    • Is the working directory clean or dirty
  • If 0 commits since tag, and the dir is clean, this is a release version
    • Handle if the commit has multiple tags; try to find the "version" tag
    • Set project.version to the tag
  • Otherwise, this is a "snapshot" build
    • Maybe do something like latest_tag+commit_count+dirty?

Complications

Simply implementing the above would kinda break patchChangelog, since it uses mod_version to determine what version to mark the "unreleased" changes as belonging to. Therefore we couldn't patch the changelog until after tagging the release commit, meaning we'd have to --amend it.

Probably the best way to avoid this would be three separate gradle tasks:

  • bumpMajorVersion: ++x.0.0
  • bumpMinorVersion: x.++y.0
  • bumpPatchVersion: x.y.++z

Running any of these tasks would detect the previous release, bump project.version, patch the changelog, commit & tag.

The release process would then become:

  1. Run gradlew bumpPatchVersion
  2. Run git push to push the new commit to the remote branch
  3. Run git push --tags or git push origin <tagname> to push the tags

These bumping tasks could still be added even without dynamic versions, but I'm mentioning them here as they solve the changlog patching issue.

@MattSturgeon MattSturgeon added the dev Only affects developers label Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev Only affects developers
Projects
None yet
Development

No branches or pull requests

1 participant