From 843fa46e6d3bc54828f69ad3a898ffcdbc4cf787 Mon Sep 17 00:00:00 2001 From: "Cuong. Duong Manh" Date: Fri, 17 May 2024 13:15:30 +0700 Subject: [PATCH] =?UTF-8?q?This=20is=20Manh=20Cuong's=20commit=20?= =?UTF-8?q?=F0=9F=8C=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release_build.yml | 12 ------------ .goreleaser.yaml | 7 ++++++- vngcloud/version/version.go | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 vngcloud/version/version.go diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml index 5b1b77a..dc04630 100644 --- a/.github/workflows/release_build.yml +++ b/.github/workflows/release_build.yml @@ -25,10 +25,6 @@ jobs: *Repository*: `${{ github.repository }}` *Author*: `${{ github.actor }}` *Action*: Building `vngcloud-go-sdk:${{ github.ref_name }}` package - *Commit message*: - ``` - ${{ github.event.commits[0].message }} - ``` *See changes*: https://github.com/${{ github.repository }}/commit/${{github.sha}} *See workflow*: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - name: Check out code into the Go module directory @@ -61,10 +57,6 @@ jobs: *Repository*: `${{ github.repository }}` *Author*: `${{ github.actor }}` *Action*: Failed to build `vngcloud-go-sdk:${{ github.ref_name }}` package - *Commit message*: - ``` - ${{ github.event.commits[0].message }} - ``` *See changes*: https://github.com/${{ github.repository }}/commit/${{github.sha}} *See workflow*: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - name: Send alert that the image has been built success @@ -79,9 +71,5 @@ jobs: *Repository*: `${{ github.repository }}` *Author*: `${{ github.actor }}` *Action*: The `vngcloud-go-sdk:${{ github.ref_name }}` package is built successfully - *Commit message*: - ``` - ${{ github.event.commits[0].message }} - ``` *See changes*: https://github.com/${{ github.repository }}/commit/${{github.sha}} *See workflow*: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 1ebf0cc..9b748ce 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,3 +1,8 @@ # .goreleaser.yaml builds: - - skip: true \ No newline at end of file + - skip: true + + ldflags: + - -s + - -w + - -X 'github.com/vngcloud/vngcloud-go-sdk/vngcloud/version.Version={{.Tag}}' \ No newline at end of file diff --git a/vngcloud/version/version.go b/vngcloud/version/version.go new file mode 100644 index 0000000..ad91739 --- /dev/null +++ b/vngcloud/version/version.go @@ -0,0 +1,14 @@ +package version + +import ( + "fmt" + "os" +) + +// Version is set by the linker flags in the Makefile. +var Version string + +func PrintVersionAndExit() { + fmt.Printf("%s\n", Version) + os.Exit(0) +}