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

versions:
  github: SpectralOps/teller

dependencies:
  openssl.org: ^1.1

build:
  dependencies:
    go.dev: ^1.21
    rust-lang.org: ^1.78
    protobuf.dev: '*' # as of 2.0.6
  script:
    - run: go build $GO_ARGS -ldflags="$GO_LDFLAGS" .
      if: <2
    - run: cargo install --locked --path teller-cli --root {{prefix}}
      if: '>=2'
  env:
    COMMIT_SHA: '$(git describe --always --abbrev=8 --dirty)'
    VERSION_DATE: '$(date -u +%FT%TZ)'
    GO_ARGS:
      - -trimpath
      - -o={{prefix}}/bin/teller
    linux:
      GO_ARGS:
        - -buildmode=pie
    GO_LDFLAGS:
      - -s
      - -w
      - -X main.version={{version}}
      - -X main.commit=${COMMIT_SHA}
      - -X main.date=${VERSION_DATE}

provides:
  - bin/teller

test:
  - run: |
      echo 'foo: var' > test.env
      teller -c $FIXTURE show  2>&1 | grep 'foo'
      teller version | grep {{version}}
    if: <2
    fixture:
      content: |
        project: test
        providers:
          # this will fuse vars with the below .env file
          # use if you'd like to grab secrets from outside of the project tree
          dotenv:
            env_sync:
              path: test.env
      extname: .yml
  - run: |
      echo 'foo=var' > test.env
      teller -c $FIXTURE show  2>&1 | grep 'foo'
      test "$(teller --version)" = "teller {{version}}"
    if: '>=2'
    fixture:
      content: |
        providers:
          dot_1:
            kind: dotenv
            maps:
              - id: foo
                path: test.env
      extname: .yml
