# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           golang 1.0

go.setup            github.com/goreleaser/goreleaser 2.15.3 v
go.offline_build    no
revision            0

homepage            https://goreleaser.com

description         Deliver Go binaries as fast and easily as possible

long_description    {*}${description}. GoReleaser builds Go binaries for \
                    several platforms, and can create GitHub releases as well.

categories          devel
installs_libs       no
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  599efc6abf3d48c834b5b4c6c716006baec2d640 \
                    sha256  a5b0f9c06fb9032be04d6f7db5e64d016ac4bd7993f9c2aa5f085402c62a4e9e \
                    size    2703756

build.args-append   \
    -ldflags \" -X main.version=${version} -X main.builtBy=macports \"

post-build {
    file mkdir ${worksrcpath}/completions ${worksrcpath}/manpage

    foreach _shell {bash fish zsh} {
        system -W ${worksrcpath} "./${name} completion ${_shell} > ./completions/${name}.${_shell}"
    }

    system -W ${worksrcpath} "./${name} man > ./manpage/${name}.1"
}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/

    set bash_comp_dir ${destroot}${prefix}/share/bash-completion/completions
    xinstall -d ${bash_comp_dir}
    copy ${worksrcpath}/completions/${name}.bash ${bash_comp_dir}/${name}

    set fish_comp_dir ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -d ${fish_comp_dir}
    copy ${worksrcpath}/completions/${name}.fish ${fish_comp_dir}/

    set zsh_comp_dir ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${zsh_comp_dir}
    copy ${worksrcpath}/completions/${name}.zsh ${zsh_comp_dir}/_${name}

    xinstall -m 0444 \
        ${worksrcpath}/manpage/${name}.1 ${destroot}${prefix}/share/man/man1/
}
