distributable:
  url: https://github.com/Versent/saml2aws/archive/refs/tags/{{version.tag}}.tar.gz
  strip-components: 1

versions:
  github: Versent/saml2aws

display-name: saml2aws

build:
  dependencies:
    go.dev: ^1.21
  script:
    go build $ARGS -ldflags="$LDFLAGS" ./cmd/saml2aws
  env:
    ARGS:
      - -trimpath
      - -o={{prefix}}/bin/saml2aws
    LDFLAGS:
      - -s
      - -w
      - -X main.Version={{version}}
    linux:
      LDFLAGS:
        - -buildmode=pie

provides:
  - bin/saml2aws

test:
  - saml2aws --help
  - saml2aws --version 2>&1 | grep {{version}}
  - run: cp $FIXTURE ./_saml2aws
    fixture: |
      #compdef saml2aws

      _saml2aws_bash_autocomplete() {
          local cur prev opts base
          COMPREPLY=()
          cur="${COMP_WORDS[COMP_CWORD]}"
          opts=$( ${COMP_WORDS[0]} --completion-bash ${COMP_WORDS[@]:1:$COMP_CWORD} )
          COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
          return 0
      }
      complete -F _saml2aws_bash_autocomplete saml2aws
  - saml2aws script 2>out.log || true
  - cat out.log | grep 'Failed to validate account'
