This repository was archived by the owner on Jan 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
feat: add version cmd #280
Open
tedim52
wants to merge
20
commits into
main
Choose a base branch
from
tedi/version
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4e83a31
add version cmd
tedim52 f8d4f9a
update err msg
tedim52 9799a46
update nix flakes
tedim52 308b457
create kardinal version module
tedim52 e39d419
use kurtosis version pkg to print version
tedim52 34e47c0
add kardinal version to go workspace
tedim52 46cdbde
add generate version to nix flake and shell
tedim52 83f45f3
add nix files for generating kardinal version
tedim52 a867695
fix get docker tag
tedim52 b26cfdd
fix nix scripts
tedim52 ad86c2c
fix nix again
tedim52 c0bcae3
fix script
tedim52 35db686
adjust flake and shell nix
tedim52 21c2390
change root path calculation
tedim52 ed0f61a
update shell script
tedim52 fa3b84f
pull tag
tedim52 ad3f485
add generate version to kardinal cli
tedim52 0f3d297
call expression before building cli golang app
tedim52 d085509
move generate version expression to cli and remove old sh scripts
tedim52 4784381
update shell nix
tedim52 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -6,4 +6,5 @@ use ( | |
| ./libs/cli-kontrol-api | ||
| ./kardinal-cli | ||
| ./sidecars/redis-overlay-service | ||
| ./kardinal_version | ||
| ) | ||
This file contains hidden or 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 hidden or 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,20 +1,28 @@ | ||
| { | ||
| pkgs, | ||
| commit_hash ? "dirty", | ||
| pkgs, | ||
| commit_hash ? "dirty" | ||
| }: let | ||
| pname = "kardinal.cli"; | ||
|
|
||
| generateKardinalVersion = pkgs.callPackage ./scripts/generate_kardinal_version.nix { | ||
| inherit pkgs; | ||
| }; | ||
| _ = pkgs.runCommand "generate-version" { | ||
| buildInputs = [ generateKardinalVersion ]; | ||
| }; | ||
|
|
||
| ldflags = pkgs.lib.concatStringsSep "\n" [ | ||
| "-X github.com/kurtosis-tech/kurtosis/kardinal.AppName=${pname}" | ||
| "-X github.com/kurtosis-tech/kurtosis/kardinal.Commit=${commit_hash}" | ||
| ]; | ||
| in | ||
| pkgs.buildGoApplication { | ||
| # pname has to match the location (folder) where the main function is or use | ||
| # subPackges to specify the file (e.g. subPackages = ["some/folder/main.go"];) | ||
| # subPackages to specify the file (e.g. subPackages = ["some/folder/main.go"];) | ||
| inherit pname ldflags; | ||
| name = "${pname}"; | ||
| pwd = ./.; | ||
| src = ./.; | ||
| modules = ./gomod2nix.toml; | ||
| CGO_ENABLED = 0; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { pkgs, ... }: | ||
| pkgs.writeShellApplication { | ||
| name = "generate-kardinal-version"; | ||
| runtimeInputs = with pkgs; [ git ]; | ||
|
|
||
| text = '' | ||
| set -euo pipefail | ||
| root_dirpath=$(git rev-parse --show-toplevel) | ||
|
|
||
| KARDINAL_VERSION_PACKAGE_DIR="kardinal_version" | ||
| KARDINAL_VERSION_GO_FILE="kardinal_version.go" | ||
|
|
||
| # Check if the current commit has a tag | ||
| if git describe --tags --exact-match > /dev/null 2>&1; then | ||
| # If there's an exact match to a tag, use the tag as the version | ||
| new_version="$(git describe --tags --exact-match)" | ||
| else | ||
| # Otherwise, use the short commit SHA | ||
| commit_sha="$(git rev-parse --short=6 HEAD)" | ||
| # Check if the working directory is dirty | ||
| suffix="$(git diff --quiet || echo '-dirty')" | ||
| new_version="$commit_sha$suffix" | ||
| fi | ||
|
|
||
| kardinal_version_go_file_abs_path="$root_dirpath/$KARDINAL_VERSION_PACKAGE_DIR/$KARDINAL_VERSION_GO_FILE" | ||
|
|
||
| cat << EOF > "$kardinal_version_go_file_abs_path" | ||
| package $KARDINAL_VERSION_PACKAGE_DIR | ||
|
|
||
| const ( | ||
| // !!!!!!!!!!!!!!!!!! DO NOT MODIFY THIS! IT WILL BE UPDATED AUTOMATICALLY DURING THE BUILD PROCESS !!!!!!!!!!!!!!! | ||
| KardinalVersion = "$new_version" | ||
| // !!!!!!!!!!!!!!!!!! DO NOT MODIFY THIS! IT WILL BE UPDATED AUTOMATICALLY DURING THE BUILD PROCESS !!!!!!!!!!!!!!! | ||
| ) | ||
| EOF | ||
| ''; | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module github.com/kurtosis-tech/kardinal/kardinal_version | ||
|
|
||
| go 1.22.3 |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.