requires:
  - name: "toolchain-go"
    category: "development"
    version: ">=0"
env:
  - PATH=$PATH:/usr/local/go/bin
  - CGO_ENABLED=0
  - REPO={{( index .Values.labels "github.repo" )}}

prelude:
  - PACKAGE_VERSION=${PACKAGE_VERSION%\+*} && git clone --branch v"${PACKAGE_VERSION}" https://github.com/{{( index .Values.labels "github.owner" )}}/$REPO

steps:
  - |
    cd $REPO && GIT_COMMIT=$(git rev-parse HEAD) && \
    go build -o bin/{{.Values.bin_name}} -ldflags "-s -w -X 'github.com/rancher/elemental-cli/internal/version.version=v${PACKAGE_VERSION}' -X 'github.com/rancher/elemental-cli/internal/version.gitCommit=${GIT_COMMIT}'" && \
    mv bin/{{.Values.bin_name}} /usr/bin/{{.Values.bin_name}}

includes:
  - /usr/bin/{{.Values.bin_name}}