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

fix: test scripts

parent f6b81496
No related branches found
No related tags found
No related merge requests found
Pipeline #26134 failed
...@@ -55,14 +55,6 @@ ...@@ -55,14 +55,6 @@
bob = let bob = let
projectDefinition = import ./project.nix; projectDefinition = import ./project.nix;
projectHash =
if (self' ? shortRev)
then self'.shortRev
else "dirty";
lastModifiedDate =
self'.lastModifiedDate or self'.lastModified or "19700101";
sourcePath = ./source; sourcePath = ./source;
in in
# https://nixos.wiki/wiki/Go # https://nixos.wiki/wiki/Go
...@@ -79,10 +71,10 @@ ...@@ -79,10 +71,10 @@
ldflags = [ ldflags = [
"-s -w" "-s -w"
"-X '${projectDefinition.modulePath}/release.version=${projectDefinition.version}'" "-X '${projectDefinition.modulePath}/release.version=${projectDefinition.version}'"
"-X '${projectDefinition.modulePath}/release.commit=${projectHash}'" "-X '${projectDefinition.modulePath}/release.commit=${projectDefinition.commitHash}'"
"-X '${projectDefinition.modulePath}/release.name=${projectDefinition.name}'" "-X '${projectDefinition.modulePath}/release.name=${projectDefinition.name}'"
"-X '${projectDefinition.modulePath}/release.mnemonic=${projectDefinition.mnemonic}'" "-X '${projectDefinition.modulePath}/release.mnemonic=${projectDefinition.mnemonic}'"
"-X '${projectDefinition.modulePath}/release.buildDate=${lastModifiedDate}'" "-X '${projectDefinition.modulePath}/release.buildDate=${builtins.date}'"
]; ];
#vendorHash = null; #vendorHash = null;
......
...@@ -7,4 +7,5 @@ ...@@ -7,4 +7,5 @@
modulePath = "gitlab.schukai.com/oss/bob"; modulePath = "gitlab.schukai.com/oss/bob";
version = "0.4.11"; ## do not change this line; it will be updated automatically version = "0.4.11"; ## do not change this line; it will be updated automatically
vendorHash = null; ## do not change this line; it will be updated automatically vendorHash = null; ## do not change this line; it will be updated automatically
commitHash = "f6b8149"; ## do not change this line; it will be updated automatically
} }
...@@ -11,9 +11,10 @@ in '' ...@@ -11,9 +11,10 @@ in ''
#!${pkgs.bash}/bin/bash #!${pkgs.bash}/bin/bash
${common} ${common}
defaultHash="${pkgs.lib.fakeHash}" defaultHash="${pkgs.lib.fakeHash}"
echo_step "Reset vendorHash to default value: $defaultHash"
${pkgs.gnused}/bin/sed -i "s|vendorHash\s*=\s*null|vendorHash = \"$defaultHash\"|g" ${workingDirectory}/project.nix ${pkgs.gnused}/bin/sed -i "s|vendorHash\s*=\s*null|vendorHash = \"$defaultHash\"|g" ${workingDirectory}/project.nix
${pkgs.gnused}/bin/sed -i "s|vendorHash\s*=\s*\"[^\"]\"|vendorHash = \"$defaultHash\"|g" ${workingDirectory}/project.nix ${pkgs.gnused}/bin/sed -i "s|vendorHash\s*=\s*\"[^\"]\"|vendorHash = \"$defaultHash\"|g" ${workingDirectory}/project.nix
...@@ -31,8 +32,6 @@ in '' ...@@ -31,8 +32,6 @@ in ''
fi fi
echo_ok "No dependencies found and vendorHash is set to null." echo_ok "No dependencies found and vendorHash is set to null."
${pkgs.git}/bin/git add $filepath/project.nix
${pkgs.git}/bin/git commit -m "chore: Update vendorHash to null" ${workingDirectory}/project.nix
exit 0 exit 0
fi fi
......
...@@ -17,10 +17,21 @@ ${common} ...@@ -17,10 +17,21 @@ ${common}
cmd=${versionsTool}/bin/version cmd=${versionsTool}/bin/version
echo_step "Getting current commit hash"
HASH=$(${pkgs.git}/bin/git -C ${workingDirectory}/ rev-parse --short HEAD)
echo_ok "Current commit hash is ''${HASH}"
echo_step "Replacing hash in project.nix"
if ! ${pkgs.gnused}/bin/sed -i "s|commitHash\s*=\s*\"[^\"]*\"|commitHash = \"''${HASH}\"|g" ${workingDirectory}/project.nix ; then
echo_fail "Hash not replaced"
exit 1
fi
echo_ok "Hash updated"
echo_step "Checking if there is a new version" echo_step "Checking if there is a new version"
if ! $cmd auto --git --exit-code-if-no-bump ; then if ! $cmd auto --git --exit-code-if-no-bump ; then
echo_step "No version bump" echo_fail "No version jump to a new version"
fi fi
VERSION=$($cmd print --git) VERSION=$($cmd print --git)
...@@ -31,15 +42,14 @@ if [[ -z "''${VERSION}" ]]; then ...@@ -31,15 +42,14 @@ if [[ -z "''${VERSION}" ]]; then
exit 1 exit 1
fi fi
echo_step "Check version in project.nix"
echo_step "Replacing version in project.nix"
# check if version replaced # check if version replaced
if ! ${pkgs.gnused}/bin/sed -i "s/version\s*=\s*\"[^\"]*\"/version = \"''${VERSION}\"/g" ${workingDirectory}/project.nix; then if ! ${pkgs.gnused}/bin/sed -i "s/version\s*=\s*\"[^\"]*\"/version = \"''${VERSION}\"/g" ${workingDirectory}/project.nix; then
echo_fail "Version not replaced" echo_fail "Version not replaced"
exit 1 exit 1
fi fi
echo_ok "Version replaced" echo_ok "Version and hash updated"
'' ''
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment