# -*- 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           github 1.0

github.setup        dagger dagger 0.12.2 v
github.tarball_from releases
revision            0

categories          devel
maintainers         {judaew @judaew} openmaintainer
license             Apache-2

description         A portable devkit for CI/CD pipelines
long_description    \
    Using Dagger, software teams can develop powerful CICD pipelines with \
    minimal effort, then run them anywhere. Benefits include: \
    \n- Unify dev and CI environments. Write your pipeline once, Dagger will \
    run it the same everywhere. \
    \n- Reduce CI lock-in. No more re-writing everything from scratch every \
    6 months.
homepage            https://dagger.io

switch ${build_arch} {
    x86_64 {
        distfiles           dagger_v${version}_darwin_amd64${extract.suffix}
        checksums           rmd160  21728a030dcfcf6e13908a729a681759cb9d2c2e \
                            sha256  7255ea25af4de506328f2c48ddc90ad5cf37bf66c5b652a8b1d5417570a5a6ad \
                            size    10088619
    }
    arm64 {
        distfiles           dagger_v${version}_darwin_arm64${extract.suffix}
        checksums           rmd160  6575e6d5d80c4b703a167de9ff80fa7f3587b339 \
                            sha256  baf301780f58d3d4982c2fe1592cc8b88493bdd730431d57810408ed0945fa67 \
                            size    9531091
    }
    default {
        known_fail  yes
        pre-fetch {
            ui_error "${subport} @ ${version} only supported for architectures ${supported_archs}"
            return -code error "Unsupported architecture: ${build_arch}"
        }
    }
}

extract.mkdir       yes
use_configure       no
build {}

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

    # Shell completion
    xinstall -d ${destroot}${prefix}/etc/bash_completion.d
    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    system "${destroot}${prefix}/bin/${name} completion bash > ${destroot}${prefix}/etc/bash_completion.d/${name}"
    system "${destroot}${prefix}/bin/${name} completion zsh > ${destroot}${prefix}/share/zsh/site-functions/_${name}"
    system "${destroot}${prefix}/bin/${name} completion fish > ${destroot}${prefix}/share/fish/vendor_completions.d/${name}.fish"
}
