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

Use Go style pseudo-versions when there is no semver supplied #38

Merged
merged 1 commit into from
Nov 1, 2023

Conversation

negz
Copy link
Member

@negz negz commented Nov 1, 2023

Description of your changes

The CI workflow uses a semver (e.g. v1.0.0) when you run it using the workflow_dispatch trigger and supply one explicitly. This is how you 'release' a function.

Today when the workflow runs for a PR or regular main branch build we default to v0.0.0-<git-short-sha> (e.g. v0.0.0-9be3d00). This is a very simple way to tag development builds with no user input required. It's handy that the resulting package can be correlated to the git commit that produced it using the git SHA.

A major flaw of this implementation is that newer SHAs do not sort above older SHAs when treated as semantic versions.

This commit switches us to a simple approximation of the Go pseudoversions you would see in a go.mod file, as described by https://go.dev/ref/mod#pseudo-versions. These versions include the git commit time before the SHA, so newer commits will be considered newer versions when processing the semver. We also switch to using the first 12 characters of the SHA. This reduces the risk of collision, and makes us match exactly Go's pseudoversion implementation.

Development packages will now be pushed with a tag like v0.0.0-20231101115142-1091066df799.

I have:

The CI workflow uses a semver (e.g. v1.0.0) when you run it using the
workflow_dispatch trigger and supply one explicitly. This is how you
'release' a function.

Today when the workflow runs for a PR or regular main branch build we
default to v0.0.0-<git-short-sha>. This is a very simple way to tag
development builds with no user input required. It's handy that the
resulting package can be correlated to the git commit that produced it
using the git SHA.

A major flaw of this implementation is that newer SHAs do not sort above
older SHAs when treated as semantic versions.

This commit switches us to a simple approximation of the Go
pseudoversions you would see in a go.mod file, as described by
https://go.dev/ref/mod#pseudo-versions. These versions include the git
commit time before the SHA, so newer commits will be considered newer
versions when processing the semver. We also switch to using the first
12 characters of the SHA. This reduces the risk of collision, and makes
us match exactly Go's pseudoversion implementation.

Signed-off-by: Nic Cope <[email protected]>
Copy link
Collaborator

@stevendborrelli stevendborrelli left a comment

Choose a reason for hiding this comment

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

LGTM

@negz
Copy link
Member Author

negz commented Nov 1, 2023

Confirmed the semantic version library we use will sort these correctly: https://go.dev/play/p/awYl-N0CzD4

@negz
Copy link
Member Author

negz commented Nov 1, 2023

Also tested by updating function-auto-ready in crossplane-contrib/function-auto-ready#11. It works as expected:

2023-11-01T23:02:21Z	DEBUG	Wrote OCI index	{"ref": "xpkg.upbound.io/crossplane-contrib/function-auto-ready:v0.0.0-20231101225931-60aea09d94c8", "manifests": 2}

@negz negz merged commit 115b4a4 into crossplane:main Nov 1, 2023
6 checks passed
@negz negz deleted the sortie branch November 1, 2023 23:04
negz added a commit to negz/function-dummy that referenced this pull request Nov 1, 2023
negz added a commit to negz/function-patch-and-transform that referenced this pull request Nov 1, 2023
negz added a commit to negz/function-go-templating that referenced this pull request Nov 1, 2023
negz added a commit to negz/function-cue that referenced this pull request Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants