diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a6ca07770df2bddaaf73591fc59b3aee0cca9d67..5261d1e7b2da6668ebe25461ad3c0ee03b841d68 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,45 +1,46 @@ -image: docker-registry.schukai.com:443/nixos-ci-devenv:latest - -services: - - docker:dind - - -variables: - NIXOS_VERSION: "23.05" - NIXPKGS_ALLOW_UNFREE: "1" - NIXPKGS_ALLOW_INSECURE: "1" - DOCKER_DRIVER: overlay2 - - -stages: - - tag - - release - - -tag-it: - tags: - - nixos - stage: tag - script: - - devenv shell tag-version - only: - - master - except: - - tags - -release: - tags: - - nixos - stage: release - #image: - # name: goreleaser/goreleaser - # entrypoint: [""] - only: - - tags - variables: - # Disable shallow cloning so that goreleaser can diff between tags to - GIT_DEPTH: 0 - script: - - devenv shell deploy-app - #- cd source; goreleaser release --clean + ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX + image: docker-registry.schukai.com:443/nixos-ci-devenv:latest + + services: + - docker:dind + + variables: + NIXOS_VERSION: "23.05" + NIXPKGS_ALLOW_UNFREE: "1" + NIXPKGS_ALLOW_INSECURE: "1" + DOCKER_DRIVER: overlay2 + + + stages: + - tag + - release + + + tag-it: + tags: + - nixos + stage: tag + script: + - devenv shell tag-version + only: + - master + except: + - tags + + release: + tags: + - nixos + stage: release + #image: + # name: goreleaser/goreleaser + # entrypoint: [""] + only: + - tags + variables: + # Disable shallow cloning so that goreleaser can diff between tags to + GIT_DEPTH: 0 + script: + - devenv shell deploy-app + #- cd source; goreleaser release --clean +## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX diff --git a/README.md b/README.md index ec369c210dc2fe1e52dd1d2915e15ef4f3dd6178..ba4bb3675a63a0e71e147bf034075b16cae638dc 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ This tool helps to increment the version number of a project. You can download the tool here: [download.schukai.com/tools/version/](http://download.schukai.com/tools/version/). - ```bash echo "1.0.0" | version patch # 1.0.1 @@ -12,7 +11,7 @@ echo "1.0.0" | version minor # 1.1.0 echo "1.0.0" | version major # 2.0.0 -``` +``` You can also replace directly in files. @@ -47,38 +46,37 @@ Or set git tags directly ```bash version patch --git -``` +``` **Build** With the command build the current build date can be output. - -```bash +```bash version build ``` **Auto** -The 'auto' feature allows the tool to automatically determine the next version +The 'auto' feature allows the tool to automatically determine the next version based on the project's git commit history since the last tag. -It uses semantic commit messages to determine the type of version bump. -If a commit message starts with "feat:", it will trigger a minor version bump. -If a commit message starts with "fix:" or if it includes "BREAKING CHANGE", +It uses semantic commit messages to determine the type of version bump. +If a commit message starts with "feat:", it will trigger a minor version bump. +If a commit message starts with "fix:" or if it includes "BREAKING CHANGE", it will trigger a patch or a major version bump respectively. Here is how you can use the 'auto' feature: ```bash version auto -``` +``` This command implies the '--git' flag, which means that the tool will tag the git repository with the new version. The tag name will be the new version number. -It is important to note that this feature requires that your commit messages -follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) +It is important to note that this feature requires that your commit messages +follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) message format. The `exit-code-if-no-bump` flag can be used to make the command exit with a non-zero exit. @@ -93,22 +91,21 @@ In this case, the command will exit with the exit code 1 if no version bump is r **Predict** The `predict` command allows you to predict the next version based on the -project's git commit history since the last tag. Other than the `auto` command, +project's git commit history since the last tag. Other than the `auto` command, this command does not write the result to a file or tag the git repository. ```bash version predict ``` - **Makefile** ```makefile -build: +build: version patch --path $(PROJECT_ROOT)version.json --selector "version" $(eval VERSION := $(shell cat version.json | jq -r .version)) $(eval BUILD := $(shell version date)) - + echo "Compiling for every OS and Platform $(VERSION) $(BUILD)" -``` \ No newline at end of file +``` diff --git a/Taskfile.yaml b/Taskfile.yaml index 3ab08fea79fbe66b822f830cadf3bd9b96287cc4..b95f48cd1eed99cd6c07d847baa51e0c4a1b850e 120000 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -1 +1 @@ -/nix/store/lfy3spmspb2bnzwg8359nn58q1hzdyv5-Taskfile.yaml \ No newline at end of file +/nix/store/4bvalx54rgxmryi1jx7k70aq4ccr7phq-Taskfile.yaml \ No newline at end of file diff --git a/bin/go-compile.sh b/bin/go-compile.sh index 29d91475c5d9c950bf1313fc703b4bbabf7f5f2a..cbf5b16b06e8a8d20d30a90c87f49b82184a0df5 100755 --- a/bin/go-compile.sh +++ b/bin/go-compile.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash set -x - SOURCE_PATH=$1 BUILD_PATH=$2 COMPONENT_SLUG=$3 @@ -20,33 +19,33 @@ cd $SOURCE_PATH || exit 1 # Run and build loop through all platforms (except excluded ones) for platform in ${platforms[@]}; do - # GOOS und GOARCH Variablen setzen - export GOARCH=$(echo $platform | cut -d'/' -f1) - export GOOS=$(echo $platform | cut -d'/' -f2) - -# if [[ ! "${included_os[@]}" =~ "$GOOS" ]]; then -# echo "Skipping excluded platform: $GOOS" -# continue -# fi - -# if [[ ! "${included_arch[@]}" =~ "$GOARCH" ]]; then -# echo "Skipping excluded architecture: $GOARCH" -# continue -# fi - - echo "============================================" - echo "Building for $GOOS/$GOARCH" - - output_name=$BUILD_PATH$COMPONENT_SLUG-$GOOS-$GOARCH - if [ $GOOS = "windows" ]; then - output_name+='.exe' - fi - - env GOFLAGS= GOWORK=off GO111MODULE=on GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-X $GO_RELEASE_PACKAGE_NAME.version=$PROJECT_VERSION -X $GO_RELEASE_PACKAGE_NAME.build=$PROJECT_BUILD_DATE" -o $output_name - if [ $? -ne 0 ]; then - echo "An error has occurred! $output_name build failed." - echo "============================================" - fi + # GOOS und GOARCH Variablen setzen + export GOARCH=$(echo $platform | cut -d'/' -f1) + export GOOS=$(echo $platform | cut -d'/' -f2) + + # if [[ ! "${included_os[@]}" =~ "$GOOS" ]]; then + # echo "Skipping excluded platform: $GOOS" + # continue + # fi + + # if [[ ! "${included_arch[@]}" =~ "$GOARCH" ]]; then + # echo "Skipping excluded architecture: $GOARCH" + # continue + # fi + + echo "============================================" + echo "Building for $GOOS/$GOARCH" + + output_name=$BUILD_PATH$COMPONENT_SLUG-$GOOS-$GOARCH + if [ $GOOS = "windows" ]; then + output_name+='.exe' + fi + + env GOFLAGS= GOWORK=off GO111MODULE=on GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-X $GO_RELEASE_PACKAGE_NAME.version=$PROJECT_VERSION -X $GO_RELEASE_PACKAGE_NAME.build=$PROJECT_BUILD_DATE" -o $output_name + if [ $? -ne 0 ]; then + echo "An error has occurred! $output_name build failed." + echo "============================================" + fi done cd - || exit 1 diff --git a/data/index.html b/data/index.html index c4bdc9e8f2f2c4c3b3514ab7a6e87383f438dabb..d22c7b5fc5185f939361ad712fa6109bc705c10b 100644 --- a/data/index.html +++ b/data/index.html @@ -1,56 +1,91 @@ <!doctype html> <html lang="en"> -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> - <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" - integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> + <link + href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" + rel="stylesheet" + integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" + crossorigin="anonymous" + /> <style> - - body { - background-color: #ffffff; - } - + body { + background-color: #ffffff; + } </style> <title>Version | Download Portal schukai GmbH</title> -</head> -<body> - - -<div class="d-flex flex-column align-items-center justify-content-center" - style="height:100vh;"> - - <div class="text-center"> - <a href="https://www.schukai.com" class="text-decoration-none text-white text-decoration"><img - src="https://cdn.alvine.io/image/logo/schukai-rot.svg" width="300px"></a> - <br> + </head> + <body> + <div + class="d-flex flex-column align-items-center justify-content-center" + style="height: 100vh" + > + <div class="text-center"> + <a + href="https://www.schukai.com" + class="text-decoration-none text-white text-decoration" + ><img + src="https://cdn.alvine.io/image/logo/schukai-rot.svg" + width="300px" + /></a> + <br /> <div class="card mt-5"> - <div class="card-header"> - Version - </div> - <ul class="list-group"> - <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-linux-386">version-linux-386</a></li> - <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-linux-amd64">version-linux-amd64</a></li> - <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-linux-arm">version-linux-arm</a></li> - <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-linux-arm64">version-linux-arm64</a></li> - <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-windows">version-windows</a></li> - </ul> + <div class="card-header">Version</div> + <ul class="list-group"> + <li class="list-group-item"> + <a + class="text-decoration-none link-danger" + href="./version-linux-386" + >version-linux-386</a + > + </li> + <li class="list-group-item"> + <a + class="text-decoration-none link-danger" + href="./version-linux-amd64" + >version-linux-amd64</a + > + </li> + <li class="list-group-item"> + <a + class="text-decoration-none link-danger" + href="./version-linux-arm" + >version-linux-arm</a + > + </li> + <li class="list-group-item"> + <a + class="text-decoration-none link-danger" + href="./version-linux-arm64" + >version-linux-arm64</a + > + </li> + <li class="list-group-item"> + <a + class="text-decoration-none link-danger" + href="./version-windows" + >version-windows</a + > + </li> + </ul> </div> <p class="mt-5"> - <a href="https://about.schukai.com/de/impressum/" class="text-decoration-none text-decoration" - style="color:#c10000">Imprint</a></p> - + <a + href="https://about.schukai.com/de/impressum/" + class="text-decoration-none text-decoration" + style="color: #c10000" + >Imprint</a + > + </p> + </div> </div> - -</div> - - -<!-- + <!-- <div class="d-flex flex-column align-items-center justify-content-center" style="height:100vh;"> @@ -73,10 +108,10 @@ </div> </div> --> - -<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" - integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" - crossorigin="anonymous"></script> - -</body> + <script + src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" + integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" + crossorigin="anonymous" + ></script> + </body> </html> diff --git a/data/version.yaml b/data/version.yaml index 107f558b44cccfa926e27fd2dc938883546c21f8..5288ff5db5aa6b223a523fcd016e96a6c8c598ab 100644 --- a/data/version.yaml +++ b/data/version.yaml @@ -1,7 +1,7 @@ entry: - id: 1 - title: Entry 1 - meta: - created: "2015-01-01T00:00:00.000Z" - updated: "2015-01-01T00:00:00.000Z" - version: 1.0.13 + id: 1 + title: Entry 1 + meta: + created: "2015-01-01T00:00:00.000Z" + updated: "2015-01-01T00:00:00.000Z" + version: 1.0.13 diff --git a/devenv.nix b/devenv.nix index 69f04cfcc7ced21041d014c8c61d4ccdd204e94f..099ccad3100c62ceb223c1bdbdb99717bb6b9dd2 100644 --- a/devenv.nix +++ b/devenv.nix @@ -1,158 +1,207 @@ # See full reference at https://devenv.sh/reference/options/ -{ pkgs, inputs, phps, lib, config, modulesPath,... }: +{ + pkgs, + inputs, + phps, + lib, + config, + modulesPath, + ... +}: let + taskfileYaml = pkgs.writeTextFile { + name = "Taskfile.yaml"; + text = '' + ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX + version: '3' -let + tasks: + build: + desc: Build the app + aliases: + - b + cmds: + - devenv shell build-app + sources: + - source/**/*.go + - source/**/*.mod + - dist/** - taskfileYaml = pkgs.writeTextFile { + commit: + desc: Commit a feature + cmds: + - do-git-commit + silent: true + + default: + desc: Print this help message + aliases: [d, help] + cmds: + - task --list + silent: true + + ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX + ''; + }; + + treefmtConfig = pkgs.writeTextFile { name = "Taskfile.yaml"; text = '' -## THIS FILE IS AUTOGENERATED. DO NOT EDIT THIS FILE DIRECTLY. -version: '3' - -tasks: - build: - desc: Build the app - aliases: - - b - cmds: - - devenv shell build-app - sources: - - source/**/*.go - - source/**/*.mod - - dist/** - - commit: - desc: Commit a feature - cmds: - - do-git-commit - silent: true - - default: - desc: Print this help message - aliases: [d, help] - cmds: - - task --list - silent: true - + ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX + + [formatter.nix] + command = "${pkgs.alejandra}/bin/alejandra" + options = [] + includes = [ "*.nix" ] + excludes = [] + + [formatter.go] + command = "${pkgs.go}/bin/gofmt" + options = ["-w"] + includes = [ "*.go" ] + excludes = [] + + #[formatter.php] + #command = "${pkgs.php83Packages.php-cs-fixer}/bin/php-cs-fixer" + #options = ["fix"] + #includes = [ "*.php" ] + #excludes = [] + + [formatter.shell] + command = "${pkgs.shfmt}/bin/shfmt" + options = ["-w"] + includes = [ "*.sh", "*.bash" ] + excludes = [] + + + [formatter.prettier] + command = "${pkgs.nodePackages.prettier}/bin/prettier" + options = ["--write","--plugin=${pkgs.nodePackages.prettier-plugin-toml}/lib/node_modules/prettier-plugin-toml/lib/api.js"] + includes = [ + "*.css", + "*.html", + "*.js", + "*.mjs", + "*.json", + "*.xml", + "*.toml", + "*.jsx", + "*.md", + "*.mdx", + "*.scss", + "*.ts", + "*.yml", + "*.yaml"] + excludes = ["treefmt.toml", "Taskfile.yml", "node_modules"] + + ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX + ''; }; - + gitlabCiYaml = pkgs.writeTextFile { - name = ".gitlab-ci.yml"; - text = '' - image: docker-registry.schukai.com:443/nixos-ci-devenv:latest - - services: - - docker:dind - - - variables: - NIXOS_VERSION: "23.05" - NIXPKGS_ALLOW_UNFREE: "1" - NIXPKGS_ALLOW_INSECURE: "1" - DOCKER_DRIVER: overlay2 - - - stages: - - tag - - release - - - tag-it: - tags: - - nixos - stage: tag - script: - - devenv shell tag-version - only: - - master - except: - - tags - - release: - tags: - - nixos - stage: release - #image: - # name: goreleaser/goreleaser - # entrypoint: [""] - only: - - tags - variables: - # Disable shallow cloning so that goreleaser can diff between tags to - GIT_DEPTH: 0 - script: - - devenv shell deploy-app - #- cd source; goreleaser release --clean - - ''; - }; - - + name = ".gitlab-ci.yml"; + text = '' + ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX + image: docker-registry.schukai.com:443/nixos-ci-devenv:latest + + services: + - docker:dind + + + variables: + NIXOS_VERSION: "23.05" + NIXPKGS_ALLOW_UNFREE: "1" + NIXPKGS_ALLOW_INSECURE: "1" + DOCKER_DRIVER: overlay2 + + + stages: + - tag + - release + + + tag-it: + tags: + - nixos + stage: tag + script: + - devenv shell tag-version + only: + - master + except: + - tags + + release: + tags: + - nixos + stage: release + #image: + # name: goreleaser/goreleaser + # entrypoint: [""] + only: + - tags + variables: + # Disable shallow cloning so that goreleaser can diff between tags to + GIT_DEPTH: 0 + script: + - devenv shell deploy-app + #- cd source; goreleaser release --clean + ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX + ''; + }; + goReleaserYaml = pkgs.writeTextFile { name = ".goreleaser.yml"; text = '' -# .goreleaser.yml -gitlab_urls: - api: https://gitlab.schukai.com/api/v4 - download: https://gitlab.schukai.com - - # set to true if you use a self-signed certificate - skip_tls_verify: false - - use_package_registry: true - - # Set this if you set GITLAB_TOKEN to the value of CI_JOB_TOKEN. - # Since: v1.11 - use_job_token: false - -project_name: version - -builds: - - id: version -# goos: -# - linux -## - darwin -## - windows -# goarch: -# - amd64 -## - arm64 -## - "386" -# goarm: -# - "6" -## gomips: -## - hardfloat -## goamd64: -## - v1 - targets: -# - linux_amd64_v1 - - linux_arm64 -# - linux_386 -# - darwin_amd64_v1 -# - darwin_arm64 -# - windows_amd64_v1 -# - windows_arm64 -# - windows_386 - dir: ${config.devenv.root}/source -# main: ${config.devenv.root}/source/main.go -# binary: version -# builder: go -# gobinary: go -# command: build - ldflags: - - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.build={{.Date}} + ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX + gitlab_urls: + api: https://gitlab.schukai.com/api/v4 + download: https://gitlab.schukai.com + # set to true if you use a self-signed certificate + skip_tls_verify: false - ''; - - }; - - - in + use_package_registry: true + # Set this if you set GITLAB_TOKEN to the value of CI_JOB_TOKEN. + # Since: v1.11 + use_job_token: false -{ + project_name: version + + builds: + - id: version + goos: + - linux + - darwin + - windows + # goarch: + # - amd64 + ## - arm64 + ## - "386" + # goarm: + # - "6" + ## gomips: + ## - hardfloat + ## goamd64: + ## - v1 + # targets: + # - linux_amd64_v1 + # - linux_arm64 + ## - linux_386 + # - darwin_amd64_v1 + # - darwin_arm64 + # - windows_amd64_v1 + # - windows_arm64 + # - windows_386 + dir: ${config.devenv.root}/source + ldflags: + - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.build={{.Date}} + ## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX + ''; + }; +in { env.APP_NAME = "version"; # https://devenv.sh/packages/ @@ -174,7 +223,7 @@ builds: docker-compose drill eza - fd + fd gawk gcc12 gdlv @@ -187,6 +236,7 @@ builds: gnused go-task graphviz + treefmt gum httpie hurl @@ -222,553 +272,106 @@ builds: util-linux wget zlib - ]; - + scripts.tag-version.exec = '' -#!${pkgs.bash}/bin/bash - set -x - ${pkgs.git}/bin/git config user.email "''${GITLAB_USER_EMAIL}" - ${pkgs.git}/bin/git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}" - ${pkgs.git}/bin/git config credential.helper '!f() { echo "username=gitlab-ci-token"; echo "password=''${CI_JOB_TOKEN}"; }; f' - ${pkgs.git}/bin/git config pull.rebase true - ${pkgs.git}/bin/git config http.sslVerify "false" - ${pkgs.git}/bin/git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@} - ${pkgs.git}/bin/git fetch --all --tags --unshallow - ${pkgs.git}/bin/git reset --hard origin/master - ${pkgs.git}/bin/git checkout $CI_COMMIT_REF_NAME - ${pkgs.git}/bin/git pull origin $CI_COMMIT_REF_NAME - ${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/version auto --git --verbose - - ${pkgs.git}/bin/git log --decorate=short --pretty=oneline - - ${pkgs.git}/bin/git push origin $CI_COMMIT_REF_NAME --tags - + #!${pkgs.bash}/bin/bash + + if [[ -z "''${CI_JOB_TOKEN}" ]]; then + echo " ✖ Not in gitlab ci." + exit 0 + fi + + + set -x + ${pkgs.git}/bin/git config user.email "''${GITLAB_USER_EMAIL}" + ${pkgs.git}/bin/git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}" + ${pkgs.git}/bin/git config credential.helper '!f() { echo "username=gitlab-ci-token"; echo "password=''${CI_JOB_TOKEN}"; }; f' + ${pkgs.git}/bin/git config pull.rebase true + ${pkgs.git}/bin/git config http.sslVerify "false" + ${pkgs.git}/bin/git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@} + ${pkgs.git}/bin/git fetch --all --tags --unshallow + ${pkgs.git}/bin/git reset --hard origin/master + ${pkgs.git}/bin/git checkout $CI_COMMIT_REF_NAME + ${pkgs.git}/bin/git pull origin $CI_COMMIT_REF_NAME + + NEWVERSION=$(${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/version predict --git exit-code-if-no-bump) + if [[ $? -eq 0 ]]; then + echo " ✖ No bump wanted." + exit 0 + fi + + if [[ -z "''${NEWVERSION}" ]]; then + echo " ✖ No version found." + exit 0 + fi + + sed -i "s/version\s*=\s*\".*\"/version=\"''${NEWVERSION}\"/" ${config.devenv.root}/project.nix + ${pkgs.git}/bin/git add ${config.devenv.root}/project.nix + ${pkgs.git}/bin/git commit -m "chore: Bump version to ''${NEWVERSION}" + + ${pkgs.git}/bin/git log --decorate=short --pretty=oneline + + ${pkgs.git}/bin/git tag -a "''${NEWVERSION}" -m "chore: Release ''${NEWVERSION}" + ${pkgs.git}/bin/git push origin $CI_COMMIT_REF_NAME --tags + ''; scripts.update-files.exec = '' -#!${pkgs.bash}/bin/bash - update_symlink() { - local source_path="$1" - local target_path="$2" - local file_name="$(basename "$target_path")" - - if [[ -L "$source_path" ]]; then - if [[ "$(readlink "$source_path")" != "$target_path" ]]; then - # Link exists but is not up to date - rm "$source_path" + #!${pkgs.bash}/bin/bash + update_symlink() { + local source_path="$1" + local target_path="$2" + local file_name="$(basename "$target_path")" + + if [[ -L "$source_path" ]]; then + if [[ "$(readlink "$source_path")" != "$target_path" ]]; then + # Link exists but is not up to date + rm "$source_path" + ln -s "$target_path" "$source_path" + fi + elif [[ -e "$source_path" ]]; then + echo "$file_name already exists. Please rename or delete it." + exit 1 + else ln -s "$target_path" "$source_path" fi - elif [[ -e "$source_path" ]]; then - echo "$file_name already exists. Please rename or delete it." - exit 1 - else - ln -s "$target_path" "$source_path" - fi - } - - # Usage for Taskfile.yaml - update_symlink "${config.devenv.root}/Taskfile.yaml" "${taskfileYaml}" - update_symlink "${config.devenv.root}/.goreleaser.yml" "${goReleaserYaml}" - - cat ${gitlabCiYaml} > "${config.devenv.root}/.gitlab-ci.yml" + } + + # Usage for Taskfile.yaml + update_symlink "${config.devenv.root}/Taskfile.yaml" "${taskfileYaml}" + update_symlink "${config.devenv.root}/.goreleaser.yml" "${goReleaserYaml}" + update_symlink "${config.devenv.root}/treefmt.toml" "${treefmtConfig}" - ''; + cat ${gitlabCiYaml} > "${config.devenv.root}/.gitlab-ci.yml" + ''; - # https://devenv.sh/languages/ - # languages.nix.enable = true; languages = { - go = { enable = true; }; + go = {enable = true;}; }; - + difftastic.enable = true; + scripts.build-app.exec = '' + #!${pkgs.bash}/bin/bash + ${pkgs.treefmt}/bin/treefmt + ${pkgs.nix}/bin/nix build .#version + ''; - scripts.build-app.exec = '' -#!${pkgs.bash}/bin/bash -${pkgs.nix}/bin/nix build .#version - + scripts.deploy-app.exec = '' + #!${pkgs.bash}/bin/bash + ${pkgs.goreleaser}/bin/goreleaser release --clean --config ${config.devenv.root}/.goreleaser.yml ''; - - scripts.deploy-app.exec = '' -#!${pkgs.bash}/bin/bash -${pkgs.eza}/bin/eza -T# -cat ${config.devenv.root}/.goreleaser.yml -${pkgs.goreleaser}/bin/goreleaser release --clean --config ${config.devenv.root}/.goreleaser.yml - + + scripts.update-hashes.exec = '' + #!${pkgs.bash}/bin/bash + set -x + sed -i 's/vendorHash\s*=\s*".*"/vendorHash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="/' ${config.devenv.root}/project.nix + HASH=$(${pkgs.nix}/bin/nix build 2>&1 | grep 'got:' | awk '{print $2}') + sed -i "s/vendorHash\s*=\s*\".*\"/vendorHash=\"''${HASH}\"/" ${config.devenv.root}/project.nix ''; - -# # This script is executed when the app is built -# # You can use it to build the app -# scripts.build-app.exec = '' -##!${pkgs.bash}/bin/bash -# -#set -x -# -#PATH="''${PATH}":${pkgs.coreutils}/bin -#PATH="''${PATH}":${pkgs.findutils}/bin -#PATH="''${PATH}":${pkgs.jq}/bin/ -#PATH="''${PATH}":${pkgs.rsync}/bin/ -#PATH="''${PATH}":${pkgs.bash}/bin/ -#PATH="''${PATH}":${pkgs.curl}/bin/ -#PATH="''${PATH}":${pkgs.moreutils}/bin/ -#PATH="''${PATH}":${pkgs.gnutar}/bin -#PATH="''${PATH}":${pkgs.gzip}/bin/ -#PATH="''${PATH}":${pkgs.procps}/bin/ -#PATH="''${PATH}":${pkgs.eza}/bin/ -#PATH="''${PATH}":${pkgs.git}/bin/ -#PATH="''${PATH}":${pkgs.gnugrep}/bin/ -#PATH="''${PATH}":${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/ -# -#export PATH -# -# -#if [ -z "'CI_JOB_TOKEN" ]; then -# version=''$(git describe --tags --always --dirty) -# buildDate=''$(date -u +"%Y-%m-%dT%H:%M:%SZ") -#else -# version=''$(version predict --git) -# buildDate=''$(version date) -#fi -# -#${config.devenv.root}/bin/go-compile.sh \ -# "${config.devenv.root}/source/" \ -# "${config.devenv.root}/dist"/ \ -# "version" \ -# "main" \ -# "''${version}" \ -# "''${buildDate}" -# -# -#''; -# -# # This scritp is used to deploy the app to the gitlab registry -# # It is used by the gitlab-ci.yml file -# # The environment variables are set in the gitlab project settings -# scripts.deploy-app.exec = '' -##!${pkgs.bash}/bin/bash -# -#PATH="''${PATH}":${pkgs.coreutils}/bin -#PATH="''${PATH}":${pkgs.jq}/bin/ -#PATH="''${PATH}":${pkgs.curl}/bin/ -#PATH="''${PATH}":${pkgs.moreutils}/bin/ -#PATH="''${PATH}":${pkgs.gnutar}/bin -#PATH="''${PATH}":${pkgs.gzip}/bin/ -#PATH="''${PATH}":${pkgs.eza}/bin/ -#PATH="''${PATH}":${pkgs.git}/bin/ -#PATH="''${PATH}":${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/ -# -#export -f PATH -# -#if [[ -f .env-gitlab-ci ]]; then -# source .env-gitlab-ci -# rm .env-gitlab-ci -#fi -# -#set -x -### if $HOME not set, set it to current directory -#if [[ -z "''${HOME}" ]]; then -# HOME=$(pwd) -#fi -# -#export HOME -# -#git config user.email "''${GITLAB_USER_EMAIL}" -#git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}" -#git config pull.rebase true -#git config http.sslVerify "false" -#git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@} -# -#git fetch --all --tags --unshallow -#git reset --hard origin/master -#git checkout $CI_COMMIT_REF_NAME -#git pull origin $CI_COMMIT_REF_NAME -# -# -#if [ ! -z "''${CI_PROJECT_DIR}" ]; then -# echo "CI_PROJECT_DIR is set, using it as project root." -# project_root=$(realpath "''${CI_PROJECT_DIR}")/ -#elif [ ! -z "''${DEVENV_ROOT}" ]; then -# echo "DEVENV_ROOT is set, using it as project root." -# project_root=$(realpath "''${DEVENV_ROOT}")/ -#else -# echo "Error: DEVENV_ROOT or CI_PROJECT_DIR environment variables are not set." -# exit 1 -#fi -# -#if [ ! -d "''${project_root}" ]; then -# echo "Error: Project root directory does not seem to be valid." -# echo "Check the DEVENV_ROOT or CI_PROJECT_DIR environment variables." -# exit 1 -#fi -# -#if [ -z "'CI_JOB_TOKEN" ]; then -# echo "Error: CI_JOB_TOKEN variable is not set." -# exit 1 -#fi -# -#git --no-pager log --decorate=short --pretty=oneline -# -### the version should be the same as in the build task -#if ! version auto --git --verbose --exit-code-if-no-bump -#then -# echo "ERROR: Could not update version." -# exit 1 -#fi -# -#git --no-pager log --decorate=short --pretty=oneline -# -#gitVersion=$(version print --git) -# -# -#for file in $(eza "''${project_root}"dist/*); do -# filname=$(basename ''${file}) -# curl -v --insecure -H "JOB-TOKEN: ''${CI_JOB_TOKEN}" --upload-file \ -# ''${file} \ -# https://gitlab.schukai.com/api/v4/projects/''${CI_PROJECT_ID}/packages/generic/${config.env.APP_NAME}/''${gitVersion}/''${filname} -#done -# -#git push -o ci.skip origin ''${CI_COMMIT_REF_NAME} --tags -# -#echo "done" -# -# ''; -# -# scripts.do-git-commit.exec = '' -# #!${pkgs.bash}/bin/bash -# -# # Define colors if the terminal supports it -# if [ -t 1 ]; then -# RED='\033[0;31m' -# GREEN='\033[0;32m' -# RESET='\033[0m' -# BOLD='\033[1m' -# else -# RED="" -# GREEN="" -# RESET="" -# fi -# -# step=1 -# -# reset -# clear -# -# # create random log file -# LOGFILE="$(mktemp)" -# if [ $? -ne 0 ]; then -# echo -e "''${RED}✖ Could not create temporary log file. Exiting.''${RESET}" -# exit 1 -# fi -# -# log_and_display() { -# echo -e "''${GREEN}==> $step. $1''${RESET}" | tee -a $LOGFILE -# step=$((step + 1)) -# } -# -# log_error_and_display() { -# echo -e "''${RED}==> $step. $1''${RESET}" | tee -a $LOGFILE -# } -# -# printLogfileAndExit() { -# exit_code=$1 -# echo -e "\n\n========================================\n\n\n" -# -# echo -e "\n\n''${BOLD}Git and GitLab Automation Script''${RESET}\n\nI have performed the following actions:\n\n" -# cat "$LOGFILE" -# -# # Optional: Remove log file -# ${pkgs.coreutils}/bin/rm -f "$LOGFILE" -# -# if [ $exit_code -eq 0 ]; then -# echo -e "\n''${GREEN}✔''${RESET} All actions were successful" | tee -a $LOGFILE -# elif [ $exit_code -eq -1 ]; then -# echo -e "\n''${RED}✖''${RESET} The script was manually cancelled" | tee -a $LOGFILE -# exit_code=0 -# else -# echo -e "\n''${RED}✖''${RESET} Some actions failed" | tee -a $LOGFILE -# fi -# -# exit $exit_code -# } -# -# print_headline() { -# local title=$1 -# local underline=$(printf '─%.0s' $(seq 1 ''${#title})) -# echo -e "\n\n''${BOLD}''${title}\n''${underline}''${RESET}\n" -# } -# -# do_cancel() { -# echo -e "''${RED}==> ✖ Cancelled.''${RESET}" | tee -a $LOGFILE -# printLogfileAndExit -1 -# } -# -# # Function for unified logging and display -# log_action() { -# if [ $? -eq 0 ]; then -# echo -e " ''${GREEN}✔''${RESET} $1: Successful" | tee -a $LOGFILE -# else -# echo -e " ''${RED}✖''${RESET} $1: Failed" | tee -a $LOGFILE -# printLogfileAndExit 1 -# fi -# } -# -# print_what_to_do() { -# echo -e "\n\nWhat do you want to do?\n" -# } -# -# git_status=$(git status --porcelain) -# if [[ -z "$git_status" ]]; then -# log_error_and_display "No changes to commit. Exiting." -# printLogfileAndExit 0 -# fi -# -# print_headline "Choose commit type" -# selection=$(gum choose "feat: (new feature for the user, not a new feature for build script)" "fix: (bug fix for the user, not a fix to a build script)" "chore: (updating grunt tasks etc.; no production code change)" "docs: (changes to the documentation)" "style: (formatting, missing semi colons, etc; no production code change)" "refactor: (refactoring production code, eg. renaming a variable)" "test: (adding missing tests, refactoring tests; no production code change)" "Cancel") -# -# commit_type=$(echo "$selection" | awk -F':' '{print $1}') -# -# if [[ "$commit_type" == "Cancel" ]]; then -# do_cancel -# fi -# -# log_and_display "You chose the commit type: $commit_type" -# -# # NEXT STEP ISSUE HANDLING ############################################################################################################ -# #log_and_display "Issue handling" -# -# gitlabIssues=() -# while IFS= read -r line; do -# if [[ $line =~ ^# ]]; then -# id=$(echo "$line" | awk '{print substr($1, 2)}') -# title=$(echo "$line" | awk -F'about' '{print $1}' | awk '{$1=$2=""; print substr($0, 3)}') -# gitlabIssues+=("$id > $title") -# fi -# done < <(gum spin --spinner dot --show-output --title "Ask gitlab ..." -- glab issue list --output-format=details) -# -# ## if issues are available, ask if user wants to use an existing issue or create a new one -# createOption="Create new issue" -# existingOption="Use existing issue" -# cancelOption="Cancel" -# -# print_headline "Choose issue handling" -# if [ ''${#gitlabIssues[@]} -eq 0 ]; then -# log_and_display "There are no issues available." -# -# print_what_to_do -# choice=$(gum choose "$createOption" "$cancelOption") -# -# else -# log_and_display "There are ''${#gitlabIssues[@]} issues available." -# print_what_to_do -# choice=$(gum choose "$createOption" "$existingOption" "$cancelOption") -# fi -# -# if [[ "$choice" == "$cancelOption" ]]; then -# do_cancel -# fi -# -# ## array of issue ids -# work_on_issue_ids=() -# -# issue_text="" -# -# if [[ "$choice" == "$createOption" ]]; then -# print_headline "Create new issue" -# issue_text=$(gum input --placeholder "Enter issue title") -# echo -e "Enter issue description. ''${RED}End with Ctrl+D''${RESET}\n" -# issue_description=$(gum write --placeholder "Enter issue description. End with Ctrl+D") -# -# if [[ -z "$issue_text" ]]; then -# log_error_and_display "Issue title is empty. Exiting." -# printLogfileAndExit 1 -# fi -# -# log_and_display "You entered the issue title: $issue_text" -# log_and_display "You entered the issue description: $issue_description" -# echo -e "\n" -# -# gum confirm "Do you want to create this issue?" -# # gum confirm exits with status 0 if confirmed and status 1 if cancelled. -# if [ $? -eq 1 ]; then -# do_cancel -# fi -# -# issue_output=$(glab issue create -t"$issue_text" --no-editor --description "$issue_description") -# issue_id=$(echo "$issue_output" | grep -oP '(?<=/issues/)\d+') -# -# work_on_issue_ids+=("$issue_id") -# -# log_action "glab issue with id $issue_id created" -# -# else -# -# print_headline "Use existing issue" -# echo -e "Select issue with arrow keys and press tab or space to select. Press enter to confirm.\n" -# issue_ids=$(gum choose --no-limit "''${gitlabIssues[@]}") -# -# # assign issue_ids to work_on_issue_ids. iterate over lines and take integer from beginning of line -# while IFS= read -r line; do -# work_on_issue_ids+=($(echo "$line" | grep -oP '^\d+')) -# done <<<"$issue_ids" -# -# fi -# -# if [ ''${#work_on_issue_ids[@]} -eq 0 ]; then -# log_and_display "No issue selected. Exiting." -# printLogfileAndExit 0 -# fi -# -# # NEXT STEP COMMIT MESSAGE ############################################################################################################ -# # print work_on_issue_ids -# work_on_issue_ids_string="" -# for i in "''${work_on_issue_ids[@]}"; do -# work_on_issue_ids_string+="#$i " -# done -# -# log_and_display "You chose to work on the following issues: ''${work_on_issue_ids_string}" -# -# -# print_headline "Check for changes to commit" -# -# # ' ' = unmodified -# # M = modified -# # T = file type changed (regular file, symbolic link or submodule) -# # A = added -# # D = deleted -# # R = renamed -# # C = copied (if config option status.renames is set to "copies") -# # U = updated but unmerged -# # https://man.freebsd.org/cgi/man.cgi?query=git-status&sektion=1&manpath=freebsd-release-ports -# -# count_all_changes=$(echo "$git_status" | wc -l) -# count_staged_changes=$(echo "$git_status" | grep -c '^M') -# count_new_staged_files=$(echo "$git_status" | grep -c '^A') -# count_staged_changes=$((count_staged_changes + count_new_staged_files)) -# -# git_options_all="All $count_all_changes changes" -# git_options_staged="Only the $count_staged_changes staged changes" -# git_options_select_files="Select files" -# git_options_cancel="Cancel" -# -# git_options_array=() -# if [[ $count_all_changes -gt 0 ]]; then -# git_options_array+=("$git_options_all") -# fi -# -# if [[ $count_staged_changes -gt 0 ]]; then -# git_options_array+=("$git_options_staged") -# fi -# -# git_options_array+=( "$git_options_select_files" ) -# git_options_array+=( "$git_options_cancel" ) -# -# -# selection=$(gum choose "''${git_options_array[@]}") -# if [[ "$selection" == "$git_options_cancel" ]]; then -# do_cancel -# fi -# -# if [[ "$selection" == "$git_options_all" ]]; then -# git add -A -# echo "1" -# elif [[ "$selection" == "$git_options_select_files" ]]; then -# -# files=() -# while IFS= read -r line; do -# files+=("$line") -# done <<<"$git_status" -# -# selected_files=$(gum choose --no-limit "''${files[@]}") -# -# # no files selected -# if [[ -z "$selected_files" ]]; then -# log_and_display "No files selected. Exiting." -# printLogfileAndExit 0 -# fi -# -# # add selected files -# while IFS= read -r line; do -# ## git proclimne could have letter, ? or ! at the beginning of the line -# file=$(echo "$line" | awk '{print $2}') -# if [[ -z "$file" || ! -f "$file" ]]; then -# log_and_display "No file found in line: $line" -# continue -# fi -# -# git add "$file" -# done <<<"$selected_files" -# -# fi -# -# ## count staged changes again and print -# count_staged_changes=$(echo "$git_status" | grep -c '^M') -# count_new_staged_files=$(echo "$git_status" | grep -c '^A') -# count_staged_changes=$((count_staged_changes + count_new_staged_files)) -# -# log_and_display "You have $count_staged_changes staged changes to commit." -# -# # NEXT STEP COMMIT MESSAGE ############################################################################################################ -# -# print_headline "Enter commit message" -# commit_message=$(gum input --placeholder "Enter commit message" --value "$commit_type: $issue_text $work_on_issue_ids_string") -# -# if [[ -z "$commit_message" ]]; then -# log_error_and_display "Commit message is empty. Exiting." -# printLogfileAndExit 1 -# fi -# -# log_and_display "You entered the commit message: $commit_message" -# -# gum confirm "Do you want to commit with this message?" -# if [ $? -eq 1 ]; then -# do_cancel -# fi -# -# # NEXT STEP COMMIT #################################################################################################################### -# print_headline "Committing changes" -# -# if ! git commit -m "$commit_message" ; then -# log_error_and_display "Commit failed. Exiting." -# printLogfileAndExit 1 -# fi -# -# log_and_display "Commit successful." -# -# # NEXT STEP PUSH ###################################################################################################################### -# -# print_headline "Pushing changes" -# -# if ! git push ; then -# log_error_and_display "Push failed. Exiting." -# printLogfileAndExit 1 -# fi -# -# log_and_display "Push successful." -# -# # Close issue ###################################################################################################################### -# -# print_headline "Closing issues" -# -# for issue_id in "''${work_on_issue_ids[@]}"; do -# -# gum confirm "Do you want to close issue #$issue_id?" -# if [ $? -eq 1 ]; then -# continue -# fi -# -# if ! glab issue close "$issue_id" ; then -# log_error_and_display "Closing issue $issue_id failed. Exiting." -# else -# log_and_display "Closing issue $issue_id successful." -# fi -# done -# -# printLogfileAndExit 0 -# ''; - + enterShell = '' update-files - ''; - + ''; } diff --git a/flake.nix b/flake.nix index a079e7c947607408d6dd204dae0b8d5c850b171f..c08e62ccfd66b067d04be129718a34de18c8fa5e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,82 +1,66 @@ { - description = "Version is a program that automates and simplifies the process of incrementing version numbers for software projects."; + description = "Version is a program that automates and simplifies the process of incrementing version numbers for software projects."; # Nixpkgs / NixOS version to use. inputs.nixpkgs.url = "nixpkgs/nixos-23.05"; - outputs = { self, nixpkgs }: - let + outputs = { + self, + nixpkgs, + }: let + # to work with older version of flakes + lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101"; - # to work with older version of flakes - lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101"; + rootPath = ./.; - rootPath = ./.; + project = import "${rootPath}/project.nix"; - # System types to support. - supportedSystems = [ "x86_64-linux" "x86_64-windows" "x86_64-darwin" ]; + # System types to support. + supportedSystems = ["x86_64-linux" "x86_64-windows" "x86_64-darwin"]; - # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - # Nixpkgs instantiated for supported system types. - nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + # Nixpkgs instantiated for supported system types. + nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;}); + in { + packages = forAllSystems (system: let + pkgs = nixpkgsFor.${system}; + in { + version = pkgs.buildGoModule { + name = "version"; - in - { + # In 'nix develop', we don't need a copy of the source tree + # in the Nix store. + src = ././source; + tags = []; # add your tags here (eq "netgo" "osusergo" "static_build") - packages = forAllSystems (system: - let - pkgs = nixpkgsFor.${system}; - in - { - version = pkgs.buildGoModule { - name = "version"; + #vendorHash = pkgs.lib.fakeHash; + vendorHash = project.vendorHash; - # In 'nix develop', we don't need a copy of the source tree - # in the Nix store. - src = ././source; - tags = []; # add your tags here (eq "netgo" "osusergo" "static_build") + meta = with nixpkgs.legacyPackages.${system}.lib; { + description = "Version is a program that automates and simplifies the process of incrementing version numbers for software projects."; + homepage = "https://gitlab.schukai.com/oss/utilities/version"; + license = licenses.mit; + maintainers = with maintainers; ["schukai GmbH"]; + }; + }; - # This hash locks the dependencies of this package. It is - # necessary because of how Go requires network access to resolve - # VCS. See https://www.tweag.io/blog/2021-03-04-gomod2nix/ for - # details. Normally one can build with a fake sha256 and rely on native Go - # mechanisms to tell you what the hash should be or determine what - # it should be "out-of-band" with other tooling (eg. gomod2nix). - # To begin with it is recommended to set this, but one must - # remeber to bump this hash when your dependencies change. - #vendorSha256 = pkgs.lib.fakeSha256; + default = self.packages.${system}.version; + }); - #vendorHash = pkgs.lib.fakeHash; - vendorHash = "sha256-j3gYTLV+EvGILC1qWiLCPEaSF+XKVwd27pwjckXsT9Q="; + # Add dependencies that are only needed for development + devShells = forAllSystems (system: let + pkgs = nixpkgsFor.${system}; + in { + default = pkgs.mkShell { + buildInputs = with pkgs; [go gopls gotools go-tools]; + }; + }); - meta = with nixpkgs.legacyPackages.${system}.lib; { - description = "Version is a program that automates and simplifies the process of incrementing version numbers for software projects."; - homepage = "https://gitlab.schukai.com/oss/utilities/version"; - license = licenses.mit; - maintainers = with maintainers; [ "schukai GmbH" ]; - }; - - }; - - default = self.packages.${system}.version; - - }); - - # Add dependencies that are only needed for development - devShells = forAllSystems (system: - let - pkgs = nixpkgsFor.${system}; - in - { - default = pkgs.mkShell { - buildInputs = with pkgs; [ go gopls gotools go-tools ]; - }; - }); - - # The default package for 'nix build'. This makes sense if the - # flake provides only one package or there is a clear "main" - # package. - defaultPackage = forAllSystems (system: self.packages.${system}.version); - }; + # The default package for 'nix build'. This makes sense if the + # flake provides only one package or there is a clear "main" + # package. + defaultPackage = forAllSystems (system: self.packages.${system}.version); + }; } diff --git a/project.nix b/project.nix new file mode 100644 index 0000000000000000000000000000000000000000..239a149998d3ddccd3d09e8d0062e1a79409f5f9 --- /dev/null +++ b/project.nix @@ -0,0 +1,10 @@ +{ + name = "Version"; + mnemonic = "version"; + description = "Manage version information"; + supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; + compileForSystems = ["linux/arm64" "linux/amd64" "darwin/amd64" "windows/amd64"]; + modulePath = "gitlab.schukai.com/oss/utilities/version"; + version = "0.1.7"; + vendorHash = "sha256-uyWI6Gnko1J62XDk6jjRdqZ8TSFtwsTOlDwdR9Xc+ic="; +} diff --git a/source/commandline.go b/source/commandline.go index a28d5ff2edf43122eb38d258a8a897e924ed6eed..612357ec01d5e802742640b159edc45f4ba3c154 100644 --- a/source/commandline.go +++ b/source/commandline.go @@ -34,6 +34,7 @@ type commandLineOptions struct { ExitCode bool `short:"e" long:"exit-code-if-no-bump" description:"exit code to use if no notable changes are found"` } `command:"auto" description:"check the git repository and increase the version if necessary. This implies --git"` Predict struct { + ExitCode bool `short:"e" long:"exit-code-if-no-bump" description:"exit code to use if no notable changes are found"` } `command:"predict" description:"predict the next version based on the git history. This implies --git"` Print struct { } `command:"print" description:"print the current version, you can combine this with --git to print the last tag"` @@ -188,7 +189,7 @@ func executeCommand() { exitCode := 0 printMessage := true - if arguments.Auto.ExitCode { + if arguments.Auto.ExitCode || arguments.Predict.ExitCode { if !arguments.Verbose { printMessage = false diff --git a/treefmt.toml b/treefmt.toml new file mode 120000 index 0000000000000000000000000000000000000000..e585279b4929cf46df57e7bb326b108229f1be91 --- /dev/null +++ b/treefmt.toml @@ -0,0 +1 @@ +/nix/store/7fz761spzs45g2kdvpa6fk9j21slwmdv-Taskfile.yaml \ No newline at end of file