Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,20 +479,26 @@ jobs:
SPOTUIFY_VERSION: ${{ needs.validate.outputs.version }}
run: |
$env:SPOTUIFY_INSTALL_DIR = Join-Path $env:RUNNER_TEMP 'spotuify'
$installerSource = $null
$installCommand = @'
Invoke-RestMethod -Uri 'https://crapshack.net/spotuify/install.ps1' -UseBasicParsing -TimeoutSec 60 | Invoke-Expression
'@
$installed = $false
for ($attempt = 1; $attempt -le 5; $attempt++) {
try {
$installerSource = Invoke-RestMethod `
-Uri 'https://crapshack.net/spotuify/install.ps1' `
-UseBasicParsing `
-TimeoutSec 60
& powershell.exe `
-NoLogo `
-NoProfile `
-NonInteractive `
-ExecutionPolicy Bypass `
-Command $installCommand
if ($LASTEXITCODE -eq 0) {
$installed = $true
break
} catch {
if ($attempt -eq 5) { throw }
Start-Sleep -Seconds (2 * $attempt)
}
if ($attempt -lt 5) { Start-Sleep -Seconds (2 * $attempt) }
}
if (-not $installed) {
throw 'Spotuify public installer failed after 5 attempts.'
}
$installerSource | Invoke-Expression
$binDirectory = Join-Path $env:SPOTUIFY_INSTALL_DIR 'bin'
$mainVersion = & (Join-Path $binDirectory 'spotuify.exe') --version
$currentRelease = (Get-Content -LiteralPath (Join-Path $env:SPOTUIFY_INSTALL_DIR 'current') -Raw).Trim()
Expand Down
6 changes: 5 additions & 1 deletion packaging/standalone/install.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#Requires -Version 5.1

param(
[switch]$LoadOnly
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Expand Down Expand Up @@ -831,7 +835,7 @@ function Install-Spotuify {
}
}

if ($MyInvocation.InvocationName -ne '.') {
if (-not $LoadOnly) {
try {
Install-Spotuify
} catch {
Expand Down
17 changes: 16 additions & 1 deletion test/installer-windows.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $ProgressPreference = 'SilentlyContinue'

$repositoryRoot = Split-Path -Parent $PSScriptRoot
$installerPath = Join-Path $repositoryRoot 'packaging/standalone/install.ps1'
. $installerPath
. $installerPath -LoadOnly

$testRoot = Join-Path ([IO.Path]::GetTempPath()) ("spotuify-installer-tests-$([guid]::NewGuid().ToString('N'))")
$script:FixtureManifest = $null
Expand Down Expand Up @@ -572,6 +572,21 @@ try {
}
}

Invoke-Test 'runs the entrypoint when evaluated from a dot-sourced scope' {
$installerSource = Get-Content -LiteralPath $installerPath -Raw
$previousVersion = $env:SPOTUIFY_VERSION
try {
$env:SPOTUIFY_VERSION = 'invalid'
Assert-Throws {
. {
$installerSource | Invoke-Expression
}
} 'SPOTUIFY_VERSION must be latest or a stable version'
} finally {
[Environment]::SetEnvironmentVariable('SPOTUIFY_VERSION', $previousVersion, 'Process')
}
}

Write-Host 'All Spotuify Windows installer tests passed.'
} catch {
$testFailure = $_
Expand Down
19 changes: 19 additions & 0 deletions test/release-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ describe("release workflow", () => {

test("publishes standalone installers and verifies the crapshack endpoints", async () => {
const source = await Bun.file(WORKFLOW_PATH).text();
const workflow = Bun.YAML.parse(source) as {
jobs?: {
"public-installer-smoke"?: {
steps?: Array<{ if?: string; run?: string }>;
};
};
};

expect(source).toContain(
"install -m 0755 packaging/standalone/install.sh dist/install.sh",
Expand All @@ -41,5 +48,17 @@ describe("release workflow", () => {
);
expect(source).toContain("https://crapshack.net/spotuify/install.sh");
expect(source).toContain("https://crapshack.net/spotuify/install.ps1");

const windowsSmoke = workflow.jobs?.["public-installer-smoke"]?.steps?.find(
(step) => step.if === "matrix.kind == 'windows'",
);
expect(windowsSmoke?.run).toContain("& powershell.exe");
expect(windowsSmoke?.run).toContain("-Command $installCommand");
expect(windowsSmoke?.run).toContain(
"Invoke-RestMethod -Uri 'https://crapshack.net/spotuify/install.ps1' -UseBasicParsing -TimeoutSec 60 | Invoke-Expression",
);
expect(windowsSmoke?.run).not.toContain(
"$installerSource | Invoke-Expression",
);
});
});