From 3b056b367b6a00d47eb50eeab34551a8ba890d91 Mon Sep 17 00:00:00 2001 From: Tom Schlick Date: Sat, 23 Mar 2024 14:05:37 -0400 Subject: [PATCH] feat: tag version in build --- .github/workflows/release.yml | 4 +--- etc/pkgs-observer-agent.conf.d/service.conf | 3 +-- main.go | 8 ++------ 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ce0a5d1..b2e937f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,7 @@ jobs: goarch: ${{ matrix.goarch }} md5sum: OFF compress_assets: OFF + ldflags: "-X main.version=${{ github.event.release.tag_name }} -X main.commit=${{ github.sha }}" package: runs-on: ubuntu-latest @@ -65,9 +66,6 @@ jobs: cd .. ) >> $GITHUB_ENV - - name: Set the VERSION - run: sed -i 's/VERSION=/VERSION=${{ env.VERSION }}/' REPO/etc/pkgs-observer-agent.conf.d/service.conf && cat REPO/etc/pkgs-observer-agent.conf.d/service.conf - - name: Make Directory Structure run: mkdir -p "SOURCES/${GITHUB_REPO_NAME}" SPECS release diff --git a/etc/pkgs-observer-agent.conf.d/service.conf b/etc/pkgs-observer-agent.conf.d/service.conf index 1796a4f..3a86973 100644 --- a/etc/pkgs-observer-agent.conf.d/service.conf +++ b/etc/pkgs-observer-agent.conf.d/service.conf @@ -1,2 +1 @@ -INGEST_ENDPOINT= -VERSION= \ No newline at end of file +INGEST_ENDPOINT= \ No newline at end of file diff --git a/main.go b/main.go index b41a962..52bdf61 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,8 @@ import ( "runtime" ) +var version = "unknown" + type Package struct { RawLine string `json:"raw"` } @@ -178,12 +180,6 @@ func main() { return } - version := os.Getenv("VERSION") - if version == "" { - fmt.Println("Error: VERSION environment variable not set") - return - } - payload := Payload{ Version: version, Hostname: hostname,