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

versions:
  github: maaslalani/invoice

provides:
  - bin/invoice

build:
  dependencies:
    go.dev: ^1.20
  script:
    - go mod download
    - go build -v -trimpath -ldflags="$GO_LDFLAGS" -o '{{prefix}}/bin/invoice' .
  env:
    GO_LDFLAGS:
      - -s
      - -w
    linux:
      # or segmentation fault
      # fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
      GO_LDFLAGS:
        - -buildmode=pie

test:
  - invoice generate --from "Dream, Inc." --to "Imagine, Inc."
    --item "Rubber Duck" --quantity 2 --rate 25
    --tax 0.13 --discount 0.15
    --note "For debugging purposes"
  - test -s invoice.pdf
