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
10 changes: 9 additions & 1 deletion docs/binaries-phar-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ curl -fsSL https://raw.githubusercontent.com/yiipress/engine/master/install.sh |
curl -fsSL https://raw.githubusercontent.com/yiipress/engine/master/install.sh | YIIPRESS_VERSION=nightly sh
```

Or, with the PowerShell installer:

```powershell
$env:YIIPRESS_VERSION = "nightly"
irm https://raw.githubusercontent.com/yiipress/engine/master/install.ps1 | iex
```

`YIIPRESS_VERSION=nightly` resolves the newest immutable nightly prerelease through the GitHub releases API. It does not require
`jq` or GitHub CLI. Nightly builds contain unreleased changes and are intended for preview and testing.
`jq` or GitHub CLI. Both installers inspect up to ten release pages and use the first prerelease whose tag matches the immutable
`nightly-<run>-<attempt>-<sha>` format. Nightly builds contain unreleased changes and are intended for preview and testing.

YiiPress can be packaged as reproducible artifacts:

Expand Down
30 changes: 30 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@ if ([Runtime.InteropServices.RuntimeInformation]::OSArchitecture -ne [Runtime.In
}

$Asset = "yiipress-windows-amd64.zip"
if ($Version -eq "nightly") {
$ResolvedVersion = $null
for ($Page = 1; -not $ResolvedVersion -and $Page -le 10; $Page++) {
$Releases = $null
for ($Attempt = 1; $Attempt -le 3; $Attempt++) {
try {
$Releases = @(
Invoke-RestMethod -Uri "https://api.github.com/repos/$Repository/releases?per_page=100&page=$Page"
)
break
} catch {
if ($Attempt -eq 3) {
throw
}
Start-Sleep -Seconds 2
}
}
$ResolvedVersion = $Releases | Where-Object {
$_.prerelease -eq $true -and $_.draft -ne $true `
-and $_.tag_name -match '^nightly-[0-9]+-[0-9]+-[0-9a-f]+$'
} | Select-Object -First 1 -ExpandProperty tag_name
if ($Releases.Count -eq 0) {
break
}
}
if (-not $ResolvedVersion) {
throw "Could not find a YiiPress nightly release for $Repository."
}
$Version = $ResolvedVersion
}
$ReleaseUrl = if ($Version -eq "latest") {
"https://github.com/$Repository/releases/latest/download"
} else {
Expand Down
13 changes: 13 additions & 0 deletions tests/Unit/Packaging/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,19 @@ public function windowsInstallerDownloadsVerifiesAndAtomicallyReplacesTheExecuta
self::assertStringContainsString('[Environment]::SetEnvironmentVariable("Path", $UpdatedPath, "User")', $script);
self::assertStringContainsString('YIIPRESS_INSTALL_DIR', $script);
self::assertStringContainsString('YIIPRESS_VERSION', $script);
self::assertStringContainsString('if ($Version -eq "nightly")', $script);
self::assertStringContainsString(
'https://api.github.com/repos/$Repository/releases?per_page=100&page=$Page',
$script,
);
self::assertStringContainsString("-match '^nightly-[0-9]+-[0-9]+-[0-9a-f]+$'", $script);
self::assertStringContainsString('$_.draft -ne $true', $script);
self::assertStringContainsString('Select-Object -First 1 -ExpandProperty tag_name', $script);
self::assertStringContainsString('$Page -le 10', $script);
self::assertStringContainsString('$Attempt -le 3', $script);
self::assertStringContainsString('Start-Sleep -Seconds 2', $script);
self::assertStringContainsString('if ($Attempt -eq 3)', $script);
self::assertStringContainsString('Could not find a YiiPress nightly release for $Repository.', $script);
}

private function createRelease(
Expand Down