Files
PiliPlus/lib/scripts/build.ps1
My-Responsitories a65edab7d1 opt: env (#1510)
* opt: env

* fix

* fix: regex

* fix: android

* fix

* fix

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* fastforge define

* fix

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

---------

Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
2025-10-10 15:52:26 +08:00

47 lines
1.2 KiB
PowerShell

param(
[string]$Arg = ''
)
try {
$versionName = $null
$versionCode = [int](git rev-list --count HEAD).Trim()
$commitHash = (git rev-parse HEAD).Trim()
$updatedContent = foreach ($line in (Get-Content -Path 'pubspec.yaml' -Encoding UTF8)) {
if ($line -match '^\s*version:\s*([\d\.]+)') {
$versionName = $matches[1]
if ($Arg -eq 'android') {
$versionName += '-' + $commitHash.Substring(0, 9)
}
"version: $versionName+$versionCode"
}
else {
$line
}
}
if ($null -eq $versionName) {
throw 'version not found'
}
$updatedContent | Set-Content -Path 'pubspec.yaml' -Encoding UTF8
$buildTime = [int]([DateTimeOffset]::Now.ToUnixTimeSeconds())
$data = @{
'pili.name' = $versionName
'pili.code' = $versionCode
'pili.hash' = $commitHash
'pili.time' = $buildTime
}
$data | ConvertTo-Json -Compress | Out-File 'pili_release.json' -Encoding UTF8
Add-Content -Path $env:GITHUB_ENV -Value "version=$versionName+$versionCode"
}
catch {
Write-Error "Prebuild Error: $($_.Exception.Message)"
exit 1
}