diff --git a/.github/workflows/winres-check.yml b/.github/workflows/winres-check.yml new file mode 100644 index 00000000..f15e2993 --- /dev/null +++ b/.github/workflows/winres-check.yml @@ -0,0 +1,51 @@ +name: Windows Version Resource Check + +on: + pull_request: + paths: + - 'cmd/**' + - '.github/workflows/winres-check.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + winres-check: + name: Verify Windows version resource + runs-on: cx-public-ubuntu-x64 + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v6 + with: + persist-credentials: false + + - name: Setup Go + uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 #v4 + with: + go-version-file: go.mod + + # committed .syso files must match what winres.json generates + - name: Committed resources match winres.json + run: | + tmp="$(mktemp -d)" + go run github.com/tc-hib/go-winres@v0.3.3 make --in cmd/winres/winres.json --out "$tmp/rsrc" --arch amd64,386,arm64 + for a in amd64 386 arm64; do + cmp "$tmp/rsrc_windows_$a.syso" "cmd/rsrc_windows_$a.syso" \ + || { echo "::error::cmd/rsrc_windows_$a.syso is out of date, run 'make winres' and commit"; exit 1; } + done + + # the built Windows exe must carry the publisher info + - name: Built Windows binaries carry Checkmarx version info + run: | + tmp="$(mktemp -d)" + for a in amd64 386 arm64; do + CGO_ENABLED=0 GOOS=windows GOARCH=$a go build -o "$tmp/cx_$a.exe" ./cmd + for s in "Checkmarx" "Checkmarx One CLI"; do + strings -el "$tmp/cx_$a.exe" | grep -qx "$s" \ + || { echo "::error::windows/$a build is missing version info '$s'"; exit 1; } + done + done diff --git a/.goreleaser-dev.yml b/.goreleaser-dev.yml index 1ba2f93c..49278a4e 100644 --- a/.goreleaser-dev.yml +++ b/.goreleaser-dev.yml @@ -6,7 +6,7 @@ release: disable: true builds: - - main: ./cmd/main.go + - main: ./cmd env: - CGO_ENABLED=0 binary: cx @@ -43,7 +43,7 @@ builds: # - SIGNING_HSM_CREDS={{ .Env.SIGNING_HSM_CREDS }} # - SIGNING_REMOTE_SSH_PRIVATE_KEY={{ .Env.SIGNING_REMOTE_SSH_PRIVATE_KEY }} - - main: ./cmd/main.go + - main: ./cmd env: - CGO_ENABLED=0 binary: cx diff --git a/.goreleaser.yml b/.goreleaser.yml index b1595d6f..4eb8b4e0 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,7 +5,7 @@ release: disable: true builds: - - main: ./cmd/main.go + - main: ./cmd env: - CGO_ENABLED=0 binary: cx @@ -42,7 +42,7 @@ builds: # - SIGNING_HSM_CREDS={{ .Env.SIGNING_HSM_CREDS }} # - SIGNING_REMOTE_SSH_PRIVATE_KEY={{ .Env.SIGNING_REMOTE_SSH_PRIVATE_KEY }} - - main: ./cmd/main.go + - main: ./cmd env: - CGO_ENABLED=0 binary: cx diff --git a/Makefile b/Makefile index d1db47d8..e6b7d8b6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .DEFAULT_GOAL := vet -.PHONY:fmt vet build lint +.PHONY:fmt vet build lint winres fmt: go fmt ./... vet: fmt @@ -8,4 +8,7 @@ vet: fmt build: vet go build -o bin/cx.exe ./cmd lint: fmt - golangci-lint run -c .golangci.yml \ No newline at end of file + golangci-lint run -c .golangci.yml +# regenerate the committed Windows version resources (only needed when cmd/winres/winres.json changes) +winres: + go run github.com/tc-hib/go-winres@v0.3.3 make --in cmd/winres/winres.json --out cmd/rsrc --arch amd64,386,arm64 diff --git a/cmd/rsrc_windows_386.syso b/cmd/rsrc_windows_386.syso new file mode 100644 index 00000000..b58aa16c Binary files /dev/null and b/cmd/rsrc_windows_386.syso differ diff --git a/cmd/rsrc_windows_amd64.syso b/cmd/rsrc_windows_amd64.syso new file mode 100644 index 00000000..737d6d3f Binary files /dev/null and b/cmd/rsrc_windows_amd64.syso differ diff --git a/cmd/rsrc_windows_arm64.syso b/cmd/rsrc_windows_arm64.syso new file mode 100644 index 00000000..f75b8cfa Binary files /dev/null and b/cmd/rsrc_windows_arm64.syso differ diff --git a/cmd/winres/winres.json b/cmd/winres/winres.json new file mode 100644 index 00000000..128454e9 --- /dev/null +++ b/cmd/winres/winres.json @@ -0,0 +1,24 @@ +{ + "RT_VERSION": { + "#1": { + "0000": { + "fixed": { + "file_version": "0.0.0.0", + "product_version": "0.0.0.0" + }, + "info": { + "0409": { + "CompanyName": "Checkmarx", + "FileDescription": "Checkmarx One CLI", + "FileVersion": "0.0.0", + "InternalName": "cx", + "LegalCopyright": "Copyright (c) Checkmarx Ltd.", + "OriginalFilename": "cx.exe", + "ProductName": "Checkmarx One CLI", + "ProductVersion": "0.0.0" + } + } + } + } + } +}