#dagger versioning
1 messages ยท Page 1 of 1 (latest)
Hello! Do you mean versioning of dagger modules?
Dagger modules use git as the source of truth. The git repository is the registry; git tags and branches can be used as versions
No sorry, I mean applying semantic versioning 2.0 in my CICD Pipelines
and git commits are used for pinning
I would like to automatically generate versioned tags when pipelines get triggered on stable, dev, and pre-release branches.
Basically I need semver to push versioned artifacts on OCI registries for my FluxCD GitOps operator to pull from based on some ImagePolicy
Sounds like you're looking to find (or may need to build) a Dagger function that gives you tags out. What are the inputs? Previous state of git? Previous tags? Type of branch: dev/pre-release/stable, etc
yes, correct.
I guess that as input there is the need for some git context (previous tags, branch that triggered the pipeline, type of action pr/push ...).
If I understood correctl, in yaml defined CICD systems like Gitlab, a lot of people are using this npm package called semver for doing this (inside the Job's Container, of course)
We're using https://gitversion.net/docs/ (a dotnet tool) to do exactly that - within a dedicated Dagger module, then pass on the generated version to the next steps of our CI/CD pipeline
Notice that using the git api in Dagger such as git https://github.com/dagger/dagger | branch main | tree
.git/packed-refs
.git/refs/tags/main
.git/shallow
and some other differences compared to git clone and then read in the Directory.
With the shallow clone, I don't get the right output from dotnet-gitversion
But if fed a local dir like from a previous git clone https://github.com/dagger/dagger then it works well
import dagger
from dagger import dag, function, object_type
@object_type
class GitVersion:
@function
def container(self, version: str = "6.1.0-alpine.3.20-9.0") -> dagger.Container:
"""Returns a gitversion container at provided version"""
return dag.container().from_("gittools/gitversion:"+ version)
@function
async def version(self, repo: dagger.Directory) -> str:
"""Returns gitversion output for the provided repo Directory"""
return await (
self.container()
.with_mounted_directory("/repo", repo)
.with_workdir("/repo")
.with_exec(["/tools/dotnet-gitversion"])
.stdout()
)
{
"AssemblySemFileVer": "0.16.3.0",
"AssemblySemVer": "0.16.3.0",
"BranchName": "main",
"BuildMetaData": null,
"CommitDate": "2025-03-06",
"CommitsSinceVersionSource": 44,
"EscapedBranchName": "main",
"FullBuildMetaData": "Branch.main.Sha.07b0cd6c664ffb2fef63fd98eee0b8bb89cebae7",
"FullSemVer": "0.16.3-44",
"InformationalVersion": "0.16.3-44+Branch.main.Sha.07b0cd6c664ffb2fef63fd98eee0b8bb89cebae7",
"Major": 0,
"MajorMinorPatch": "0.16.3",
"Minor": 16,
"Patch": 3,
"PreReleaseLabel": "",
"PreReleaseLabelWithDash": "",
"PreReleaseNumber": 44,
"PreReleaseTag": "44",
"PreReleaseTagWithDash": "-44",
"SemVer": "0.16.3-44",
"Sha": "07b0cd6c664ffb2fef63fd98eee0b8bb89cebae7",
"ShortSha": "07b0cd6",
"UncommittedChanges": 0,
"VersionSourceSha": "b3e6f765a547b22edc61a24336177348b9f00d94",
"WeightedPreReleaseNumber": 55044
}
with dagger -i -c 'version $(git https://github.com/dagger/dagger | branch main | tree)'
{
"AssemblySemFileVer": "0.0.1.0",
"AssemblySemVer": "0.0.1.0",
"BranchName": "main",
"BuildMetaData": null,
"CommitDate": "2025-03-06",
"CommitsSinceVersionSource": 1,
"EscapedBranchName": "main",
"FullBuildMetaData": "Branch.main.Sha.07b0cd6c664ffb2fef63fd98eee0b8bb89cebae7",
"FullSemVer": "0.0.1-1",
"InformationalVersion": "0.0.1-1+Branch.main.Sha.07b0cd6c664ffb2fef63fd98eee0b8bb89cebae7",
"Major": 0,
"MajorMinorPatch": "0.0.1",
"Minor": 0,
"Patch": 1,
"PreReleaseLabel": "",
"PreReleaseLabelWithDash": "",
"PreReleaseNumber": 1,
"PreReleaseTag": "1",
"PreReleaseTagWithDash": "-1",
"SemVer": "0.0.1-1",
"Sha": "07b0cd6c664ffb2fef63fd98eee0b8bb89cebae7",
"ShortSha": "07b0cd6",
"UncommittedChanges": 0,
"VersionSourceSha": "",
"WeightedPreReleaseNumber": 55001
}
@silent maybe related? https://github.com/moby/moby/issues/43873#issuecomment-1202025590@949034677610643507> Sorry for botching the @silent 
i'm actually planning on fixing this soon! and adding a ton more configurability to git clones ๐
yeah, I would like to know to .. not sure what the conclusion were ?
I played around with this and there are (limiting it to go-lang native impl ?)
SVU https://github.com/caarlos0/svu
and
NVS https://github.com/purpleclay/nsv
which has a module in daggerverse ?
https://daggerverse.dev/mod/github.com/purpleclay/daggerverse/nsv@910e1ac9754f208569ac4d65f1ef52d9a2301833
The NSV dagger module is intriguing me, I think I am going to try this out (only I am using SDK=Java, I hope this is not a problem)
You can use Dagger modules written in any SDK with any other SDK, so from a Java SDK module, dagger install <any other dagger mod written in Go, TS, PHP, Python, Java, Elixir, whatever> should be no problem ๐
sry, yes limiting it to go-lang was my preference
Ok thanks a lot, now I know that if I will have problems it will just be because of my ignorance ๐