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

versions:
  github: pressly/goose

provides:
  - bin/goose

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

test:
  dependencies:
    sqlite.org: 3
  env:
    GOOSE_DRIVER: sqlite3
    GOOSE_DBSTRING: ./test.db
    GOOSE_MIGRATION_DIR: ./migrations
  script:
    - 'test "$(goose -version)" = "goose version: v{{version}}"'
    - mkdir -p $GOOSE_MIGRATION_DIR
    - goose create add_some_column sql
    - goose status
    - goose up
    - goose status
    - goose down
    - goose status
