diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index 814209f2..288f8ee6 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -548,6 +548,111 @@ jobs: security delete-keychain $RUNNER_TEMP/app-signing.keychain-db || true security delete-keychain $RUNNER_TEMP/dev-signing.keychain-db || true + submit-to-chocolatey: + runs-on: windows-latest + if: github.event.inputs.artifact_destination == 'submit' + needs: [build-windows] + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 1 + + - name: Get version from package.json + id: package-version + run: | + $VERSION = (Get-Content package.json | ConvertFrom-Json).version + echo "version=$VERSION" >> $env:GITHUB_OUTPUT + echo "Building Chocolatey package for version: $VERSION" + + - name: Download Windows x64 MSI artifact + uses: actions/download-artifact@v4 + with: + name: termix_windows_x64_msi + path: artifact + + - name: Get MSI file info + id: msi-info + run: | + $VERSION = "${{ steps.package-version.outputs.version }}" + $MSI_FILE = Get-ChildItem -Path artifact -Filter "*.msi" | Select-Object -First 1 + $MSI_NAME = $MSI_FILE.Name + $CHECKSUM = (Get-FileHash -Path $MSI_FILE.FullName -Algorithm SHA256).Hash + + echo "msi_name=$MSI_NAME" >> $env:GITHUB_OUTPUT + echo "checksum=$CHECKSUM" >> $env:GITHUB_OUTPUT + echo "MSI File: $MSI_NAME" + echo "SHA256: $CHECKSUM" + + - name: Prepare Chocolatey package + run: | + $VERSION = "${{ steps.package-version.outputs.version }}" + $CHECKSUM = "${{ steps.msi-info.outputs.checksum }}" + $MSI_NAME = "${{ steps.msi-info.outputs.msi_name }}" + + # Construct the download URL with the actual release tag format + $DOWNLOAD_URL = "https://github.com/Termix-SSH/Termix/releases/download/release-$VERSION-tag/$MSI_NAME" + + # Copy chocolatey files to build directory + New-Item -ItemType Directory -Force -Path "choco-build" + Copy-Item -Path "chocolatey\*" -Destination "choco-build" -Recurse -Force + + # Update chocolateyinstall.ps1 with actual values + $installScript = Get-Content "choco-build\tools\chocolateyinstall.ps1" -Raw + $installScript = $installScript -replace 'DOWNLOAD_URL_PLACEHOLDER', $DOWNLOAD_URL + $installScript = $installScript -replace 'CHECKSUM_PLACEHOLDER', $CHECKSUM + Set-Content -Path "choco-build\tools\chocolateyinstall.ps1" -Value $installScript + + # Update nuspec with version + $nuspec = Get-Content "choco-build\termix.nuspec" -Raw + $nuspec = $nuspec -replace 'VERSION_PLACEHOLDER', $VERSION + Set-Content -Path "choco-build\termix.nuspec" -Value $nuspec + + echo "Chocolatey package prepared for version $VERSION" + echo "Download URL: $DOWNLOAD_URL" + + - name: Install Chocolatey + run: | + Set-ExecutionPolicy Bypass -Scope Process -Force + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + + - name: Pack Chocolatey package + run: | + cd choco-build + choco pack termix.nuspec + + - name: Check for Chocolatey API Key + id: check_choco_key + run: | + if ("${{ secrets.CHOCOLATEY_API_KEY }}" -ne "") { + echo "has_key=true" >> $env:GITHUB_OUTPUT + echo "✅ Chocolatey API key found. Will push to Chocolatey." + } else { + echo "has_key=false" >> $env:GITHUB_OUTPUT + echo "⚠️ Chocolatey API key not configured. Package will be created but not pushed." + echo "Add CHOCOLATEY_API_KEY secret to enable automatic submission." + } + + - name: Push to Chocolatey + if: steps.check_choco_key.outputs.has_key == 'true' + run: | + $VERSION = "${{ steps.package-version.outputs.version }}" + cd choco-build + choco apikey --key "${{ secrets.CHOCOLATEY_API_KEY }}" --source https://push.chocolatey.org/ + choco push "termix.$VERSION.nupkg" --source https://push.chocolatey.org/ + echo "✅ Package pushed to Chocolatey successfully!" + + - name: Upload Chocolatey package as artifact + uses: actions/upload-artifact@v4 + with: + name: chocolatey-package + path: choco-build/*.nupkg + retention-days: 30 + upload-to-release: runs-on: blacksmith-4vcpu-ubuntu-2404 if: github.event.inputs.artifact_destination == 'release' diff --git a/chocolatey/termix.nuspec b/chocolatey/termix.nuspec new file mode 100644 index 00000000..45f5aec1 --- /dev/null +++ b/chocolatey/termix.nuspec @@ -0,0 +1,33 @@ + + + + termix + VERSION_PLACEHOLDER + https://github.com/Termix-SSH/Termix + bugattiguy527 + Termix + bugattiguy527 + https://github.com/Termix-SSH/Termix + https://raw.githubusercontent.com/Termix-SSH/Termix/main/public/icon.png + https://raw.githubusercontent.com/Termix-SSH/Termix/refs/heads/main/LICENSE + false + https://github.com/Termix-SSH/Termix + https://docs.termix.site/install + https://github.com/Termix-SSH/Support/issues + docker ssh self-hosted file-management ssh-tunnel termix server-management terminal + Termix is a web-based server management platform with SSH terminal, tunneling, and file editing capabilities. + Termix is an open-source, forever-free, self-hosted all-in-one server management platform. It provides a web-based solution for managing your servers and infrastructure through a single, intuitive interface. + +Termix offers: +- SSH terminal access +- SSH tunneling capabilities +- Remote file management +- Server monitoring and management + +This package installs the desktop application version of Termix. + https://github.com/Termix-SSH/Termix/releases + + + + + diff --git a/chocolatey/tools/chocolateyinstall.ps1 b/chocolatey/tools/chocolateyinstall.ps1 new file mode 100644 index 00000000..c7c6f0f2 --- /dev/null +++ b/chocolatey/tools/chocolateyinstall.ps1 @@ -0,0 +1,20 @@ +$ErrorActionPreference = 'Stop' + +$packageName = 'termix' +$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" +$url64 = 'DOWNLOAD_URL_PLACEHOLDER' +$checksum64 = 'CHECKSUM_PLACEHOLDER' +$checksumType64 = 'sha256' + +$packageArgs = @{ + packageName = $packageName + fileType = 'msi' + url64bit = $url64 + softwareName = 'Termix*' + checksum64 = $checksum64 + checksumType64 = $checksumType64 + silentArgs = "/qn /norestart /l*v `"$($env:TEMP)\$($packageName).$($env:chocolateyPackageVersion).MsiInstall.log`"" + validExitCodes = @(0, 3010, 1641) +} + +Install-ChocolateyPackage @packageArgs diff --git a/chocolatey/tools/chocolateyuninstall.ps1 b/chocolatey/tools/chocolateyuninstall.ps1 new file mode 100644 index 00000000..0c29bac0 --- /dev/null +++ b/chocolatey/tools/chocolateyuninstall.ps1 @@ -0,0 +1,34 @@ +$ErrorActionPreference = 'Stop' + +$packageName = 'termix' +$softwareName = 'Termix*' +$installerType = 'msi' + +$silentArgs = '/qn /norestart' +$validExitCodes = @(0, 3010, 1605, 1614, 1641) + +[array]$key = Get-UninstallRegistryKey -SoftwareName $softwareName + +if ($key.Count -eq 1) { + $key | % { + $file = "$($_.UninstallString)" + + if ($installerType -eq 'msi') { + $silentArgs = "$($_.PSChildName) $silentArgs" + $file = '' + } + + Uninstall-ChocolateyPackage -PackageName $packageName ` + -FileType $installerType ` + -SilentArgs "$silentArgs" ` + -ValidExitCodes $validExitCodes ` + -File "$file" + } +} elseif ($key.Count -eq 0) { + Write-Warning "$packageName has already been uninstalled by other means." +} elseif ($key.Count -gt 1) { + Write-Warning "$($key.Count) matches found!" + Write-Warning "To prevent accidental data loss, no programs will be uninstalled." + Write-Warning "Please alert package maintainer the following keys were matched:" + $key | % {Write-Warning "- $($_.DisplayName)"} +}