-
Notifications
You must be signed in to change notification settings - Fork 30
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]>
stevendborrelli
approved these changes
Nov 1, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
negz
added a commit
to negz/function-auto-ready
that referenced
this pull request
Nov 1, 2023
See crossplane/function-template-go#38. Signed-off-by: Nic Cope <[email protected]>
2 tasks
Confirmed the semantic version library we use will sort these correctly: https://go.dev/play/p/awYl-N0CzD4 |
Also tested by updating function-auto-ready in crossplane-contrib/function-auto-ready#11. It works as expected:
|
negz
added a commit
to negz/function-dummy
that referenced
this pull request
Nov 1, 2023
See crossplane/function-template-go#38. Signed-off-by: Nic Cope <[email protected]>
negz
added a commit
to negz/function-patch-and-transform
that referenced
this pull request
Nov 1, 2023
See crossplane/function-template-go#38. Signed-off-by: Nic Cope <[email protected]>
negz
added a commit
to negz/function-go-templating
that referenced
this pull request
Nov 1, 2023
See crossplane/function-template-go#38. Signed-off-by: Nic Cope <[email protected]>
2 tasks
negz
added a commit
to negz/function-cue
that referenced
this pull request
Nov 1, 2023
See crossplane/function-template-go#38 Signed-off-by: Nic Cope <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
Added or updated unit tests for my change.