distributable:
  url: https://github.com/mvdan/sh/archive/refs/tags/v{{version}}.tar.gz
  strip-components: 1

versions:
  github: mvdan/sh/releases/tags
  strip: /^v/

build:
  dependencies:
    go.dev: ^1.19
  env:
    CGO_ENABLED: 0
    LDFLAGS:
      - -s
      - -w
      - -extldflags=-static
      - -X main.version={{version}}
  script: |
    go build -v -ldflags="$LDFLAGS" -o "{{ prefix }}"/bin/gosh ./cmd/gosh
    go build -v -ldflags="$LDFLAGS" -o "{{ prefix }}"/bin/shfmt ./cmd/shfmt

provides:
  - bin/gosh
  - bin/shfmt

test:
  script: |
    test "$(gosh -c 'echo success')" = success
    test "$(shfmt --version)" = {{version}}
    echo "f() { true; }" | shfmt --diff -
