Skip to content
Snippets Groups Projects
Verified Commit e76c2200 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: update ci tools #7

parent 96877fcc
No related branches found
No related tags found
No related merge requests found
...@@ -47,13 +47,6 @@ tasks: ...@@ -47,13 +47,6 @@ tasks:
- ${gitCommit}/bin/git-commit - ${gitCommit}/bin/git-commit
silent: true silent: true
commit:
desc: Commit a feature
cmds:
- do-git-commit
silent: true
default: default:
desc: Print this help message desc: Print this help message
aliases: [d, help] aliases: [d, help]
...@@ -66,7 +59,7 @@ tasks: ...@@ -66,7 +59,7 @@ tasks:
}; };
treefmtConfig = pkgs.writeTextFile { treefmtConfig = pkgs.writeTextFile {
name = "Taskfile.yaml"; name = "treefmt.toml";
text = '' text = ''
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
...@@ -208,7 +201,12 @@ tasks: ...@@ -208,7 +201,12 @@ tasks:
- windows - windows
dir: ${config.devenv.root}/source dir: ${config.devenv.root}/source
ldflags: ldflags:
- -s -w -X main.version={{.Version}} -X 'main.commit={{.Commit}}' -X 'main.build={{.Date}}' -X 'main.mnemonic=${goPkgMnemonic}' -X 'main.name=${goPkgName}' - -s -w
- -X main.version={{.Version}}
- -X 'main.commit={{.Commit}}'
- -X 'main.build={{.Date}}'
- -X 'main.mnemonic=${goPkgMnemonic}'
- -X 'main.name=${goPkgName}'
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
...@@ -331,24 +329,133 @@ in { ...@@ -331,24 +329,133 @@ in {
${pkgs.git}/bin/git push origin $CI_COMMIT_REF_NAME --tags ${pkgs.git}/bin/git push origin $CI_COMMIT_REF_NAME --tags
''; '';
scripts.common-functions.exec = ''
if [ -t 1 ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RESET='\033[0m'
BOLD='\033[1m'
else
RED=""
GREEN=""
RESET=""
fi
is_true() {
val="$1"
if [ "$val" = 'true' ] || [ "$val" = '1' ]; then
return 0
else
return 1
fi
}
get_commit_hash() {
hash=""
if [[ -n "$CI_COMMIT_SHORT_SHA" ]]; then
hash="$CI_COMMIT_SHORT_SHA"
else
hash="$(git rev-parse --short HEAD)"
if [[ -n "$(git status --porcelain)" ]]; then
hash="''${hash}-dirty"
fi
fi
echo "$hash"
}
echo_green() {
echo -e "$GREEN ✔ $1$RESET"
}
echo_red() {
echo -e "$RED ✖ $1$RESET"
}
echo_todo() {
echo_bold "$BLUE • $1"
}
update_project_version() {
if version auto --git --exit-code-if-no-bump --verbose
then
buildVer=$(version print --git)
local project_nix="${config.devenv.root}/project.nix"
sed -i "s/^\s*version\s*=.*/ version = \"$buildVer\";/" "$project_nix"
echo_green "Project version updated to $buildVer"
${pkgs.git}/bin/git add "$project_nix"
${pkgs.git}/bin/git commit -m "chore: Update project version to $buildVer" "$project_nix"
${pkgs.git}/bin/git tag -f -a "$buildVer" -m "Release $buildVer"
if is_true "$CI_MODE"; then
${pkgs.git}/bin/git push -o ci.skip origin ''${CI_COMMIT_REF_NAME} --tags
fi
else
echo_green "Project version is up to date"
fi
}
get_project_version() {
echo "$(version print --git)"
}
if [ -z "$DEBUG_MODE" ]; then
DEBUG_MODE='false'
fi
if [ -n "$CI_JOB_TOKEN" ]; then
CI_MODE='true'
fi
if is_true "$DEBUG_MODE" || is_true "$CI_MODE"; then
set -x
fi
'';
scripts.update-files.exec = '' scripts.update-files.exec = ''
#!${pkgs.bash}/bin/bash #!${pkgs.bash}/bin/bash
source common-functions
create_symlink() {
if ln -s "$1" "$2" 2>/dev/null; then
echo_green "$2 created"
else
echo_red "$2 already exists"
fi
}
update_symlink() { update_symlink() {
echo -e " → $1"
local source_path="$1" local source_path="$1"
local target_path="$2" local target_path="$2"
local file_name="$(basename "$target_path")" local file_name="$(basename "$target_path")"
local source_dir="$(dirname "$source_path")"
mkdir -p "$source_dir" || true
if [[ ! -d "$source_dir" ]]; then
echo_red "$RED ✖ $source_dir is not a directory. Please remove it manually and run the script again."
exit 1
fi
if [[ -L "$source_path" ]]; then if [[ -L "$source_path" ]]; then
if [[ "$(readlink "$source_path")" != "$target_path" ]]; then if [[ "$(readlink "$source_path")" != "$target_path" ]]; then
# Link exists but is not up to date
rm "$source_path" rm "$source_path"
ln -s "$target_path" "$source_path" create_symlink "$target_path" "$source_path"
echo_green "$GREEN ✔ $source_path updated$RESET"
else
echo_green "$GREEN ✔ $source_path is up to date$RESET"
fi fi
elif [[ -e "$source_path" ]]; then elif [[ -e "$source_path" ]]; then
echo "$file_name already exists. Please rename or delete it." echo_red "$RED ✖ $source_path already exists and is not a symlink. Please remove it manually and run the script again."
exit 1 exit 1
else else
ln -s "$target_path" "$source_path" create_symlink "$target_path" "$source_path"
fi fi
} }
......
/nix/store/smqjqjy0wa39nvk52jq6x8w1i4bs65g9-Taskfile.yaml /nix/store/wrp2lsy6h8mzr6fa4n71lqnxw5dliwmc-treefmt.toml
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment