-
Notifications
You must be signed in to change notification settings - Fork 82
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
Version constant injection #576
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7e0c73b
inject version at build time
lukellmann 9977407
fix CI with mavenCentral()?
lukellmann 533ab86
fix CI with gradlePluginPortal()?
lukellmann ec23622
fix CI with mavenCentral() for buildscript?
lukellmann 85270e9
inject commit hash
lukellmann 953e96a
documentation for KORD_COMMIT_HASH
lukellmann 0c8b70d
compute short commit hash in github actions
lukellmann 411c5f5
set short sha in release job
lukellmann dcd2f50
experimental annotations
lukellmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
// No const vals, they are inlined, so recompiling would be required when values change. | ||
@file:Suppress("MayBeConstant") | ||
|
||
package dev.kord.common | ||
|
||
public object KordConstants { | ||
|
||
/** Kord's version. */ | ||
public val KORD_VERSION: String = BUILD_CONFIG_GENERATED_LIBRARY_VERSION | ||
|
||
/** The hash of the commit from which this Kord version was built. */ | ||
public val KORD_COMMIT_HASH: String = BUILD_CONFIG_GENERATED_COMMIT_HASH | ||
|
||
/** URL for Kord's GitHub repository. */ | ||
public val KORD_GITHUB_URL: String = "https://github.com/kordlib/kord" | ||
|
||
/** Kord's value for the [User Agent header](https://discord.com/developers/docs/reference#user-agent). */ | ||
public const val USER_AGENT: String = "DiscordBot (https://github.com/kordlib/kord, 0.8.0-M12)" | ||
public val USER_AGENT: String = "DiscordBot ($KORD_GITHUB_URL, $KORD_VERSION)" | ||
} |
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.
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.
Github allows you to get the commit hash, why is this logic code introduced.
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.
You are referring to the
GITHUB_SHA
environment variable, right? This one is the full hash, @DRSchlaubi wanted to have the short one if available (retrieved bygit rev-parse --short HEAD
).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.
Github doesn't provide that? in the environment?
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.
I didn't search too long, maybe they do. Do you know more?
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.
https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables only lists the long SHA
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.
Maybe we should compute the short hash in the actions instead (like here).
It would probably also be good to provide
KORD_COMMIT_HASH
andKORD_SHORT_COMMIT_HASH
.