From 76743c2f932fd0f9dc48313a131904dfbbe402c7 Mon Sep 17 00:00:00 2001 From: Volker Schukai <volker.schukai@schukai.com> Date: Wed, 3 Jan 2024 12:21:21 +0100 Subject: [PATCH] fix: test gorelease --- .gitlab-ci.yml | 25 +++++++++++++++++++++++-- .goreleaser.yml | 2 +- devenv.nix | 38 ++++++++++++++++++++++++++++++++++++-- source/commandline.go | 6 +++++- source/release.go | 16 ++++++++++++++++ 5 files changed, 81 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4a9f58a..b6b28e7 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 1795420..3488cad 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 f420023..c18e1f9 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 485847c..a28d5ff 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 f93f168..e3f5901 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 +} -- GitLab