# -*- 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.7.0 v
go.offline_build    no
github.tarball_from archive
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  c18526c25cde0cfbf8cafcee8705fc21f2739194 \
                    sha256  a33fca4cf3dbd0989105f0581183740b04e703b7deee4f4814a520ee6591c4d5 \
                    size    2758282

set build_script    ${worksrcpath}/_build.sh

build.cmd           ${build_script}
build.pre_args      {}
build.args          {}

post-extract {
    set bs [open "${build_script}" w+]
    puts ${bs} "#!/bin/sh"
    puts ${bs} "set -x"
    puts ${bs} "${go.bin} build -trimpath -ldflags \" -s -w -X main.version=${version} -X main.builtBy=macports \" && \\"
    puts ${bs} "./scripts/completions.sh"
    close ${bs}

    file attributes ${build_script} -permissions 0755
}

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}
}
