From d0855098bd314b8b426dc6ccd3439c9862b82404 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Wed, 16 Oct 2024 23:23:59 +0900 Subject: [PATCH] move generate version expression to cli and remove old sh scripts --- flake.nix | 2 +- scripts/generate_kardinal_version.nix | 37 --------------------------- scripts/generate_kardinal_version.sh | 31 ---------------------- scripts/get-docker-tag.nix | 18 ------------- scripts/get-docker-tag.sh | 14 ---------- 5 files changed, 1 insertion(+), 101 deletions(-) delete mode 100755 scripts/generate_kardinal_version.nix delete mode 100755 scripts/generate_kardinal_version.sh delete mode 100644 scripts/get-docker-tag.nix delete mode 100755 scripts/get-docker-tag.sh diff --git a/flake.nix b/flake.nix index f6068ff8..e60699c1 100644 --- a/flake.nix +++ b/flake.nix @@ -87,7 +87,7 @@ }; }; - generateKardinalVersion = pkgs.callPackage ./scripts/generate_kardinal_version.nix { + generateKardinalVersion = pkgs.callPackage ./kardinal-cli/scripts/generate_kardinal_version.nix { inherit pkgs; }; diff --git a/scripts/generate_kardinal_version.nix b/scripts/generate_kardinal_version.nix deleted file mode 100755 index 01e6d15c..00000000 --- a/scripts/generate_kardinal_version.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ 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 - ''; -} diff --git a/scripts/generate_kardinal_version.sh b/scripts/generate_kardinal_version.sh deleted file mode 100755 index b13f1787..00000000 --- a/scripts/generate_kardinal_version.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/zsh - -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 \ No newline at end of file diff --git a/scripts/get-docker-tag.nix b/scripts/get-docker-tag.nix deleted file mode 100644 index c5384672..00000000 --- a/scripts/get-docker-tag.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ 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" - ''; -} \ No newline at end of file diff --git a/scripts/get-docker-tag.sh b/scripts/get-docker-tag.sh deleted file mode 100755 index d2c5b653..00000000 --- a/scripts/get-docker-tag.sh +++ /dev/null @@ -1,14 +0,0 @@ -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}" \ No newline at end of file