diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4a9f58a5d93fab70c8633770a369585747afb78d..b6b28e71f9bc1692ae64d2113f6a0e8596d4aac4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,9 +16,31 @@ variables: stages: # - build -# - deploy + - tag - release + +tag-it: + stage: tag + script: + - git config user.email "''${GITLAB_USER_EMAIL}" + - git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}" + - git config credential.helper '!f() { echo "username=gitlab-ci-token"; echo "password=''${CI_JOB_TOKEN}"; }; f' + - 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 + - version auto exit-code-if-no-bump + - git push origin $CI_COMMIT_REF_NAME + only: + ## regex to x.y branches and master + - master + except: + - tags + release: stage: release image: @@ -28,7 +50,6 @@ release: - tags variables: # Disable shallow cloning so that goreleaser can diff between tags to - # generate a changelog. GIT_DEPTH: 0 script: - cd source; goreleaser release --clean diff --git a/.goreleaser.yml b/.goreleaser.yml index 1795420f16b7efa3d4aa0f8445f2ce22d9601875..3488cad20ed288f3538e1fb4b352e42f89980a5b 120000 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1 +1 @@ -/nix/store/nil8y275ifgp8i2psgfi5ls53qmhihsn-goreleaser.yml \ No newline at end of file +/nix/store/69q2b7irlnvf3cpf80gq07nm3mn6yf9r-goreleaser.yml \ No newline at end of file diff --git a/devenv.nix b/devenv.nix index f420023980ce63271ea5e65cee57309534829691..c18e1f936502e5d136cb133646d84844dcc943ae 100644 --- a/devenv.nix +++ b/devenv.nix @@ -43,7 +43,7 @@ tasks: text = '' # .goreleaser.yml gitlab_urls: - api: https://gitlab.schukai.com/api/v4/ + api: https://gitlab.schukai.com/api/v4 download: https://gitlab.schukai.com # set to true if you use a self-signed certificate @@ -54,10 +54,44 @@ gitlab_urls: # 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: source + #main: 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}} + + ''; }; diff --git a/source/commandline.go b/source/commandline.go index 485847cc3a990115d1cb5eeecf8b1a242caea9fa..a28d5ff2edf43122eb38d258a8a897e924ed6eed 100644 --- a/source/commandline.go +++ b/source/commandline.go @@ -111,7 +111,11 @@ func executeCommand() { } if command == "version" { - fmt.Println(GetMnemonic() + " " + GetVersion() + " (" + GetBuild() + ")") + fmt.Println("Name: ", GetName()) + fmt.Println("Version: ", GetVersion()) + fmt.Println("Build: ", GetBuild()) + fmt.Println("Commit: ", GetCommit()) + fmt.Println("Mnemonic: ", GetMnemonic()) return } diff --git a/source/release.go b/source/release.go index f93f16838507aeb9e1131a6bb1baed2b6ff4dd0f..e3f5901e15878e185b4c862538bc45e9f6dd4569 100644 --- a/source/release.go +++ b/source/release.go @@ -6,18 +6,24 @@ var ( version = "dev" build = "n/a" mnemonic = "version" + name = "Version" + commit = "n/a" ) type Accessor interface { GetVersion() string GetBuild() string GetMnemonic() string + GetCommit() string + GetName() string } type ReleaseStruct struct { Version string Build string Mnemonic string + Commit string + Name string } var release ReleaseStruct @@ -28,6 +34,8 @@ func init() { Version: version, Build: build, Mnemonic: mnemonic, + Commit: commit, + Name: name, } } @@ -42,3 +50,11 @@ func GetBuild() string { func GetMnemonic() string { return release.Mnemonic } + +func GetCommit() string { + return release.Commit +} + +func GetName() string { + return release.Name +}