distributable:
  url: git+https://github.com/istio/istio.git
  ref: ${{version.tag}}

versions:
  github: istio/istio

build:
  dependencies:
    go.dev: ^1.21
    linux/aarch64:
      gnu.org/gcc: '*' # wants `gcc` and `ld.gold`
  script:
    - go build $ARGS -ldflags="$LDFLAGS" ./istioctl/cmd/istioctl
    - ${{prefix}}/bin/istioctl collateral --man
    - mkdir -p {{prefix}}/share/man/man1
    - cp ./*.1 {{prefix}}/share/man/man1/
  env:
    ARGS:
      - -trimpath
      - -o={{prefix}}/bin/istioctl
    COMMIT_SHA: $(git describe --always --abbrev=8 --dirty)
    LDFLAGS:
      - -s
      - -w
      - -X istio.io/istio/pkg/version.buildVersion={{version}}
      - -X istio.io/istio/pkg/version.buildGitRevision=${COMMIT_SHA}
      - -X istio.io/istio/pkg/version.buildTag={{version.tag}}
      - -X istio.io/istio/pkg/version.buildHub=docker.io/istio
    linux:
      LDFLAGS:
        - -buildmode=pie

provides:
  - bin/istioctl

test:
  - istioctl version --remote=false | grep {{version}}
  - istioctl completion bash | grep '__istioctl_format_comp_descriptions()'
