Skip to content
Merged
12 changes: 5 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
shell: [ default ]
experimental: [ false ]
helm-version: [ v3.18.6, v3.17.4 ]
helm-version: [ v3.18.6, v3.19.0-rc.1 ]
include:
- os: windows-latest
shell: wsl
Expand All @@ -61,16 +61,16 @@ jobs:
- os: windows-latest
shell: wsl
experimental: false
helm-version: v3.17.4
helm-version: v3.19.0-rc.1
- os: windows-latest
shell: cygwin
experimental: false
helm-version: v3.17.4
helm-version: v3.19.0-rc.1
- os: ubuntu-latest
container: alpine
shell: sh
experimental: false
helm-version: v3.17.4
helm-version: v3.19.0-rc.1

steps:
- name: Disable autocrlf
Expand All @@ -93,8 +93,6 @@ jobs:
- name: Setup Cygwin
if: "contains(matrix.shell, 'cygwin')"
uses: egor-tensin/setup-cygwin@v4
with:
platform: x64

- name: helm plugin install
run: helm plugin install .
Expand All @@ -111,7 +109,7 @@ jobs:
# That's why we cover only 2 Helm minor versions in this matrix.
# See https://github.com/helmfile/helmfile/pull/286#issuecomment-1250161182 for more context.
- helm-version: v3.18.6
- helm-version: v3.17.4
- helm-version: v3.19.0-rc.1
steps:
- uses: engineerd/setup-kind@v0.6.2
with:
Expand Down
77 changes: 77 additions & 0 deletions install-binary.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
param (
[switch] $Update = $false
)

function Get-Architecture {
$architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture

$arch = switch ($architecture) {
"X64" { "amd64" }
"Arm64" { "arm64" }
Default { "" }
}

if ($arch -eq "") {
throw "Unsupported architecture: ${architecture}"
}

return $arch
}

function Get-Version {
param ([Parameter(Mandatory=$true)][bool] $Update)

if ($Update) {
return "latest"
}

return git describe --tags --exact-match 2>$null || "latest"
}

function New-TemporaryDirectory {
$tmp = [System.IO.Path]::GetTempPath()
$name = (New-Guid).ToString("N")
$dir = New-Item -ItemType Directory -Path (Join-Path $tmp $name)
return $dir.FullName
}

function Get-Url {
param ([Parameter(Mandatory=$true)][string] $Version, [Parameter(Mandatory=$true)][string] $Architecture)

if ($Version -eq "latest") {
return "https://github.com/databus23/helm-diff/releases/latest/download/helm-diff-windows-${Architecture}.tgz"
}
return "https://github.com/databus23/helm-diff/releases/download/${Version}/helm-diff-windows-${Architecture}.tgz"
}

function Download-Plugin {
param ([Parameter(Mandatory=$true)][string] $Url, [Parameter(Mandatory=$true)][string] $Output)

Invoke-WebRequest -OutFile $Output $Url
}

function Install-Plugin {
param ([Parameter(Mandatory=$true)][string] $ArchiveDirectory, [Parameter(Mandatory=$true)][string] $ArchiveName, [Parameter(Mandatory=$true)][string] $Destination)

Push-Location $ArchiveDirectory
tar -xzf $ArchiveName -C .
Pop-Location

New-Item -ItemType Directory -Path $Destination -Force
Copy-Item -Path (Join-Path $ArchiveDirectory "diff" "bin" "diff.exe") -Destination $Destination -Force
}

$ErrorActionPreference = "Stop"

$archiveName = "helm-diff.tgz"
$arch = Get-Architecture
$version = Get-Version -Update $Update
$tmpDir = New-TemporaryDirectory

trap { Remove-Item -path $tmpDir -Recurse -Force }

$url = Get-Url -Version $version -Architecture $arch
$output = Join-Path $tmpDir $archiveName

Download-Plugin -Url $url -Output $output
Install-Plugin -ArchiveDirectory $tmpDir -ArchiveName $archiveName -Destination (Join-Path $env:HELM_PLUGIN_DIR "bin")
29 changes: 24 additions & 5 deletions plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
name: "diff"
name: diff
# Version is the version of Helm plus the number of official builds for this
# plugin
version: "3.12.5"
usage: "Preview helm upgrade changes as a diff"
description: "Preview helm upgrade changes as a diff"
useTunnel: true
command: "$HELM_PLUGIN_DIR/bin/diff"
hooks:
install: "$HELM_PLUGIN_DIR/install-binary.sh"
update: "$HELM_PLUGIN_DIR/install-binary.sh -u"
platformCommand:
- command: ${HELM_PLUGIN_DIR}/bin/diff
- os: windows
command: ${HELM_PLUGIN_DIR}\bin\diff.exe

platformHooks:
install:
- command: ${HELM_PLUGIN_DIR}/install-binary.sh
- os: windows
command: pwsh
args:
- -c
- ${HELM_PLUGIN_DIR}/install-binary.ps1
update:
- command: ${HELM_PLUGIN_DIR}/install-binary.sh
args:
- -u
- os: windows
command: pwsh
args:
- -c
- ${HELM_PLUGIN_DIR}/install-binary.ps1
- -Update
Loading