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
4 changes: 4 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ jobs:
if: matrix.verify_packages
shell: pwsh
run: ./packaging/VerifyPackageArtifact.ps1 -ArtifactDirectory artifacts -Configuration '${{ env.CONFIGURATION }}' -AllowNoPackages
- name: Smoke linux-x64 release archive construction
if: matrix.verify_packages
shell: pwsh
run: ./packaging/BuildReleaseArchive.ps1 -Configuration '${{ env.CONFIGURATION }}' -RuntimeIdentifier 'linux-x64' -Version 'pr'
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<PackageVersion>$(VersionPrefix)</PackageVersion>
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
106 changes: 86 additions & 20 deletions packaging/BuildReleaseArchive.ps1
Original file line number Diff line number Diff line change
@@ -1,24 +1,90 @@
param([Parameter(Mandatory=$true)][string]$RuntimeIdentifier,[Parameter(Mandatory=$true)][string]$Version,[ValidateSet('Debug','Staging','Release')][string]$Configuration='Release',[string]$ArchiveBaseName='Icod.LineEditor')
$ErrorActionPreference='Stop'
param(
[Parameter(Mandatory = $true)]
[string]$RuntimeIdentifier,
[Parameter(Mandatory = $true)]
[string]$Version,
[ValidateSet('Debug', 'Staging', 'Release')]
[string]$Configuration = 'Release',
[string]$ArchiveBaseName = 'Icod.LineEditor'
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$repositoryRoot=[System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))

$repositoryRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
Import-Module (Join-Path $PSScriptRoot 'RepositoryTools.psm1') -Force
$solutionPath=Get-RepositorySolution -RepositoryRoot $repositoryRoot
$projects=@(Get-SolutionProjects -SolutionPath $solutionPath -RepositoryRoot $repositoryRoot)
$executables=@(Get-ExecutableProjects -ProjectPaths $projects -Configuration $Configuration)
$releaseRoot=Join-Path $repositoryRoot 'artifacts/release'
$stageName="$ArchiveBaseName-$Version-$RuntimeIdentifier"
$stageParent=Join-Path $releaseRoot 'stage'
$stage=Join-Path $stageParent $stageName
$archive=Join-Path $releaseRoot "$stageName.zip"
if(Test-Path $stage){Remove-Item $stage -Recurse -Force}; New-Item -ItemType Directory -Path $stage -Force|Out-Null
Invoke-DotNet -Arguments @('restore',$solutionPath,'-r',$RuntimeIdentifier)
foreach($executable in $executables){
$publish=Join-Path $releaseRoot "publish/$RuntimeIdentifier/$($executable.AssemblyName)"
Invoke-DotNet -Arguments @('publish',$executable.ProjectPath,'-c',$Configuration,'-r',$RuntimeIdentifier,'--no-restore','--self-contained','false','-p:PublishSingleFile=true','-p:PublishTrimmed=false','-p:DebugType=None','-p:DebugSymbols=false','-p:ContinuousIntegrationBuild=true','-o',$publish)
$file=if($RuntimeIdentifier.StartsWith('win-')){"$($executable.AssemblyName).exe"}else{$executable.AssemblyName}
Copy-Item (Join-Path $publish $file) (Join-Path $stage $file)
$solutionPath = Get-RepositorySolution -RepositoryRoot $repositoryRoot
$projects = @(Get-SolutionProjects -SolutionPath $solutionPath -RepositoryRoot $repositoryRoot)
$executables = @(Get-ExecutableProjects -ProjectPaths $projects -Configuration $Configuration)
$releaseRoot = Join-Path $repositoryRoot 'artifacts/release'
$stageName = "$ArchiveBaseName-$Version-$RuntimeIdentifier"
$stageParent = Join-Path $releaseRoot 'stage'
$stage = Join-Path $stageParent $stageName
$archive = Join-Path $releaseRoot "$stageName.zip"

if (Test-Path -LiteralPath $stage) {
Remove-Item -LiteralPath $stage -Recurse -Force
}
foreach($support in @('README.md','LICENSE')){if(Test-Path (Join-Path $repositoryRoot $support)){Copy-Item (Join-Path $repositoryRoot $support) (Join-Path $stage $support)}}
if($RuntimeIdentifier.StartsWith('win-')){Compress-Archive -LiteralPath $stage -DestinationPath $archive -CompressionLevel Optimal}else{Get-ChildItem $stage -File|Where-Object{$_.Name -in @('lineeditor','ed','red','sed')}|ForEach-Object{& chmod +x $_.FullName}; Push-Location $stageParent;try{& zip -r -q $archive $stageName;if(0 -ne $LASTEXITCODE){throw 'zip failed'}}finally{Pop-Location}}
New-Item -ItemType Directory -Path $stage -Force | Out-Null

Invoke-DotNet -Arguments @(
'restore',
$solutionPath,
'-r',
$RuntimeIdentifier
)

foreach ($executable in $executables) {
$publish = Join-Path $releaseRoot "publish/$RuntimeIdentifier/$($executable.AssemblyName)"
Invoke-DotNet -Arguments @(
'publish',
$executable.ProjectPath,
'-c',
$Configuration,
'-r',
$RuntimeIdentifier,
'--no-restore',
'--self-contained',
'false',
'-p:SelfContained=false',
'-p:PublishSingleFile=true',
'-p:PublishTrimmed=false',
'-p:DebugType=None',
'-p:DebugSymbols=false',
'-p:ContinuousIntegrationBuild=true',
'-o',
$publish
)
$file = if ($RuntimeIdentifier.StartsWith('win-')) {
"$($executable.AssemblyName).exe"
} else {
$executable.AssemblyName
}
Copy-Item -LiteralPath (Join-Path $publish $file) -Destination (Join-Path $stage $file)
}

foreach ($support in @('README.md', 'LICENSE')) {
$supportPath = Join-Path $repositoryRoot $support
if (Test-Path -LiteralPath $supportPath -PathType Leaf) {
Copy-Item -LiteralPath $supportPath -Destination (Join-Path $stage $support)
}
}

if ($RuntimeIdentifier.StartsWith('win-')) {
Compress-Archive -LiteralPath $stage -DestinationPath $archive -CompressionLevel Optimal
} else {
Get-ChildItem -LiteralPath $stage -File |
Where-Object { $_.Name -in @('lineeditor', 'ed', 'red', 'sed') } |
ForEach-Object { & chmod +x $_.FullName }
Push-Location $stageParent
try {
& zip -r -q $archive $stageName
if (0 -ne $LASTEXITCODE) {
throw 'zip failed'
}
} finally {
Pop-Location
}
}

Write-Host "Created release archive: $archive"
5 changes: 5 additions & 0 deletions packaging/RepositoryTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ function Get-ExecutableProjects {
param([Parameter(Mandatory = $true)][string[]]$ProjectPaths,[string]$Configuration = 'Release')
$result = @()
foreach ($projectPath in $ProjectPaths) {
$isTestProject = Get-MSBuildProperty -ProjectPath $projectPath -Name 'IsTestProject' -Configuration $Configuration
if ('true' -eq $isTestProject.Trim().ToLowerInvariant()) {
continue
}

$outputType = Get-MSBuildProperty -ProjectPath $projectPath -Name 'OutputType' -Configuration $Configuration
if ($outputType -in @('Exe', 'WinExe')) {
$assemblyName = Get-MSBuildProperty -ProjectPath $projectPath -Name 'AssemblyName' -Configuration $Configuration
Expand Down
Loading