From 89b38ff3dcf0b59ea148a08cb8ad4fb5c1814b97 Mon Sep 17 00:00:00 2001 From: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:01:31 +0200 Subject: [PATCH] Adds more comments on what the expressions does Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> --- scripts/release | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/scripts/release b/scripts/release index 6d32fa0..eb2ca8f 100755 --- a/scripts/release +++ b/scripts/release @@ -27,11 +27,17 @@ log::warn() { ### Utils functions ### -------------------------------------------------------------------------------------------------------------------- +### Permits us to know if the current target environment +### is a windows platform or not. is_windows() { local -r target="$1" echo "$target" | grep -q "windows" } +### NOTE: This function is currently not in use but kept as +### a backup function in case something breaks +### +### Returns the target environment, with a fix for the x86_64 target. get_env_target() { eval "$(rustc --print cfg | grep target)" local -rr raw="${target_arch:-}-${target_vendor:-}-${target_os:-}-${target_env:-}" @@ -43,11 +49,24 @@ get_env_target() { fi } +### NOTE: This function is currently not in use but kept as +### a backup function in case something breaks +### +### Logs the given arguments then execute it _tap() { log::info "$@" "$@" } +### NOTE: This function is currently not in use but kept as +### a backup function in case something breaks +### +### Lists the content of a path, given as parameter. +_ls() { + log::info "contents from $*:" + ls -la "$@" || true +} + ### -------------------------------------------------------------------------------------------------------------------- ### Release-Related functions ### -------------------------------------------------------------------------------------------------------------------- @@ -60,28 +79,38 @@ release() { log::info "desired target: $cross_target" TAR_DIR="$(pwd)/target/tar" + + ### We clean up the target folder, just in case rm -rf "$(pwd)/target" 2> /dev/null || true + ### We add the target for rustup in case cross doesn't find it. + ### Since the default behaviour of cross is to compile from + ### a rustup target if it doesn't find one for itself. rustup target add $env_target cargo install cross + + ### We're building the release via cross for the target environment cross build --release --target "$env_target" cd target/"$env_target"/release/ if is_windows "$env_target"; then + ### If our target is windows, we can simply zip our executable + ### since having tar is not the norm and neither the default zip -r "navi.zip" "navi.exe" + + ### We export a CI/CD variable to be used later in the pipeline echo "EXTENSION=zip" >> $GITHUB_OUTPUT else + ### For all other targets, they have tar as the norm + ### or have it installed by default. tar -czf "navi.tar.gz" "navi" + + ### We export a CI/CD variable to be used later in the pipeline echo "EXTENSION=tar.gz" >> $GITHUB_OUTPUT fi } -_ls() { - log::info "contents from $*:" - ls -la "$@" || true -} - ### -------------------------------------------------------------------------------------------------------------------- ### Main script ### --------------------------------------------------------------------------------------------------------------------