From e9b1c471bb2ec9277468c791eb30b67ff1102775 Mon Sep 17 00:00:00 2001
From: Christian Zunker <827818+czunker@users.noreply.github.com>
Date: Tue, 31 Oct 2023 10:04:21 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Set=20cnquery=20version=20for=20?=
 =?UTF-8?q?goreleaser=20(#147)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Christian Zunker <christian@mondoo.com>
---
 .github/workflows/release.yaml | 3 +++
 .goreleaser.yml                | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index ef668fe..47327b6 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -24,6 +24,8 @@ jobs:
         with:
           go-version: ">=${{ env.golang-version }}"
           cache: false
+      - name: Set cnspec version
+        run: echo "CNSPEC_VERSION=$(go list -json -m go.mondoo.com/cnspec/v9 | jq -r '.Version')" >> $GITHUB_ENV
       - name: Run GoReleaser
         uses: goreleaser/goreleaser-action@v5
         with:
@@ -32,6 +34,7 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           API_VERSION: x5.0
+          CNSPEC_VERSION: ${{ env.CNSPEC_VERSION }}
       - name: Install Github CLI (gh)
         if: ${{ env.RUNNER_TYPE != 'self-hosted' }}
         run: |
diff --git a/.goreleaser.yml b/.goreleaser.yml
index 580a2bf..e07af5a 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -22,7 +22,7 @@ builds:
       - arm64
       - arm
     ldflags:
-      - -s -w -X go.mondoo.com/packer-plugin-cnspec/version.Version={{.Version}} -X go.mondoo.com/packer-plugin-cnspec/version.Build={{.ShortCommit}} -X go.mondoo.com/packer-plugin-cnspec/version.Date={{.Date}}
+      - -s -w -X go.mondoo.com/cnquery/v9.Version={{ .Env.CNSPEC_VERSION }} -X go.mondoo.com/packer-plugin-cnspec/version.Version={{.Version}} -X go.mondoo.com/packer-plugin-cnspec/version.Build={{.ShortCommit}} -X go.mondoo.com/packer-plugin-cnspec/version.Date={{.Date}}
   - id: packer-plugin-cnspec-windows
     binary: 'packer-plugin-cnspec_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
     goos:
@@ -31,7 +31,7 @@ builds:
       - amd64
       - arm64
     ldflags:
-      - -s -w -X go.mondoo.com/packer-plugin-cnspec/version.Version={{.Version}} -X go.mondoo.com/packer-plugin-cnspec/version.Build={{.ShortCommit}} -X go.mondoo.com/packer-plugin-cnspec/version.Date={{.Date}}
+      - -s -w -X go.mondoo.com/cnquery/v9.Version={{ .Env.CNSPEC_VERSION }} -X go.mondoo.com/packer-plugin-cnspec/version.Version={{.Version}} -X go.mondoo.com/packer-plugin-cnspec/version.Build={{.ShortCommit}} -X go.mondoo.com/packer-plugin-cnspec/version.Date={{.Date}}
   - id: packer-plugin-cnspec-darwin
     binary: 'packer-plugin-cnspec_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
     goos:
@@ -40,7 +40,7 @@ builds:
       - amd64
       - arm64
     ldflags:
-      - -s -w -X go.mondoo.com/packer-plugin-cnspec/version.Version={{.Version}} -X go.mondoo.com/packer-plugin-cnspec/version.Build={{.ShortCommit}} -X go.mondoo.com/packer-plugin-cnspec/version.Date={{.Date}} 
+      - -s -w -X go.mondoo.com/cnquery/v9.Version={{ .Env.CNSPEC_VERSION }} -X go.mondoo.com/packer-plugin-cnspec/version.Version={{.Version}} -X go.mondoo.com/packer-plugin-cnspec/version.Build={{.ShortCommit}} -X go.mondoo.com/packer-plugin-cnspec/version.Date={{.Date}} 
   
   # building fall-back binaries
   - id: packer-plugin-mondoo