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

name                    helm
categories              sysutils
platforms               darwin
license                 Apache-2
maintainers             {ogsite.net:sirn @sirn} @pedrohdz {lbschenkel @lbschenkel} \
                        openmaintainer

subport helm_select {}

# *NOTE* Remember to update `latestVersion` on a version upgrade.
set latestVersion       helm-3.1
subport helm-3.1 {
    set baseVersion     3.1
    set patchNumber     1
    revision            0
    checksums           rmd160  7324750fb10656b9b4a686620e461a41e6f4e1d8 \
                        sha256  2ce00e6c44ba18fbcbec21c493476e919128710d480789bb35bd228ae695cd66 \
                        size    12889373
}

subport helm-3.0 {
    set baseVersion     3.0
    set patchNumber     3
    revision            0
    checksums           rmd160  85b53300b25820dc6588af92e6041d6c01261caf \
                        sha256  5e27bc6ecf838ed28a6a480ee14e6bec137b467a56f427dbc3cf995f9bdcf85c \
                        size    12716418
}

subport helm-2.16 {
    set baseVersion     2.16
    set patchNumber     3
    revision            0
    checksums           rmd160  b522f42d8d796ef5b4dae26565e2b4b07b5ad3eb \
                        sha256  df2a38d1c27c2d3e5ead63c872f5409e8bea091451db6bc6b81898b19981d4cb \
                        size    26556949
}

subport helm-2.15 {
    set baseVersion     2.15
    set patchNumber     2
    revision            0
    checksums           rmd160  2f0790dbe10ccebd724f43d5e0f3533b0c389ee1 \
                        sha256  0815dc44f9f1c5bcee1c130268bfca2ddf6425b60cf042d3b3c907c35ef11e31 \
                        size    25747450
}

subport helm-2.14 {
    set baseVersion     2.14
    set patchNumber     2
    revision            0
    checksums           rmd160  002bdedc70c51fd03ba76fbbe31c3e509ee0c11e \
                        sha256  9469da75bb357bc325c985dead224480bbacc7aa8aecff74089dff97e64655d0 \
                        size    27862805
}

subport helm-2.13 {
    set baseVersion     2.13
    set patchNumber     1
    revision            0
    checksums           rmd160  33f9f56bc0cc1ce4a47f863f8ba278bfa02431ba \
                        sha256  c9564c4133349b98a8c1dda42fdb6545f6e4bfdf0980cdfc38cf76d2f8e5e701 \
                        size    24089303
}

subport helm-2.12 {
    set baseVersion     2.12
    set patchNumber     3
    revision            0
    checksums           rmd160  8676268e53e3d21c1ca3216db8684ea3b68c4ba0 \
                        sha256  564a087915e07333d2335face555eaac63accd669fb63672ae1b66a73144ac50 \
                        size    23867687
}

if {${subport} == ${name}} {
    PortGroup           obsolete 1.0

    replaced_by         ${latestVersion}
    version             2.14.1
    revision            1

} elseif {${subport} == "helm_select"} {
    version             0.0
    revision            0
    supported_archs     noarch

    description         Common files for selecting default Helm version
    long_description    This port installs files that allow 'port select' \
                        to create links to the preferred default version \
                        of Helm/Tiller.
    homepage            https://www.macports.org/

    distfiles
    use_configure       no
    build {}

    destroot {
        select::install helm ${filespath}/base
        select::install helm ${filespath}/none
    }

    livecheck.type     none

} else {
    PortGroup           github 1.0

    supported_archs     x86_64
    depends_run         port:helm_select

    set patchVersion    ${baseVersion}.${patchNumber}
    set baseName        helm${baseVersion}
    github.setup        helm helm ${patchVersion} v

    description         Kubernetes package manager
    long_description    Helps you manage Kubernetes applications — Helm Charts \
                        help you define, install, and upgrade even the most \
                        complex Kubernetes application.

    master_sites        https://get.helm.sh/
    distname            helm-v${version}-darwin-amd64
    worksrcdir          darwin-amd64

    use_configure       no

    select.group        helm
    select.file         ${filespath}/${baseName}

    build {}

    destroot {
        xinstall ${worksrcpath}/helm ${destroot}${prefix}/bin/helm${baseVersion}
        # Starting with helm 3 there is no tiller anymore
        set majorVersion [string index $baseVersion 0]
        if {${majorVersion} == "2" } {
            xinstall ${worksrcpath}/tiller ${destroot}${prefix}/bin/tiller${baseVersion}
        }
    }

    # Skip -rc and other pre-release tags
    set regexVersionPart [string map {. {\.}} $baseVersion]
    github.livecheck.regex  (${regexVersionPart}\\.\\d+)

    notes "
    To make this the default Helm/Tiller (i.e., the version run by the 'helm' or\
    'tiller' commands, Tiller is only present in v2), run:
        sudo port select --set helm ${baseName}
    "
}

