Skip to content

Commit

Permalink
compile version into the file
Browse files Browse the repository at this point in the history
  • Loading branch information
tomschlick committed Mar 23, 2024
1 parent 85481c2 commit 8ec613d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ jobs:
- name: Create Spec File
run: PATH="REPO/.github/scripts:${PATH}" create_spec_file.sh

- name: Set the VERSION
run: sed -i 's/VERSION=/VERSION=${{ env.VERSION }}/' ./etc/pkgs-observer-agent.conf.d/service.conf && cat ./etc/pkgs-observer-agent.conf.d/service.conf

- name: Build DEB Package
run: dpkg-deb --build SOURCES/${GITHUB_REPO_NAME} "${{ env.GITHUB_REPO_NAME }}_${{ env.VERSION }}_${{ env.DEB_ARCHITECTURE }}.deb"

Expand Down
3 changes: 2 additions & 1 deletion etc/pkgs-observer-agent.conf.d/service.conf
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
INGEST_ENDPOINT=
INGEST_ENDPOINT=
VERSION=
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,14 @@ func main() {
return
}

version := os.Getenv("VERSION")
if version == "" {
fmt.Println("Error: VERSION environment variable not set")
return
}

payload := Payload{
Version: "1",
Version: version,
Hostname: hostname,
MachineID: machineID,
Distribution: distro,
Expand All @@ -203,7 +209,7 @@ func main() {

req, err := http.NewRequest("POST", ingestEndpoint, bytes.NewBuffer(jsonData))

req.Header.Set("User-Agent", "pkgs.observer-agent/1.0")
req.Header.Set("User-Agent", "pkgs.observer-agent/"+version)
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
Expand Down

0 comments on commit 8ec613d

Please sign in to comment.