33 lines
2.0 KiB
PowerShell
33 lines
2.0 KiB
PowerShell
param([string]$Version = '3.2.3')
|
|
$ErrorActionPreference = 'Stop'
|
|
$repo = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
|
Push-Location $repo
|
|
try {
|
|
if (Test-Path 'build/local-env/enter.ps1') { . ./build/local-env/enter.ps1 }
|
|
Push-Location frontend
|
|
try {
|
|
$installArgs = @('install', '--frozen-lockfile')
|
|
if (Test-Path '../build/local-env/pnpm-store') { $installArgs += @('--store-dir', '../build/local-env/pnpm-store') }
|
|
pnpm @installArgs
|
|
if ($LASTEXITCODE -ne 0) { throw 'Frontend dependency installation failed' }
|
|
pnpm run build
|
|
if ($LASTEXITCODE -ne 0) { throw 'Frontend build failed' }
|
|
} finally { Pop-Location }
|
|
$commit = git rev-parse --short HEAD
|
|
$release = Join-Path $repo 'build/release/linux-amd64'
|
|
New-Item -ItemType Directory -Force $release | Out-Null
|
|
$oldGoos, $oldGoarch, $oldGoamd64, $oldCgo = $env:GOOS, $env:GOARCH, $env:GOAMD64, $env:CGO_ENABLED
|
|
try {
|
|
$env:GOOS = 'linux'; $env:GOARCH = 'amd64'; $env:GOAMD64 = 'v1'; $env:CGO_ENABLED = '0'
|
|
go build -trimpath -ldflags "-s -w -X github.com/filebrowser/filebrowser/v2/version.Version=$Version -X github.com/filebrowser/filebrowser/v2/version.CommitSHA=$commit" -o (Join-Path $release 'filebrowser') .
|
|
if ($LASTEXITCODE -ne 0) { throw 'Linux build failed' }
|
|
} finally { $env:GOOS = $oldGoos; $env:GOARCH = $oldGoarch; $env:GOAMD64 = $oldGoamd64; $env:CGO_ENABLED = $oldCgo }
|
|
Copy-Item -LiteralPath LICENSE -Destination (Join-Path $release 'LICENSE')
|
|
Copy-Item -LiteralPath docs/deployment.md -Destination (Join-Path $release 'README.md')
|
|
Copy-Item -LiteralPath deploy/filebrowser.service -Destination (Join-Path $release 'filebrowser.service')
|
|
$archive = Join-Path $repo 'build/filebrowser-linux-amd64.tar.gz'
|
|
go run ./scripts/package-release.go $release $archive
|
|
if ($LASTEXITCODE -ne 0) { throw 'Archive creation failed' }
|
|
Write-Output "Built $archive ($Version, $commit, linux/amd64 v1, CGO disabled)"
|
|
} finally { Pop-Location }
|