From ac1f68f8771d9f40c1ddbc0d123cc0f17c06a52a Mon Sep 17 00:00:00 2001 From: rmvangun <85766511+rmvangun@users.noreply.github.com> Date: Thu, 8 May 2025 20:46:11 -0400 Subject: [PATCH 01/15] Include a context ID (#1121) --- pkg/controller/controller.go | 5 +++ pkg/controller/controller_test.go | 54 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 554c4a4a3..bc3a2e83e 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -749,6 +749,11 @@ func (c *BaseController) createConfigComponent(req Requirements) error { return nil } + // Generate context ID + if err := configHandler.GenerateContextID(); err != nil { + return fmt.Errorf("failed to generate context ID: %w", err) + } + return nil } diff --git a/pkg/controller/controller_test.go b/pkg/controller/controller_test.go index dcbe1f2e2..46399e388 100644 --- a/pkg/controller/controller_test.go +++ b/pkg/controller/controller_test.go @@ -2285,6 +2285,60 @@ func TestBaseController_createConfigComponent(t *testing.T) { t.Errorf("Expected no error, got %v", err) } }) + + t.Run("GeneratesContextID", func(t *testing.T) { + // Given a controller with a config handler + controller, mocks := setup(t) + mockConfigHandler := config.NewMockConfigHandler() + var generateCalled bool + mockConfigHandler.GenerateContextIDFunc = func() error { + generateCalled = true + return nil + } + controller.constructors.NewConfigHandler = func(di.Injector) config.ConfigHandler { + return mockConfigHandler + } + + // Clear any existing config handler + mocks.Injector.Register("configHandler", nil) + + // When creating the config component + err := controller.createConfigComponent(Requirements{}) + + // Then context ID should be generated + if err != nil { + t.Errorf("Expected no error, got: %v", err) + } + if !generateCalled { + t.Error("Expected GenerateContextID to be called") + } + }) + + t.Run("HandlesGenerateContextIDError", func(t *testing.T) { + // Given a controller with a failing config handler + controller, mocks := setup(t) + mockConfigHandler := config.NewMockConfigHandler() + mockConfigHandler.GenerateContextIDFunc = func() error { + return fmt.Errorf("failed to generate context ID") + } + controller.constructors.NewConfigHandler = func(di.Injector) config.ConfigHandler { + return mockConfigHandler + } + + // Clear any existing config handler + mocks.Injector.Register("configHandler", nil) + + // When creating the config component + err := controller.createConfigComponent(Requirements{}) + + // Then the error should be propagated + if err == nil { + t.Error("Expected error, got nil") + } + if !strings.Contains(err.Error(), "failed to generate context ID") { + t.Errorf("Expected error about context ID generation, got: %v", err) + } + }) } func TestBaseController_createSecretsComponents(t *testing.T) { From a4d42ec9766fdcb70c43034bdbb4b648065123ac Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 21:37:11 -0400 Subject: [PATCH 02/15] Try first chocolatey publish --- .github/workflows/ci.yaml | 13 +++++++-- .goreleaser.yaml | 58 ++++++++++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6c82b7b5f..316fa29dc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -149,14 +149,23 @@ jobs: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.GPG_PASSPHRASE }} + - name: Check if prerelease + id: prerelease + run: | + if [[ "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+- ]]; then + echo "prerelease=true" >> $GITHUB_OUTPUT + else + echo "prerelease=false" >> $GITHUB_OUTPUT + fi + - name: Run GoReleaser uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 with: version: "~> v2" - args: release --clean + args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GPG_FINGERPRINT: ${{ env.GPG_FINGERPRINT }} HOMEBREW_CLI_WRITE_PAT: ${{ secrets.HOMEBREW_CLI_WRITE_PAT }} + CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} GITHUB_SHA: ${{ github.sha }} - SKIP_HOMEBREW: ${{ steps.prerelease.outputs.prerelease == 'true' }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 4bc428f6e..9b72776da 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -15,11 +15,11 @@ builds: - CGO_ENABLED=0 main: ./cmd/windsor goos: - - darwin - - linux + # - darwin + # - linux - windows goarch: - - arm64 + # - arm64 - amd64 ldflags: - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.version={{ .Version }}'" @@ -59,16 +59,48 @@ binary_signs: signs: - artifacts: checksum -brews: +# brews: +# - name: windsor +# directory: Formula +# repository: +# owner: windsorcli +# name: homebrew-cli +# branch: main +# token: "{{ .Env.HOMEBREW_CLI_WRITE_PAT }}" +# homepage: "https://windsorcli.github.io" +# description: "The Windsor Command Line Interface" +# ids: +# - windsor + +chocolateys: - name: windsor - directory: Formula - skip_upload: "{{ eq .Env.SKIP_HOMEBREW \"true\" }}" - repository: - owner: windsorcli - name: homebrew-cli - branch: main - token: "{{ .Env.HOMEBREW_CLI_WRITE_PAT }}" - homepage: "https://windsorcli.github.io" - description: "The Windsor Command Line Interface" ids: - windsor + package_source_url: https://github.com/windsorcli/cli + owners: Windsor CLI + title: Windsor CLI + authors: Windsor CLI Team + project_url: https://windsorcli.github.io + # icon_url: https://windsorcli.github.io/icon.png + copyright: "{{ .Year }} Windsor CLI Team" + license_url: https://github.com/windsorcli/cli/blob/main/LICENSE + require_license_acceptance: false + project_source_url: https://github.com/windsorcli/cli + docs_url: https://windsorcli.github.io + bug_tracker_url: https://github.com/windsorcli/cli/issues + tags: "cli windows command-line" + summary: "The Windsor Command Line Interface" + description: | + The Windsor CLI assists your cloud native development workflow. + This package provides the Windows installer for Windsor CLI. + + After installation, add the following line to your PowerShell profile to enable shell integration: + ```powershell + Invoke-Expression (& windsor hook powershell) + ``` + + Your PowerShell profile is located at: $PROFILE + release_notes: "https://github.com/windsorcli/cli/releases/tag/v{{ .Version }}" + skip_publish: false + api_key: "{{ .Env.CHOCOLATEY_API_KEY }}" + source_repo: "https://push.chocolatey.org/" From 954228d879b1fa49550671fe2f41db69a03a10b5 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 21:42:11 -0400 Subject: [PATCH 03/15] Just run chocolatey --- .github/workflows/ci.yaml | 184 +++++++++++++++++++------------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 316fa29dc..9fed530c8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,106 +13,106 @@ permissions: issues: read pull-requests: read jobs: - build-and-test: - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - arch: [amd64, arm64] - exclude: - - os: windows-latest - arch: arm64 - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Install Aqua - uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 - with: - aqua_version: v2.51.1 - - - name: Install tools - run: aqua install - - - name: Cache Go Modules - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + # build-and-test: + # strategy: + # matrix: + # os: [ubuntu-latest, windows-latest, macos-latest] + # arch: [amd64, arm64] + # exclude: + # - os: windows-latest + # arch: arm64 + # runs-on: ${{ matrix.os }} + + # steps: + # - name: Checkout code + # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + # - name: Install Aqua + # uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 + # with: + # aqua_version: v2.51.1 + + # - name: Install tools + # run: aqua install + + # - name: Cache Go Modules + # uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + # with: + # path: | + # ~/.cache/go-build + # ~/go/pkg/mod + # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # restore-keys: | + # ${{ runner.os }}-go- - - name: Install Dependencies - run: go install ./... + # - name: Install Dependencies + # run: go install ./... - - name: Run tests - run: task test - - - name: Test Build Windsor CLI on macOS/Linux - if: ${{ matrix.os != 'windows-latest' }} - run: | - VERSION=$(echo "${GITHUB_REF}" | sed 's/refs\/heads\///' | sed 's/refs\/tags\///') - echo "Testing build for version: $VERSION" - COMMIT_SHA=${{ github.sha }} - if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then - GOOS=linux GOARCH=${{ matrix.arch }} go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$COMMIT_SHA'" -o /dev/null cmd/windsor/main.go - elif [ "${{ matrix.os }}" == "macos-latest" ]; then - GOOS=darwin GOARCH=${{ matrix.arch }} go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$COMMIT_SHA'" -o /dev/null cmd/windsor/main.go - fi - - - name: Test Build Windsor CLI on Windows - if: ${{ matrix.os == 'windows-latest' }} - run: | - $env:VERSION = $env:GITHUB_REF -replace 'refs/heads/', '' -replace 'refs/tags/', '' - echo "Testing build for version: $env:VERSION" - $env:COMMIT_SHA = "${{ github.sha }}" - $env:GOOS = "windows" - $env:GOARCH = "${{ matrix.arch }}" - go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$env:VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$env:COMMIT_SHA'" -o NUL cmd\windsor\main.go - shell: pwsh - - sast-scan: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Install Aqua - uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 - with: - aqua_version: v2.51.1 - - - name: Install tools - run: aqua install - - - name: Cache Go Modules - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + # - name: Run tests + # run: task test + + # - name: Test Build Windsor CLI on macOS/Linux + # if: ${{ matrix.os != 'windows-latest' }} + # run: | + # VERSION=$(echo "${GITHUB_REF}" | sed 's/refs\/heads\///' | sed 's/refs\/tags\///') + # echo "Testing build for version: $VERSION" + # COMMIT_SHA=${{ github.sha }} + # if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then + # GOOS=linux GOARCH=${{ matrix.arch }} go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$COMMIT_SHA'" -o /dev/null cmd/windsor/main.go + # elif [ "${{ matrix.os }}" == "macos-latest" ]; then + # GOOS=darwin GOARCH=${{ matrix.arch }} go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$COMMIT_SHA'" -o /dev/null cmd/windsor/main.go + # fi + + # - name: Test Build Windsor CLI on Windows + # if: ${{ matrix.os == 'windows-latest' }} + # run: | + # $env:VERSION = $env:GITHUB_REF -replace 'refs/heads/', '' -replace 'refs/tags/', '' + # echo "Testing build for version: $env:VERSION" + # $env:COMMIT_SHA = "${{ github.sha }}" + # $env:GOOS = "windows" + # $env:GOARCH = "${{ matrix.arch }}" + # go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$env:VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$env:COMMIT_SHA'" -o NUL cmd\windsor\main.go + # shell: pwsh + + # sast-scan: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + # - name: Install Aqua + # uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 + # with: + # aqua_version: v2.51.1 + + # - name: Install tools + # run: aqua install + + # - name: Cache Go Modules + # uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + # with: + # path: | + # ~/.cache/go-build + # ~/go/pkg/mod + # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # restore-keys: | + # ${{ runner.os }}-go- - - name: Install Dependencies - run: go install ./... + # - name: Install Dependencies + # run: go install ./... - - name: Run Gosec Security Scanner - uses: securego/gosec@955a68d0d19f4afb7503068f95059f7d0c529017 # v2.22.3 - with: - args: ./... - env: - GOTOOLCHAIN: 'local' - GOFLAGS: '-buildvcs=false' + # - name: Run Gosec Security Scanner + # uses: securego/gosec@955a68d0d19f4afb7503068f95059f7d0c529017 # v2.22.3 + # with: + # args: ./... + # env: + # GOTOOLCHAIN: 'local' + # GOFLAGS: '-buildvcs=false' release: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') - needs: [build-and-test, sast-scan] + # needs: [build-and-test, sast-scan] steps: - name: Checkout code From 4ff1dc00e0a0bd97136e4b00186ee43d9270c77b Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 21:46:46 -0400 Subject: [PATCH 04/15] Set year --- .goreleaser.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 9b72776da..7b9d0807a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -81,8 +81,8 @@ chocolateys: title: Windsor CLI authors: Windsor CLI Team project_url: https://windsorcli.github.io - # icon_url: https://windsorcli.github.io/icon.png - copyright: "{{ .Year }} Windsor CLI Team" + icon_url: https://windsorcli.github.io/icon.png + copyright: "2025 Windsor CLI Team" license_url: https://github.com/windsorcli/cli/blob/main/LICENSE require_license_acceptance: false project_source_url: https://github.com/windsorcli/cli From cd05031c9062317b9bad1e29ac314bafb1d25b2a Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 22:00:03 -0400 Subject: [PATCH 05/15] split builds --- .github/workflows/ci.yaml | 91 ++++++++++++++++++++++++++++++--------- .goreleaser.yaml | 24 ++++++++--- 2 files changed, 89 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9fed530c8..1102a8309 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -109,18 +109,75 @@ jobs: # GOTOOLCHAIN: 'local' # GOFLAGS: '-buildvcs=false' - release: - runs-on: ubuntu-latest + # release: + # runs-on: ubuntu-latest + # if: startsWith(github.ref, 'refs/tags/') + # # needs: [build-and-test, sast-scan] + + # steps: + # - name: Checkout code + # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + # - name: Install GPG + # run: sudo apt-get update && sudo apt-get install -y gnupg + + # - name: Install Aqua + # uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 + # with: + # aqua_version: v2.51.1 + + # - name: Install tools + # run: aqua install + + # - name: Cache Go Modules + # uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + # with: + # path: | + # ~/.cache/go-build + # ~/go/pkg/mod + # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # restore-keys: | + # ${{ runner.os }}-go- + + # - name: Install Dependencies + # run: go install ./... + + # - name: Import GPG key + # id: import_gpg + # uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0 + # with: + # gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + # passphrase: ${{ secrets.GPG_PASSPHRASE }} + + # - name: Check if prerelease + # id: prerelease + # run: | + # if [[ "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+- ]]; then + # echo "prerelease=true" >> $GITHUB_OUTPUT + # else + # echo "prerelease=false" >> $GITHUB_OUTPUT + # fi + + # - name: Run GoReleaser + # uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 + # with: + # version: "~> v2" + # args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} --id=unix --skip=chocolatey + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # GPG_FINGERPRINT: ${{ env.GPG_FINGERPRINT }} + # HOMEBREW_CLI_WRITE_PAT: ${{ secrets.HOMEBREW_CLI_WRITE_PAT }} + # GITHUB_SHA: ${{ github.sha }} + + release-windows: + runs-on: windows-latest if: startsWith(github.ref, 'refs/tags/') - # needs: [build-and-test, sast-scan] + # needs: release steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Install GPG - run: sudo apt-get update && sudo apt-get install -y gnupg - - name: Install Aqua uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 with: @@ -142,30 +199,22 @@ jobs: - name: Install Dependencies run: go install ./... - - name: Import GPG key - id: import_gpg - uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.GPG_PASSPHRASE }} - - name: Check if prerelease id: prerelease run: | - if [[ "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+- ]]; then - echo "prerelease=true" >> $GITHUB_OUTPUT - else - echo "prerelease=false" >> $GITHUB_OUTPUT - fi + if ($env:GITHUB_REF -match '^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+-') { + echo "prerelease=true" >> $env:GITHUB_OUTPUT + } else { + echo "prerelease=false" >> $env:GITHUB_OUTPUT + } + shell: pwsh - name: Run GoReleaser uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 with: version: "~> v2" - args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} + args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} --id=windows --id-only=chocolatey env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GPG_FINGERPRINT: ${{ env.GPG_FINGERPRINT }} - HOMEBREW_CLI_WRITE_PAT: ${{ secrets.HOMEBREW_CLI_WRITE_PAT }} CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} GITHUB_SHA: ${{ github.sha }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 7b9d0807a..131e7ac7a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,22 +10,36 @@ before: - go generate ./... builds: - - id: windsor + - id: windows env: - CGO_ENABLED=0 main: ./cmd/windsor goos: - # - darwin - # - linux - windows goarch: - # - arm64 - amd64 + binary: windsor.exe ldflags: - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.version={{ .Version }}'" - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/pkg/secrets.version={{ .Version }}'" - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.commitSHA={{ .Env.GITHUB_SHA }}'" +# - id: unix +# env: +# - CGO_ENABLED=0 +# main: ./cmd/windsor +# goos: +# - darwin +# - linux +# goarch: +# - amd64 +# - arm64 +# binary: windsor +# ldflags: +# - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.version={{ .Version }}'" +# - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/pkg/secrets.version={{ .Version }}'" +# - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.commitSHA={{ .Env.GITHUB_SHA }}'" + # Archive configuration archives: - id: windsor @@ -75,7 +89,7 @@ signs: chocolateys: - name: windsor ids: - - windsor + - windows package_source_url: https://github.com/windsorcli/cli owners: Windsor CLI title: Windsor CLI From e8332bc44d91bdff2aeec5e50f64b78d50f8e2c3 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 22:08:37 -0400 Subject: [PATCH 06/15] Install chocolatey --- .github/workflows/ci.yaml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1102a8309..ff0122eea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -178,23 +178,18 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Install Aqua - uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 - with: - aqua_version: v2.51.1 - - - name: Install tools - run: aqua install + - name: Install Chocolatey + shell: powershell + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + choco --version - - name: Cache Go Modules - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + - name: Setup Go + uses: actions/setup-go@19bb51245e9c80abacb2e91cc42b33fa478b8639 # v4.2.1 with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + go-version: 1.24.2 - name: Install Dependencies run: go install ./... From 75dd36a7784a37ac52c5d97c64744b0aff60ee11 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 22:12:03 -0400 Subject: [PATCH 07/15] Don't install go either --- .github/workflows/ci.yaml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ff0122eea..7cf28d97b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -178,22 +178,6 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Install Chocolatey - shell: powershell - run: | - Set-ExecutionPolicy Bypass -Scope Process -Force - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - choco --version - - - name: Setup Go - uses: actions/setup-go@19bb51245e9c80abacb2e91cc42b33fa478b8639 # v4.2.1 - with: - go-version: 1.24.2 - - - name: Install Dependencies - run: go install ./... - - name: Check if prerelease id: prerelease run: | From b0b13f0cec51f5add7eedf9e968c5128d5fb4dac Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 22:18:00 -0400 Subject: [PATCH 08/15] use skip appropriately --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7cf28d97b..5d9fade43 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -192,7 +192,7 @@ jobs: uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 with: version: "~> v2" - args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} --id=windows --id-only=chocolatey + args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} --skip=brew env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} From 0c76b7a615fc0497767bc00376ab634fd968cacc Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 22:19:31 -0400 Subject: [PATCH 09/15] skip homebrew --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5d9fade43..7e1a93868 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -192,7 +192,7 @@ jobs: uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 with: version: "~> v2" - args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} --skip=brew + args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} --skip=homebrew env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} From c7760e7b7171701e2f32d2a4c996723aa3355018 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 22:39:33 -0400 Subject: [PATCH 10/15] Run all on Windows --- .github/workflows/ci.yaml | 88 ++++++++------------------------------- .goreleaser.yaml | 24 +++-------- 2 files changed, 23 insertions(+), 89 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7e1a93868..336688593 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -109,91 +109,39 @@ jobs: # GOTOOLCHAIN: 'local' # GOFLAGS: '-buildvcs=false' - # release: - # runs-on: ubuntu-latest - # if: startsWith(github.ref, 'refs/tags/') - # # needs: [build-and-test, sast-scan] - - # steps: - # - name: Checkout code - # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - # - name: Install GPG - # run: sudo apt-get update && sudo apt-get install -y gnupg - - # - name: Install Aqua - # uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 - # with: - # aqua_version: v2.51.1 - - # - name: Install tools - # run: aqua install - - # - name: Cache Go Modules - # uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - # with: - # path: | - # ~/.cache/go-build - # ~/go/pkg/mod - # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - # restore-keys: | - # ${{ runner.os }}-go- - - # - name: Install Dependencies - # run: go install ./... - - # - name: Import GPG key - # id: import_gpg - # uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0 - # with: - # gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - # passphrase: ${{ secrets.GPG_PASSPHRASE }} - - # - name: Check if prerelease - # id: prerelease - # run: | - # if [[ "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+- ]]; then - # echo "prerelease=true" >> $GITHUB_OUTPUT - # else - # echo "prerelease=false" >> $GITHUB_OUTPUT - # fi - - # - name: Run GoReleaser - # uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 - # with: - # version: "~> v2" - # args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} --id=unix --skip=chocolatey - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # GPG_FINGERPRINT: ${{ env.GPG_FINGERPRINT }} - # HOMEBREW_CLI_WRITE_PAT: ${{ secrets.HOMEBREW_CLI_WRITE_PAT }} - # GITHUB_SHA: ${{ github.sha }} - - release-windows: + release: runs-on: windows-latest if: startsWith(github.ref, 'refs/tags/') - # needs: release steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + - name: Check if prerelease id: prerelease run: | - if ($env:GITHUB_REF -match '^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+-') { - echo "prerelease=true" >> $env:GITHUB_OUTPUT - } else { - echo "prerelease=false" >> $env:GITHUB_OUTPUT - } - shell: pwsh + if [[ "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+- ]]; then + echo "prerelease=true" >> $GITHUB_OUTPUT + else + echo "prerelease=false" >> $GITHUB_OUTPUT + fi + shell: bash - name: Run GoReleaser uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 with: version: "~> v2" - args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} --skip=homebrew + args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} + GPG_FINGERPRINT: ${{ env.GPG_FINGERPRINT }} GITHUB_SHA: ${{ github.sha }} + HOMEBREW_CLI_WRITE_PAT: ${{ secrets.HOMEBREW_CLI_WRITE_PAT }} + CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 131e7ac7a..7b9d0807a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,36 +10,22 @@ before: - go generate ./... builds: - - id: windows + - id: windsor env: - CGO_ENABLED=0 main: ./cmd/windsor goos: + # - darwin + # - linux - windows goarch: + # - arm64 - amd64 - binary: windsor.exe ldflags: - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.version={{ .Version }}'" - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/pkg/secrets.version={{ .Version }}'" - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.commitSHA={{ .Env.GITHUB_SHA }}'" -# - id: unix -# env: -# - CGO_ENABLED=0 -# main: ./cmd/windsor -# goos: -# - darwin -# - linux -# goarch: -# - amd64 -# - arm64 -# binary: windsor -# ldflags: -# - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.version={{ .Version }}'" -# - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/pkg/secrets.version={{ .Version }}'" -# - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.commitSHA={{ .Env.GITHUB_SHA }}'" - # Archive configuration archives: - id: windsor @@ -89,7 +75,7 @@ signs: chocolateys: - name: windsor ids: - - windows + - windsor package_source_url: https://github.com/windsorcli/cli owners: Windsor CLI title: Windsor CLI From 31595abe84356f23fb0df79b05cb9cd8e2fba0ed Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Thu, 8 May 2025 23:20:44 -0400 Subject: [PATCH 11/15] add url_templaet --- .goreleaser.yaml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 7b9d0807a..13a686b4e 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -61,16 +61,29 @@ signs: # brews: # - name: windsor -# directory: Formula # repository: # owner: windsorcli # name: homebrew-cli # branch: main # token: "{{ .Env.HOMEBREW_CLI_WRITE_PAT }}" -# homepage: "https://windsorcli.github.io" +# commit_author: +# name: goreleaserbot +# email: bot@goreleaser.com +# homepage: "https://windsorcli.github.io" # description: "The Windsor Command Line Interface" -# ids: -# - windsor +# license: "MIT" +# skip_upload: auto +# download_strategy: GithubPrivateRepositoryReleaseDownloadStrategy +# custom_require: "lib/custom_download_strategy" +# install: | +# bin.install "windsor" +# # Install shell completions +# output = Utils.safe_popen_read("#{bin}/windsor", "completion", "bash") +# (bash_completion/"windsor").write output +# output = Utils.safe_popen_read("#{bin}/windsor", "completion", "zsh") +# (zsh_completion/"_windsor").write output +# output = Utils.safe_popen_read("#{bin}/windsor", "completion", "fish") +# (fish_completion/"windsor.fish").write output chocolateys: - name: windsor @@ -101,6 +114,6 @@ chocolateys: Your PowerShell profile is located at: $PROFILE release_notes: "https://github.com/windsorcli/cli/releases/tag/v{{ .Version }}" - skip_publish: false api_key: "{{ .Env.CHOCOLATEY_API_KEY }}" source_repo: "https://push.chocolatey.org/" + url_template: "https://github.com/windsorcli/cli/releases/download/v{{ .Version }}/windsor_{{ .Version }}_windows_amd64.tar.gz" From 502b2113a5baca1c0282da44015bd5c6897b46eb Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Fri, 9 May 2025 08:26:33 -0400 Subject: [PATCH 12/15] Use zip for windows --- .goreleaser.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 13a686b4e..4cafd8730 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -29,7 +29,11 @@ builds: # Archive configuration archives: - id: windsor - formats: ["tar.gz"] + formats: + - tar.gz + format_overrides: + - goos: windows + format: zip changelog: sort: asc @@ -116,4 +120,4 @@ chocolateys: release_notes: "https://github.com/windsorcli/cli/releases/tag/v{{ .Version }}" api_key: "{{ .Env.CHOCOLATEY_API_KEY }}" source_repo: "https://push.chocolatey.org/" - url_template: "https://github.com/windsorcli/cli/releases/download/v{{ .Version }}/windsor_{{ .Version }}_windows_amd64.tar.gz" + url_template: "https://github.com/windsorcli/cli/releases/download/v{{ .Version }}/windsor_{{ .Version }}_windows_amd64.zip" From 55ff752838316999098834651861af865ac5f281 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Fri, 9 May 2025 09:36:48 -0400 Subject: [PATCH 13/15] enable homebrew --- .github/workflows/ci.yaml | 183 +++++++++++++++++++------------------- .goreleaser.yaml | 56 ++++++------ 2 files changed, 120 insertions(+), 119 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 336688593..fa93241ee 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,104 +13,105 @@ permissions: issues: read pull-requests: read jobs: - # build-and-test: - # strategy: - # matrix: - # os: [ubuntu-latest, windows-latest, macos-latest] - # arch: [amd64, arm64] - # exclude: - # - os: windows-latest - # arch: arm64 - # runs-on: ${{ matrix.os }} - - # steps: - # - name: Checkout code - # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - # - name: Install Aqua - # uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 - # with: - # aqua_version: v2.51.1 - - # - name: Install tools - # run: aqua install - - # - name: Cache Go Modules - # uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - # with: - # path: | - # ~/.cache/go-build - # ~/go/pkg/mod - # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - # restore-keys: | - # ${{ runner.os }}-go- + build-and-test: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + arch: [amd64, arm64] + exclude: + - os: windows-latest + arch: arm64 + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install Aqua + uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 + with: + aqua_version: v2.51.1 + + - name: Install tools + run: aqua install + + - name: Cache Go Modules + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - # - name: Install Dependencies - # run: go install ./... + - name: Install Dependencies + run: go install ./... - # - name: Run tests - # run: task test - - # - name: Test Build Windsor CLI on macOS/Linux - # if: ${{ matrix.os != 'windows-latest' }} - # run: | - # VERSION=$(echo "${GITHUB_REF}" | sed 's/refs\/heads\///' | sed 's/refs\/tags\///') - # echo "Testing build for version: $VERSION" - # COMMIT_SHA=${{ github.sha }} - # if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then - # GOOS=linux GOARCH=${{ matrix.arch }} go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$COMMIT_SHA'" -o /dev/null cmd/windsor/main.go - # elif [ "${{ matrix.os }}" == "macos-latest" ]; then - # GOOS=darwin GOARCH=${{ matrix.arch }} go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$COMMIT_SHA'" -o /dev/null cmd/windsor/main.go - # fi - - # - name: Test Build Windsor CLI on Windows - # if: ${{ matrix.os == 'windows-latest' }} - # run: | - # $env:VERSION = $env:GITHUB_REF -replace 'refs/heads/', '' -replace 'refs/tags/', '' - # echo "Testing build for version: $env:VERSION" - # $env:COMMIT_SHA = "${{ github.sha }}" - # $env:GOOS = "windows" - # $env:GOARCH = "${{ matrix.arch }}" - # go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$env:VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$env:COMMIT_SHA'" -o NUL cmd\windsor\main.go - # shell: pwsh - - # sast-scan: - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - # - name: Install Aqua - # uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 - # with: - # aqua_version: v2.51.1 - - # - name: Install tools - # run: aqua install - - # - name: Cache Go Modules - # uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - # with: - # path: | - # ~/.cache/go-build - # ~/go/pkg/mod - # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - # restore-keys: | - # ${{ runner.os }}-go- + - name: Run tests + run: task test + + - name: Test Build Windsor CLI on macOS/Linux + if: ${{ matrix.os != 'windows-latest' }} + run: | + VERSION=$(echo "${GITHUB_REF}" | sed 's/refs\/heads\///' | sed 's/refs\/tags\///') + echo "Testing build for version: $VERSION" + COMMIT_SHA=${{ github.sha }} + if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then + GOOS=linux GOARCH=${{ matrix.arch }} go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$COMMIT_SHA'" -o /dev/null cmd/windsor/main.go + elif [ "${{ matrix.os }}" == "macos-latest" ]; then + GOOS=darwin GOARCH=${{ matrix.arch }} go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$COMMIT_SHA'" -o /dev/null cmd/windsor/main.go + fi + + - name: Test Build Windsor CLI on Windows + if: ${{ matrix.os == 'windows-latest' }} + run: | + $env:VERSION = $env:GITHUB_REF -replace 'refs/heads/', '' -replace 'refs/tags/', '' + echo "Testing build for version: $env:VERSION" + $env:COMMIT_SHA = "${{ github.sha }}" + $env:GOOS = "windows" + $env:GOARCH = "${{ matrix.arch }}" + go build -ldflags "-X 'github.com/${{ github.repository }}/cmd.version=$env:VERSION' -X 'github.com/${{ github.repository }}/cmd.commitSHA=$env:COMMIT_SHA'" -o NUL cmd\windsor\main.go + shell: pwsh + + sast-scan: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install Aqua + uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.1.2 + with: + aqua_version: v2.51.1 + + - name: Install tools + run: aqua install + + - name: Cache Go Modules + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - # - name: Install Dependencies - # run: go install ./... + - name: Install Dependencies + run: go install ./... - # - name: Run Gosec Security Scanner - # uses: securego/gosec@955a68d0d19f4afb7503068f95059f7d0c529017 # v2.22.3 - # with: - # args: ./... - # env: - # GOTOOLCHAIN: 'local' - # GOFLAGS: '-buildvcs=false' + - name: Run Gosec Security Scanner + uses: securego/gosec@955a68d0d19f4afb7503068f95059f7d0c529017 # v2.22.3 + with: + args: ./... + env: + GOTOOLCHAIN: 'local' + GOFLAGS: '-buildvcs=false' release: runs-on: windows-latest + needs: [build-and-test, sast-scan] if: startsWith(github.ref, 'refs/tags/') steps: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 4cafd8730..901056dcc 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -15,11 +15,11 @@ builds: - CGO_ENABLED=0 main: ./cmd/windsor goos: - # - darwin - # - linux + - darwin + - linux - windows goarch: - # - arm64 + - arm64 - amd64 ldflags: - "-X 'github.com/{{ .Env.GITHUB_REPOSITORY }}/cmd.version={{ .Version }}'" @@ -63,31 +63,31 @@ binary_signs: signs: - artifacts: checksum -# brews: -# - name: windsor -# repository: -# owner: windsorcli -# name: homebrew-cli -# branch: main -# token: "{{ .Env.HOMEBREW_CLI_WRITE_PAT }}" -# commit_author: -# name: goreleaserbot -# email: bot@goreleaser.com -# homepage: "https://windsorcli.github.io" -# description: "The Windsor Command Line Interface" -# license: "MIT" -# skip_upload: auto -# download_strategy: GithubPrivateRepositoryReleaseDownloadStrategy -# custom_require: "lib/custom_download_strategy" -# install: | -# bin.install "windsor" -# # Install shell completions -# output = Utils.safe_popen_read("#{bin}/windsor", "completion", "bash") -# (bash_completion/"windsor").write output -# output = Utils.safe_popen_read("#{bin}/windsor", "completion", "zsh") -# (zsh_completion/"_windsor").write output -# output = Utils.safe_popen_read("#{bin}/windsor", "completion", "fish") -# (fish_completion/"windsor.fish").write output +brews: + - name: windsor + repository: + owner: windsorcli + name: homebrew-cli + branch: main + token: "{{ .Env.HOMEBREW_CLI_WRITE_PAT }}" + commit_author: + name: goreleaserbot + email: bot@goreleaser.com + homepage: "https://windsorcli.github.io" + description: "The Windsor Command Line Interface" + license: "MPL-2.0" + skip_upload: auto + download_strategy: GithubPrivateRepositoryReleaseDownloadStrategy + custom_require: "lib/custom_download_strategy" + install: | + bin.install "windsor" + # Install shell completions + output = Utils.safe_popen_read("#{bin}/windsor", "completion", "bash") + (bash_completion/"windsor").write output + output = Utils.safe_popen_read("#{bin}/windsor", "completion", "zsh") + (zsh_completion/"_windsor").write output + output = Utils.safe_popen_read("#{bin}/windsor", "completion", "fish") + (fish_completion/"windsor.fish").write output chocolateys: - name: windsor From d761e1a086135f54b20f74b9a477586a38330b51 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Fri, 9 May 2025 22:21:33 -0400 Subject: [PATCH 14/15] Skip specific package mangers --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fa93241ee..24d183627 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -139,7 +139,7 @@ jobs: uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 with: version: "~> v2" - args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=publish' || '' }} + args: release --clean ${{ steps.prerelease.outputs.prerelease == 'true' && '--skip=chocolatey,homebrew' || '' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GPG_FINGERPRINT: ${{ env.GPG_FINGERPRINT }} From 1700c0fba3dbd312ca719fea54040d1e2f042ceb Mon Sep 17 00:00:00 2001 From: Ryan VanGundy Date: Sat, 10 May 2025 17:32:12 -0400 Subject: [PATCH 15/15] Remove generatecontextid from controller --- pkg/controller/controller.go | 5 ---- pkg/controller/controller_test.go | 50 +++++++++++++++---------------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index bc3a2e83e..554c4a4a3 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -749,11 +749,6 @@ func (c *BaseController) createConfigComponent(req Requirements) error { return nil } - // Generate context ID - if err := configHandler.GenerateContextID(); err != nil { - return fmt.Errorf("failed to generate context ID: %w", err) - } - return nil } diff --git a/pkg/controller/controller_test.go b/pkg/controller/controller_test.go index 46399e388..544e2b2f3 100644 --- a/pkg/controller/controller_test.go +++ b/pkg/controller/controller_test.go @@ -2238,16 +2238,19 @@ func TestBaseController_createConfigComponent(t *testing.T) { // Clear any existing config handler mocks.Injector.Register("configHandler", nil) - // Set environment variable to force config load - oldEnv := os.Getenv("WINDSORCONFIG") - os.Setenv("WINDSORCONFIG", "test.yaml") - defer func() { - if oldEnv != "" { - os.Setenv("WINDSORCONFIG", oldEnv) - } else { - os.Unsetenv("WINDSORCONFIG") - } - }() + // Create temporary project directory + projectRoot := t.TempDir() + mockShell := shell.NewMockShell() + mockShell.GetProjectRootFunc = func() (string, error) { + return projectRoot, nil + } + mocks.Injector.Register("shell", mockShell) + + // Create config file + configPath := filepath.Join(projectRoot, "windsor.yaml") + if err := os.WriteFile(configPath, []byte("test"), 0644); err != nil { + t.Fatalf("Failed to create test config file: %v", err) + } // When creating the config component err := controller.createConfigComponent(Requirements{}) @@ -2286,15 +2289,10 @@ func TestBaseController_createConfigComponent(t *testing.T) { } }) - t.Run("GeneratesContextID", func(t *testing.T) { + t.Run("CreatesConfigComponent", func(t *testing.T) { // Given a controller with a config handler controller, mocks := setup(t) mockConfigHandler := config.NewMockConfigHandler() - var generateCalled bool - mockConfigHandler.GenerateContextIDFunc = func() error { - generateCalled = true - return nil - } controller.constructors.NewConfigHandler = func(di.Injector) config.ConfigHandler { return mockConfigHandler } @@ -2305,21 +2303,23 @@ func TestBaseController_createConfigComponent(t *testing.T) { // When creating the config component err := controller.createConfigComponent(Requirements{}) - // Then context ID should be generated + // Then no error should be returned if err != nil { t.Errorf("Expected no error, got: %v", err) } - if !generateCalled { - t.Error("Expected GenerateContextID to be called") + + // And the config handler should be registered + if mocks.Injector.Resolve("configHandler") != mockConfigHandler { + t.Error("Expected config handler to be registered") } }) - t.Run("HandlesGenerateContextIDError", func(t *testing.T) { + t.Run("HandlesConfigHandlerError", func(t *testing.T) { // Given a controller with a failing config handler controller, mocks := setup(t) mockConfigHandler := config.NewMockConfigHandler() - mockConfigHandler.GenerateContextIDFunc = func() error { - return fmt.Errorf("failed to generate context ID") + mockConfigHandler.InitializeFunc = func() error { + return fmt.Errorf("config handler error") } controller.constructors.NewConfigHandler = func(di.Injector) config.ConfigHandler { return mockConfigHandler @@ -2331,12 +2331,12 @@ func TestBaseController_createConfigComponent(t *testing.T) { // When creating the config component err := controller.createConfigComponent(Requirements{}) - // Then the error should be propagated + // Then an error should be returned if err == nil { t.Error("Expected error, got nil") } - if !strings.Contains(err.Error(), "failed to generate context ID") { - t.Errorf("Expected error about context ID generation, got: %v", err) + if !strings.Contains(err.Error(), "config handler error") { + t.Errorf("Expected error about config handler, got: %v", err) } }) }