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

versions:
  github: zyedidia/micro/tags
  strip: /^v/

provides:
  - bin/micro

build:
  dependencies:
    go.dev: ^1.16
  script: |
    mkdir -p "{{ prefix }}"/{bin,share/man/man1}
    go build -ldflags "$LDFLAGS -X 'github.com/zyedidia/micro/v2/internal/util.CompileDate=$(go run tools/build-date.go)'" ./cmd/micro
    install -m755 micro "{{ prefix }}"/bin
    cp assets/packaging/micro.1 "{{ prefix }}"/share/man/man1
  env:
    LDFLAGS:
      - -s
      - -w
      - -X github.com/zyedidia/micro/v2/internal/util.Version={{ version }}
    linux:
      LDFLAGS:
        - -buildmode=pie
    GOOS: $(go env GOHOSTOS)
    ADDITIONAL_GO_LINKER_FLAGS: $(go run tools/info-plist.go $GOOS {{ version }})
    GOARCH: $(go env GOHOSTARCH)

test: micro -version | grep {{ version }}
