diff --git a/.attach_pid1994321 b/.attach_pid1994321 deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/.envrc b/.envrc index 45f9325a0d9b74d493dfc7af399bfdc2eef46a06..c86b70c54565e833c26143c9782f5f17088540cb 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,9 @@ -source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0=" +use flake AWS_PROFILE=schukai +export AWS_PROFILE +source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0=" + use devenv + + + diff --git a/.gitignore b/.gitignore index 7aeb0bda140a77473f5dfa00a8bda1233a927e34..c063c483ba88e4145c7bdf112e74299678288987 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ devenv.local.nix .attach_pid* /build/ + + +dist \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6621a80ce8256d70096891cd18d450928f0ac863..3d7565bcc0a0fb43fd5922af67b7e6ff4da09184 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,14 +1,67 @@ -# You can override the included template(s) by including variable overrides -# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings -# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings -# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings -# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings -# Note that environment variables can be set in several places -# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence +image: docker-registry.schukai.com:443/nixos-ci-devenv:latest + +services: + - docker:dind + + +variables: + # The repo name as used in + # https://github.com/nix-community/NUR/blob/master/repos.json + NIXOS_VERSION: "23.05" + NIXPKGS_ALLOW_UNFREE: "1" + NIXPKGS_ALLOW_INSECURE: "1" + DOCKER_DRIVER: overlay2 + GIT_DEPTH: 10 + + stages: -- test -sast: - stage: test -include: -- template: Security/SAST.gitlab-ci.yml -- template: Security/Secret-Detection.gitlab-ci.yml + - build + - deploy + +before_script: + - nix shell nixpkgs#coreutils-full -c mkdir -p /certs/client/ + - nix shell nixpkgs#coreutils-full -c ln -fs /etc/ssl/certs/ca-bundle.crt /certs/client/ca.pem + - echo > .env-gitlab-ci + - variables=("HOME=$HOME" "CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME" "CI_REPOSITORY_URL=$CI_REPOSITORY_URL" "GITLAB_TOKEN=$GITLAB_TOKEN" "CI_JOB_TOKEN=$CI_JOB_TOKEN" "GITLAB_USER_EMAIL=$GITLAB_USER_EMAIL" "GITLAB_USER_NAME=\"$GITLAB_USER_NAME\"" "CI_REGISTRY_USER=$CI_REGISTRY_USER" "CI_PROJECT_ID=$CI_PROJECT_ID" "CI_PROJECT_DIR=$CI_PROJECT_DIR" "CI_API_V4_URL=$CI_API_V4_URL" "CI_PROJECT_NAME=$CI_PROJECT_NAME" "CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA"); for var in "${variables[@]}"; do echo "$var" >> .env-gitlab-ci; done + - cat .env-gitlab-ci + +after_script: + - if [ -f .env-gitlab-ci ]; then rm .env-gitlab-ci; fi + +build: + stage: build + tags: + - nixos + script: + - devenv shell build-app + + cache: + - key: nixos + paths: + - /nix/store + + artifacts: + paths: + - dist + +deploy: + stage: deploy + tags: + - nixos + script: + - devenv shell -c deploy-app + + when: on_success + + cache: + - key: nixos + paths: + - /nix/store + + + artifacts: + paths: + - dist + + + diff --git a/.idea/version.iml b/.idea/version.iml index 9b4b74933ef63213f3b3ee6492b3da131df6c11b..e03d8ecfb9d940ecf515056b738acafa6c313055 100644 --- a/.idea/version.iml +++ b/.idea/version.iml @@ -6,6 +6,7 @@ <content url="file://$MODULE_DIR$"> <excludeFolder url="file://$MODULE_DIR$/.devenv" /> <excludeFolder url="file://$MODULE_DIR$/.direnv" /> + <excludeFolder url="file://$MODULE_DIR$/build" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> diff --git a/Makefile b/Makefile deleted file mode 100644 index eefa9066ba8cafa7a320d11b9e7fb4f64412dad7..0000000000000000000000000000000000000000 --- a/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 -THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) -PROJECT_ROOT:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)/ -THIS_MAKEFILE:=$(PROJECT_ROOT)$(THIS_MAKEFILE_PATH) - -GO:=go -BUILD_PATH:=$(PROJECT_ROOT)build/ - -info: - echo "PROJECT_ROOT: $(PROJECT_ROOT)" - -## Compiling for every OS and Platform -compile: - - 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)" - - cd $(PROJECT_ROOT); GOOS=linux GOARCH=arm $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-linux-arm; cd - - cd $(PROJECT_ROOT); GOOS=linux GOARCH=amd64 $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-linux-amd64; cd - - cd $(PROJECT_ROOT); GOOS=linux GOARCH=arm64 $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-linux-arm64; cd - - cd $(PROJECT_ROOT); GOOS=linux GOARCH=386 $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-linux-386; cd - - cd $(PROJECT_ROOT); GOOS=windows GOARCH=amd64 $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-windows; cd - - -## compile and deplay to aws -deploy: compile - find $(BUILD_PATH) -iname "version-*" -exec aws s3 cp {} s3://download.schukai.com/tools/version/ \; - -## overview-to-aws -overview-to-aws: - aws s3 cp $(PROJECT_ROOT)/data/index.html s3://download.schukai.com/tools/version/ \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000000000000000000000000000000000000..adca507c01815ac863d31cb599de1917770a0498 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,24 @@ +version: '3' + +tasks: + + default: + aliases: + - help + cmds: + - task --list + + build: + desc: Build the app + aliases: + - b + vars: + DEVENV_ROOT: + sh: echo "$DEVENV_ROOT" + + cmds: + - devenv shell build-app + sources: + - source/**/*.go + - source/**/*.mod + - dist/** diff --git a/devenv.nix b/devenv.nix index f802f6af506f3a5fa0b853dd1a0a320e44fbbd32..d7c67b53ed6fd42c5a0811334f3a0daafefe0afa 100644 --- a/devenv.nix +++ b/devenv.nix @@ -2,6 +2,11 @@ { pkgs, inputs, phps, lib, config, modulesPath,... }: { + + + env.LD_LIBRARY_PATH = lib.makeLibraryPath [ ]; + env.APP_NAME = "version"; + # https://devenv.sh/packages/ packages = [ inputs.version.defaultPackage."${builtins.currentSystem}" @@ -13,6 +18,9 @@ pkgs.jq pkgs.delve pkgs.gdlv + pkgs.wget + pkgs.glab + pkgs.unixtools.xxd pkgs.libffi pkgs.zlib pkgs.procps @@ -20,22 +28,161 @@ pkgs.ranger pkgs.meld pkgs.gnused - pkgs.coreutils-full # # https://search.nixos.org/packages?channel=23.05&show=coreutils-full&from=0&size=50&sort=relevance&type=packages&query=mkdir + pkgs.coreutils-full pkgs.gnugrep pkgs.gnumake pkgs.util-linux pkgs.httpie pkgs.netcat pkgs.memcached - pkgs.fd + pkgs.fd ]; + + # https://devenv.sh/languages/ + # languages.nix.enable = true; languages = { - go = { - enable = true; - }; + go = { enable = true; }; }; + + difftastic.enable = true; + + # 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 -euo pipefail +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.exa}/bin/ +PATH="''${PATH}":${pkgs.git}/bin/ +PATH="''${PATH}":${pkgs.gnugrep}/bin/ +PATH="''${PATH}":${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/ + +export -f 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) + buildDate=''$(version date) +fi + +${config.devenv.root}/bin/go-compile.sh \ + "${config.devenv.root}/source/" \ + "${config.devenv.root}/dist"/ \ + "bob" \ + "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.exa}/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 +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 $(exa "''${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" + + ''; + + +} diff --git a/flake.nix b/flake.nix index d096fa401cd3cb2131245dafb70fe41bcc389ff3..595fe943d8363dd92734aa36dfec9f3f3d65d155 100644 --- a/flake.nix +++ b/flake.nix @@ -42,7 +42,7 @@ version = pversion; # In 'nix develop', we don't need a copy of the source tree # in the Nix store. - src = ./.; + src = ././source; # This hash locks the dependencies of this package. It is # necessary because of how Go requires network access to resolve diff --git a/main.go b/main.go deleted file mode 100644 index 05c03fa186cf5e037c0653313b52d65721d938ec..0000000000000000000000000000000000000000 --- a/main.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "golang.org/x/text/message" -) - -// Wird beim Bauen per -// -ldflags "-X main.version=$app_version -X main.build=$(due --iso-8601 | tr -d "-" )" -// gesetzt -var ( - version string - build string - printer *message.Printer -) - -func main() { - executeCommand() -} diff --git a/release.json b/release.json deleted file mode 100644 index d27833d471e88bbed7181899a44b50a89c090348..0000000000000000000000000000000000000000 --- a/release.json +++ /dev/null @@ -1 +0,0 @@ -{"version":"0.4.0"} diff --git a/commandline.go b/source/commandline.go similarity index 96% rename from commandline.go rename to source/commandline.go index 9160c2fba8f27d2608fee954d7b969ae3d797dbe..fb8736c59ac9b75ad1f556a470685bc7cac5d07f 100644 --- a/commandline.go +++ b/source/commandline.go @@ -36,6 +36,8 @@ type commandLineOptions struct { } `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"` + Version struct { + } `command:"version" description:"print the version of this tool"` } func increasePatch() (string, error) { @@ -103,6 +105,11 @@ func executeCommand() { nullTerminated = true } + if command == "version" { + fmt.Println(GetMnemonic() + " " + GetVersion() + " (" + GetBuild() + ")") + return + } + if command == "predict" { predict = true } diff --git a/errors.go b/source/errors.go similarity index 100% rename from errors.go rename to source/errors.go diff --git a/git.go b/source/git.go similarity index 99% rename from git.go rename to source/git.go index 36650d22f41a31346acbcfcb418a322d21f097b5..e7eb2a8d9cf5a860e2646df42841bd86f0d3e8bc 100644 --- a/git.go +++ b/source/git.go @@ -7,10 +7,11 @@ import ( "strconv" "strings" - "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" "github.com/go-git/go-git/v5/plumbing/storer" + + "github.com/go-git/go-git/v5" ) var versionRegex = regexp.MustCompile(`^v?(\d+)\.(\d+)\.(\d+).*$`) diff --git a/go.mod b/source/go.mod similarity index 88% rename from go.mod rename to source/go.mod index ab930f3f71ed5f04cf78b2efe58c7e8067267bab..5a73fe2dc6cef08b14c5c93bb09145ec49cf680b 100644 --- a/go.mod +++ b/source/go.mod @@ -4,9 +4,9 @@ go 1.18 require ( github.com/Masterminds/semver v1.5.0 - github.com/go-git/go-git/v5 v5.7.0 + github.com/go-git/go-git/v5 v5.8.1 github.com/jessevdk/go-flags v1.5.0 - github.com/tidwall/gjson v1.14.4 + github.com/tidwall/gjson v1.15.0 github.com/tidwall/sjson v1.2.5 github.com/vmware-labs/yaml-jsonpath v0.3.2 golang.org/x/text v0.11.0 @@ -14,8 +14,9 @@ require ( ) require ( + dario.cat/mergo v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230710112148-e01326fd72eb // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/cloudflare/circl v1.3.3 // indirect github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect diff --git a/go.sum b/source/go.sum similarity index 97% rename from go.sum rename to source/go.sum index 82cc2feeaf44bdae46a809cbbc8c5f996402b2a6..22b2ee19303ce4a0a55089ae56b16bb818a8b49f 100644 --- a/go.sum +++ b/source/go.sum @@ -1,3 +1,5 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= @@ -13,6 +15,8 @@ github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903 h1:ZK3C5DtzV2 github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903/go.mod h1:8TI4H3IbrackdNgv+92dI+rhpCaLqM0IfpgCgenFvRE= github.com/ProtonMail/go-crypto v0.0.0-20230710112148-e01326fd72eb h1:RU+Ff2vE68zFQSoBqlb/LChFztEWWJ9EZ8LU4gA3ubU= github.com/ProtonMail/go-crypto v0.0.0-20230710112148-e01326fd72eb/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs= +github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= @@ -58,6 +62,8 @@ github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/go-git/go-git/v5 v5.7.0 h1:t9AudWVLmqzlo+4bqdf7GY+46SUuRsx59SboFxkq2aE= github.com/go-git/go-git/v5 v5.7.0/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhcZd8Fodw8= +github.com/go-git/go-git/v5 v5.8.1 h1:Zo79E4p7TRk0xoRgMq0RShiTHGKcKI4+DI6BfJc/Q+A= +github.com/go-git/go-git/v5 v5.8.1/go.mod h1:FHFuoD6yGz5OSKEBK+aWN9Oah0q54Jxl0abmj6GnqAo= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -148,6 +154,8 @@ github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vl github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.15.0 h1:5n/pM+v3r5ujuNl4YLZLsQ+UE5jlkLVm7jMzT5Mpolw= +github.com/tidwall/gjson v1.15.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= diff --git a/source/main.go b/source/main.go new file mode 100644 index 0000000000000000000000000000000000000000..d144778ab60e7024d1fd76cfaf8e02ee30ad1ed6 --- /dev/null +++ b/source/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "golang.org/x/text/message" +) + +var ( + printer *message.Printer +) + +func main() { + executeCommand() +} diff --git a/source/release.go b/source/release.go new file mode 100644 index 0000000000000000000000000000000000000000..f93f16838507aeb9e1131a6bb1baed2b6ff4dd0f --- /dev/null +++ b/source/release.go @@ -0,0 +1,44 @@ +package main + +// Used when building per +// -ldflags "-X main.version=$version -X main.build=$(due --iso-8601 | tr -d "-" )" +var ( + version = "dev" + build = "n/a" + mnemonic = "version" +) + +type Accessor interface { + GetVersion() string + GetBuild() string + GetMnemonic() string +} + +type ReleaseStruct struct { + Version string + Build string + Mnemonic string +} + +var release ReleaseStruct + +func init() { + + release = ReleaseStruct{ + Version: version, + Build: build, + Mnemonic: mnemonic, + } +} + +func GetVersion() string { + return release.Version +} + +func GetBuild() string { + return release.Build +} + +func GetMnemonic() string { + return release.Mnemonic +} diff --git a/version.go b/source/version.go similarity index 100% rename from version.go rename to source/version.go index e5f0263ed695b3180ada9e06db5e7a01b2fac9c5..4ffa04bfbeae6af50ffb9fa107009e3cf1fccc64 100644 --- a/version.go +++ b/source/version.go @@ -3,7 +3,6 @@ package main import ( "bufio" "fmt" - "github.com/go-git/go-git/v5" "os" "path/filepath" "strings" @@ -13,10 +12,11 @@ import ( "github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath" - "gopkg.in/yaml.v3" - "github.com/Masterminds/semver" + "github.com/go-git/go-git/v5" "github.com/tidwall/gjson" + + "gopkg.in/yaml.v3" ) var ( diff --git a/version.json b/version.json deleted file mode 100644 index 0caa9ca01bb74200b0f97c06fb997d01880f11bc..0000000000000000000000000000000000000000 --- a/version.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.33" -} \ No newline at end of file