diff --git a/.circleci/config.yml b/.circleci/config.yml index 7e43b1f89..3a428583d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,8 @@ --- -version: 2 +version: 2.1 + +orbs: + win: circleci/windows@2.2.0 jobs: build: @@ -29,6 +32,25 @@ jobs: - deploy: name: deploy command: .circleci/deploy.sh + - persist_to_workspace: + root: . + paths: + - _dist/windows-amd64/* + + generate-windows-installer: + executor: win/default + steps: + - checkout + - attach_workspace: + at: 'C:\tmp\workspace' + - run: + name: Copy from Workspace + command: 'Copy-Item "C:\tmp\workspace\*" "package" -Recurse' + - run: + name: install innosetup and build + command: Set-Location package && .\build.ps1 + - store_artifacts: + path: output/ workflows: version: 2 @@ -38,3 +60,9 @@ workflows: filters: tags: only: /.*/ + - generate-windows-installer: + requires: + - build + filters: + tags: + only: /.*/ diff --git a/package/build.ps1 b/package/build.ps1 new file mode 100644 index 000000000..27bf9af57 --- /dev/null +++ b/package/build.ps1 @@ -0,0 +1,31 @@ +if (![string]::IsNullOrEmpty(${Env:CIRCLE_PR_NUMBER})) { + Write-Host "Skipping deploy step; as this is a PR" + exit; +} + +if (![string]::IsNullOrEmpty(${Env:CIRCLE_TAG})) { + $ci_version = ${Env:CIRCLE_TAG} +} +elseif ( ${Env:CIRCLE_BRANCH} -eq "main" ) { + $ci_version = "canary" +} +else { + Write-Host "Skipping deploy step; this is neither a releasable branch or a tag" + exit; +} + +Invoke-WebRequest -Uri https://jrsoftware.org/download.php/is.exe -OutFile inno.exe + +$process = Start-Process -FilePath .\inno.exe -ArgumentList "/VERYSILENT", "/NORESTART" -NoNewWindow -PassThru -Wait + +$process.WaitForExit() + +Write-Host "Inno installer exit code : " $process.ExitCode + +Write-Host "App Version : " $ci_version + +$process = Start-Process -FilePath ${Env:ProgramFiles(x86)}"\Inno Setup 6\ISCC.exe" -ArgumentList "helm_installer.iss", "/DVersion=$ci_version" -NoNewWindow -PassThru -Wait + +$process.WaitForExit() + +Write-Host "Inno Compiler exit code : " $process.ExitCode \ No newline at end of file diff --git a/package/helm_installer.iss b/package/helm_installer.iss new file mode 100644 index 000000000..55bd97521 --- /dev/null +++ b/package/helm_installer.iss @@ -0,0 +1,34 @@ +[Setup] +AppName=Helm +AppVersion={#Version} +DefaultDirName={autopf}\Helm +DefaultGroupName=Helm +PrivilegesRequired=lowest +AppPublisher=Helm +AppPublisherURL=https://helm.sh +AppSupportURL=https://github.com/helm/helm +LicenseFile="windows-amd64\LICENSE" +OutputBaseFilename=helm_installer_win64 + +[Files] +Source: "windows-amd64\*" ; DestDir: "{app}\bin"; + +[Registry] +Root: "HKCU"; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\bin"; Check: NeedsAddPathHKCU(ExpandConstant('{app}\bin')) + +[Code] +function NeedsAddPathHKCU(Param: string): boolean; +var +OrigPath: string; +begin +if not RegQueryStringValue(HKEY_CURRENT_USER, +'Environment', +'Path', OrigPath) +then begin +Result := True; +exit; +end; +// look for the path with leading and trailing semicolon +// Pos() returns 0 if not found +Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0; +end; \ No newline at end of file