# -*- 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/suzuki-shunsuke/pinact 3.9.0 v
go.offline_build    no
categories          security
maintainers         {macports.halostatue.ca:austin @halostatue} \
                    openmaintainer
license             MIT

description         A CLI to edit GitHub Workflow and Composite action files and pin \
                    versions of Actions and Reusable Workflows. pinact can also update \
                    their versions and verify version annotations.


long_description    {*}${description}

checksums           ${distname}${extract.suffix} \
                    rmd160  d4018959860aa5abc6b291ae0f86dd0e6f0c2598 \
                    sha256  4e4f5f1f98162f90fe688d9a82f00da56e545e15bec8d3a0fa334b1c72b59aef \
                    size    78605

livecheck.regex     {v(\d+\.\d+\.\d+)$}

build.args-append   -ldflags \"-X main.version=${version} -X main.commit=MacPorts \" \
                    ./cmd/pinact

post-build {
  system "${worksrcpath}/${name} completion bash > ${worksrcpath}/${name}.bash"
  system "${worksrcpath}/${name} completion fish > ${worksrcpath}/${name}.fish"
  system "${worksrcpath}/${name} completion zsh > ${worksrcpath}/${name}.zsh"
}

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

    set bash_completions_dir share/bash-completion/completions
    set fish_completions_dir share/fish/vendor_completions.d
    set zsh_completions_dir share/zsh/site-functions

    xinstall -d ${destroot}${prefix}/${bash_completions_dir}
    xinstall ${worksrcpath}/${name}.bash \
        ${destroot}${prefix}/${bash_completions_dir}/${name}

    xinstall -d ${destroot}${prefix}/${fish_completions_dir}
    xinstall ${worksrcpath}/${name}.fish \
        ${destroot}${prefix}/${fish_completions_dir}

    xinstall -d ${destroot}${prefix}/${zsh_completions_dir}
    xinstall ${worksrcpath}/${name}.zsh \
        ${destroot}${prefix}/${zsh_completions_dir}/_${name}
}
