diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0e8b2e710c..c671662667 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -36,7 +36,6 @@ jobs: if: needs.release-please.outputs.releases_created == 'true' permissions: contents: write - needs: - release-please runs-on: ubuntu-latest @@ -49,6 +48,8 @@ jobs: uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4 with: go-version: '1.20' + - name: Download Syft + uses: anchore/sbom-action/download-syft@v0.13.4 - name: Run GoReleaser uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4 with: @@ -70,6 +71,7 @@ jobs: id-token: write env: IMAGE_TAG: ghcr.io/k8sgpt-ai/k8sgpt:${{ needs.release-please.outputs.tag_name }} + IMAGE_NAME: k8sgpt steps: - name: Checkout uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3 @@ -98,8 +100,8 @@ jobs: ${{ env.IMAGE_TAG }} builder: ${{ steps.buildx.outputs.name }} push: true - cache-from: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }} - cache-to: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }} + cache-from: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_TAG }} + cache-to: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_TAG }} - name: Generate SBOM uses: anchore/sbom-action@422cb34a0f8b599678c41b21163ea6088edb2624 # v0.14.1 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 42e0e22d7d..cbd1deb36f 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -16,6 +16,27 @@ builds: ldflags: - -s -w -X main.version={{.Version}} +nfpms: + - file_name_template: '{{ .ProjectName }}_{{ .Arch }}' + homepage: https://k8sgpt.ai + description: >- + K8sGPT is a tool for scanning your kubernetes clusters, diagnosing and triaging issues in simple english. It has SRE experience codified into it’s analyzers and helps to pull out the most relevant information to enrich it with AI. + license: "MIT" + formats: + - deb + - rpm + - apk + bindir: /usr/bin + section: utils + contents: + - src: ./LICENSE + dst: /usr/share/doc/nfpm/copyright + file_info: + mode: 0644 + +sboms: + - artifacts: archive + archives: - format: tar.gz # this name template makes the OS and Arch compatible with the results of uname. diff --git a/cmd/generate/generate.go b/cmd/generate/generate.go index 9164387fdb..453875fea5 100644 --- a/cmd/generate/generate.go +++ b/cmd/generate/generate.go @@ -7,7 +7,6 @@ import ( "github.com/spf13/viper" "os/exec" "runtime" - "time" ) var ( @@ -31,10 +30,6 @@ var GenerateCmd = &cobra.Command{ backendType = backend } fmt.Println("") - color.Green("Opening: https://beta.openai.com/account/api-keys to generate a key for %s", backendType) - color.Green("Please copy the generated key and run `k8sgpt auth` to add it to your config file") - fmt.Println("") - time.Sleep(5 * time.Second) openbrowser("https://beta.openai.com/account/api-keys") }, } @@ -46,9 +41,15 @@ func init() { func openbrowser(url string) { var err error + isGui := true switch runtime.GOOS { case "linux": - err = exec.Command("xdg-open", url).Start() + _, err = exec.LookPath("xdg-open") + if err != nil { + isGui = false + } else { + err = exec.Command("xdg-open", url).Start() + } case "windows": err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() case "darwin": @@ -56,7 +57,21 @@ func openbrowser(url string) { default: err = fmt.Errorf("unsupported platform") } + printInstructions(isGui, backend) if err != nil { fmt.Println(err) } } + +func printInstructions(isGui bool, backendType string) { + fmt.Println("") + if isGui { + color.Green("Opening: https://beta.openai.com/account/api-keys to generate a key for %s", backendType) + fmt.Println("") + } else { + color.Green("Please open: https://beta.openai.com/account/api-keys to generate a key for %s", backendType) + fmt.Println("") + } + color.Green("Please copy the generated key and run `k8sgpt auth` to add it to your config file") + fmt.Println("") +}