distributable:
  url: https://github.com/kubernetes-sigs/kubebuilder/archive/refs/tags/v{{version}}.tar.gz
  strip-components: 1

versions:
  github: kubernetes-sigs/kubebuilder

build:
  dependencies:
    go.dev: ^1.21
    gnu.org/coreutils: '*'
  script: |
    go build -ldflags="$LDFLAGS" -o $BUILDLOC ./cmd
  env:
    CGO_ENABLED: 0
    LDFLAGS:
      - -X main.kubeBuilderVersion={{version}}
      - -X main.goos=$(go env GOOS)
      - -X main.goarch=$(go env GOARCH)
      - -X main.gitCommit=pkgx
      - -X main.buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
    BUILDLOC: '{{prefix}}/bin/kubebuilder'

provides:
  - bin/kubebuilder

test:
  dependencies:
    gnu.org/grep: '*'
    go.dev: ^1.21
  script: |
    kubebuilder version | grep 'KubeBuilderVersion:"{{version}}"'
    mkdir test
    cd test
    go mod init example.com
    kubebuilder init --plugins go/v4 --project-version 3 --skip-go-version-check
    go clean --modcache
