деплой
This commit is contained in:
@@ -14,6 +14,9 @@ Fails unless the X.Y.Z part of pubspec.yaml matches this value.
|
||||
.PARAMETER ReleaseNotes
|
||||
Text written to the AppCast item description.
|
||||
|
||||
.PARAMETER EnvFile
|
||||
Local dotenv file used to fill environment variables that are not already set.
|
||||
|
||||
.PARAMETER DryRun
|
||||
Builds, signs, and verifies local artifacts without changing production.
|
||||
|
||||
@@ -42,6 +45,7 @@ param(
|
||||
[string]$S3Endpoint,
|
||||
[string]$S3Bucket,
|
||||
[string]$S3Key = 'moonwell_launcher_setup.exe',
|
||||
[string]$EnvFile = '.env',
|
||||
[string]$PrivateKeyPath = '.moonwell_signing\dsa_priv.pem',
|
||||
[string]$PublicKeyPath = 'windows\runner\resources\dsa_pub.pem',
|
||||
[string]$FlutterCommand = 'flutter',
|
||||
@@ -101,6 +105,64 @@ function Get-FileSha256 {
|
||||
return (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash.ToLowerInvariant()
|
||||
}
|
||||
|
||||
function Import-DotEnv {
|
||||
param([Parameter(Mandatory = $true)][string]$Path)
|
||||
|
||||
if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) {
|
||||
return
|
||||
}
|
||||
|
||||
$allowedNames = @(
|
||||
'AWS_ACCESS_KEY_ID',
|
||||
'AWS_SECRET_ACCESS_KEY',
|
||||
'AWS_DEFAULT_REGION',
|
||||
'AWS_BUCKET',
|
||||
'AWS_ENDPOINT',
|
||||
'AWS_USE_PATH_STYLE_ENDPOINT',
|
||||
'LAUNCHER_AUTH_KEY'
|
||||
)
|
||||
|
||||
foreach ($line in Get-Content -LiteralPath $Path) {
|
||||
$trimmed = $line.Trim()
|
||||
if (
|
||||
[string]::IsNullOrWhiteSpace($trimmed) -or
|
||||
$trimmed.StartsWith('#')
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
$separator = $trimmed.IndexOf('=')
|
||||
if ($separator -le 0) {
|
||||
throw "Invalid dotenv line in ${Path}: $line"
|
||||
}
|
||||
|
||||
$name = $trimmed.Substring(0, $separator).Trim()
|
||||
if ($allowedNames -notcontains $name) {
|
||||
continue
|
||||
}
|
||||
|
||||
$value = $trimmed.Substring($separator + 1).Trim()
|
||||
if (
|
||||
$value.Length -ge 2 -and
|
||||
(
|
||||
($value.StartsWith('"') -and $value.EndsWith('"')) -or
|
||||
($value.StartsWith("'") -and $value.EndsWith("'"))
|
||||
)
|
||||
) {
|
||||
$value = $value.Substring(1, $value.Length - 2)
|
||||
}
|
||||
|
||||
$existing = [Environment]::GetEnvironmentVariable($name)
|
||||
if ([string]::IsNullOrWhiteSpace($existing)) {
|
||||
[Environment]::SetEnvironmentVariable(
|
||||
$name,
|
||||
$value,
|
||||
[EnvironmentVariableTarget]::Process
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-AppcastVersion {
|
||||
param([Parameter(Mandatory = $true)][string]$Path)
|
||||
|
||||
@@ -282,6 +344,14 @@ $previousLocation = Get-Location
|
||||
try {
|
||||
Set-Location $repositoryRoot
|
||||
|
||||
$resolvedEnvFile = if ([IO.Path]::IsPathRooted($EnvFile)) {
|
||||
$EnvFile
|
||||
}
|
||||
else {
|
||||
Join-Path $repositoryRoot $EnvFile
|
||||
}
|
||||
Import-DotEnv -Path $resolvedEnvFile
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($S3Endpoint)) {
|
||||
$S3Endpoint = $env:AWS_ENDPOINT
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user