-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add version cmd #280
base: main
Are you sure you want to change the base?
Changes from 11 commits
4e83a31
f8d4f9a
9799a46
308b457
e39d419
34e47c0
46cdbde
83f45f3
a867695
b26cfdd
ad86c2c
c0bcae3
35db686
21c2390
ed0f61a
fa3b84f
ad3f485
0f3d297
d085509
4784381
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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 | ||
| ) | ||
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| { pkgs, ... }: | ||
| pkgs.writeShellApplication { | ||
| name = "generate-kardinal-version"; | ||
| runtimeInputs = with pkgs; [ git ]; | ||
|
|
||
| text = '' | ||
| set -euo pipefail | ||
| script_dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| root_dirpath="$(dirname "$script_dirpath")" | ||
|
|
||
| KARDINAL_VERSION_PACKAGE_DIR="kardinal_version" | ||
| KARDINAL_VERSION_GO_FILE="kardinal_version.go" | ||
| KARDINAL_VERSION_PACKAGE_NAME="github.com/kurtosis-tech/kardinal/kardinal_version" | ||
| KARDINAL_VERSION_PACKAGE_GOSUM_PATH="go.sum" | ||
|
|
||
| show_helptext_and_exit() { | ||
| echo "Usage: $(basename "$0") new_version" | ||
| echo "" | ||
| echo " new_version The version to generate the version constants with, otherwise uses 'get-docker-tag.sh'" | ||
| echo "" | ||
| exit 1 | ||
| } | ||
|
|
||
| new_version="" | ||
|
|
||
| if [ -z "$new_version" ]; then | ||
| if ! cd "$root_dirpath"; then | ||
| echo "Error: Couldn't cd to the root of this repo, '$root_dirpath', which is required to get the Git tag" >&2 | ||
| show_helptext_and_exit | ||
| fi | ||
| if ! new_version="$(./scripts/get-docker-tag.sh)"; then | ||
| echo "Error: No new version provided and couldn't generate one" >&2 | ||
| show_helptext_and_exit | ||
| fi | ||
| 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 | ||
| ''; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/usr/bin/env bash | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this file? because I see there is a nix version
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we actually don't im gonna remove those
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get-docker-tag.sh is called by generate_kardinal_version.nix I wonder is there is a way to replace it with the nix version of this script?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ye i'm actually gonna embed the code for that directly in the generate nix |
||
|
|
||
| set -euo pipefail # Bash "strict mode" | ||
| script_dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| root_dirpath="$(dirname "${script_dirpath}")" | ||
|
|
||
| # ================================================================================================== | ||
| # Constants | ||
| # ================================================================================================== | ||
|
|
||
| KARDINAL_VERSION_PACKAGE_DIR="kardinal_version" | ||
| KARDINAL_VERSION_GO_FILE="kardinal_version.go" | ||
| KARDINAL_VERSION_PACKAGE_NAME="github.com/kurtosis-tech/kardinal/kardinal_version" | ||
| KARDINAL_VERSION_PACKAGE_GOSUM_PATH="go.sum" | ||
|
|
||
|
|
||
| # ================================================================================================== | ||
| # Arg Parsing & Validation | ||
| # ================================================================================================== | ||
| show_helptext_and_exit() { | ||
| echo "Usage: $(basename "${0}") new_version" | ||
| echo "" | ||
| echo " new_version The version to be generate the version constants with, otherwise uses 'get-docker-tag.sh'" | ||
| echo "" | ||
| exit 1 | ||
| } | ||
|
|
||
|
|
||
| # ================================================================================================== | ||
| # Main Logic | ||
| # ================================================================================================== | ||
| new_version="${1:-}" | ||
|
|
||
| if [ -z "${new_version}" ]; then | ||
| if ! cd "${root_dirpath}"; then | ||
| echo "Error: Couldn't cd to the root of this repo, '${root_dirpath}', which is required to get the Git tag" >&2 | ||
| show_helptext_and_exit | ||
| fi | ||
| if ! new_version="$(./scripts/get-docker-tag.sh)"; then | ||
| echo "Error: No new version provided and couldn't generate one" >&2 | ||
| show_helptext_and_exit | ||
| fi | ||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { pkgs, ... }: | ||
| pkgs.writeShellApplication { | ||
| name = "get-docker-tag"; | ||
| runtimeInputs = with pkgs; [ git ]; | ||
|
|
||
| text = '' | ||
| set -euo pipefail | ||
|
|
||
| if ! git status > /dev/null; then | ||
| echo "Error: This command was run from outside a git repo" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| commit_sha="$(git rev-parse --short=6 HEAD)" | ||
| suffix="$(git diff --quiet || echo '-dirty')" | ||
| echo "$commit_sha$suffix" | ||
| ''; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| set -euo pipefail # Bash "strict mode" | ||
|
|
||
| # ================================================================================================== | ||
| # Main Logic | ||
| # ================================================================================================== | ||
|
|
||
| if ! git status > /dev/null; then | ||
| echo "Error: This command was run from outside a git repo" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| commit_sha="$(git rev-parse --short=6 HEAD)" | ||
| suffix="$(git diff --quiet || echo '-dirty')" | ||
| echo "${commit_sha}${suffix}" |
Uh oh!
There was an error while loading. Please reload this page.