1

I am currently trying to solve a versioning problem in my application: I want to use the git tag as a version number inside a JetBrains Space automation script.

My .space.kts is based on a template from the official docs and contains the following relevant job:

job("Deploy") {
    container("Run deploy script", image = "gradle:7.1-jre11") {
        kotlinScript { api ->
            // ...

            api.space().projects.automation.deployments.schedule(
                project = api.projectIdentifier(),
                targetIdentifier = TargetIdentifier.Key("production-server"),
                version = "1.0.0" // Here, I need the git tag
            )
        }
    }
}

I have not been able to find a good solution. And I am wondering why that is:

  • Did I not manage to research correctly?
  • Is my approach not sensible?
  • If so, what would be considered best-practices for setting a version? Are there resources I can use to learn?

Most example I saw, used the build execution number or some other env variable to compose a version number. But I cannot really make sense of that approach, since I want to adhere to semver, have git tags to organize VCS and automate this process.

Thanks for your help in clarifying the issue.

Rico Herwig
  • 1,672
  • 14
  • 23
  • 1
    Tags are *assigned*, either by humans or by some automation system (semantic version automation). They don't *come from* Git, they are *given to* Git. Have whatever *assigned* this tag pass it to your build process. Anything else is sheer insanity: even if it can be done (sometimes it can), it's utterly backwards. (The typical problem comes about when there's both an auto-assigned tag, `v0.97.1`, *and* a human-readable tag, `beta-test-3`, for this version: which one should you use? Use the one someone *tells you* to use, don't just guess.) – torek Dec 17 '22 at 15:18
  • Thanks for clarifying! This is valuable advice for me, being new to the scene. – Rico Herwig Dec 17 '22 at 16:13
  • What are your triggers for this job? (what's in the `startOn` block?) – Joffrey Mar 06 '23 at 11:30

0 Answers0