Merge pull request #427 from Shazwazza/dependabot/nuget/src/Articulat… #230
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Articulate Build | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: windows-latest | |
env: | |
Solution_File: src\Articulate.sln | |
Web_Proj_Folder: src\Articulate.Web | |
Nuspec: build\Articulate.nuspec | |
Release_Folder: build\Release | |
Build_Folder: build | |
Configuration: Release | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Create copyright value | |
run: | | |
$Copyright = "Copyright " + [char]0x00A9 + " Shannon Deminick " + (Get-Date).year | |
echo ("Copyright=" + $Copyright) >> $Env:GITHUB_ENV | |
shell: pwsh | |
- name: Add MSBuild to PATH | |
uses: microsoft/[email protected] | |
- uses: nuget/setup-nuget@v1 | |
with: | |
nuget-version: 'latest' | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
- name: Determine Version | |
uses: gittools/actions/gitversion/[email protected] | |
- name: Nuget Restore | |
run: nuget restore $env:Solution_File | |
- name: MSBuild Clean | |
run: msbuild $env:Solution_File /p:Configuration=Release /t:Clean | |
- name: MSBuild Build | |
run: msbuild $env:Solution_File /p:Configuration=$env:Configuration | |
- name: Nuget Pack | |
run: nuget pack ${{ env.Nuspec }} -BasePath ${{ env.Web_Proj_Folder }} -OutputDirectory ${{ env.Release_Folder }} -Version "${{ env.GITVERSION_SEMVER }}" -Properties "copyright=${{ env.Copyright }}" | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: nuget | |
path: ${{ env.Release_Folder }}/Articulate.*.nupkg | |
- name: Umbraco package build | |
shell: pwsh | |
run: | | |
####### DO THE UMBRACO PACKAGE BUILD ############# | |
$BuildFolder = Get-Item $Env:BUILD_FOLDER | |
$ReleaseFolder = Get-Item $Env:RELEASE_FOLDER | |
$WebProjFolder = Get-Item $Env:WEB_PROJ_FOLDER | |
$TempFolder = Join-Path -Path $ReleaseFolder -ChildPath "Temp"; | |
# Set the version number in createdPackages.config | |
$CreatedPackagesConfig = Join-Path -Path $BuildFolder -ChildPath "createdPackages.config" | |
$CreatedPackagesConfigXML = [xml](Get-Content $CreatedPackagesConfig) | |
$CreatedPackagesConfigXML.packages.package.version = "$Env:GITVERSION_MAJORMINORPATCH" | |
$CreatedPackagesConfigXML.Save($CreatedPackagesConfig) | |
#copy the orig manifest to temp location to be updated to be used for the package | |
$PackageManifest = Join-Path -Path $BuildFolder -ChildPath "packageManifest.xml" | |
New-Item -ItemType Directory -Path $TempFolder | |
Copy-Item $PackageManifest "$TempFolder\package.xml" | |
$PackageManifest = (Join-Path -Path $TempFolder -ChildPath "package.xml") | |
# Set the data in packageManifest.config | |
$PackageManifestXML = [xml](Get-Content $PackageManifest) | |
$PackageManifestXML.umbPackage.info.package.version = "$Env:GITVERSION_MAJORMINORPATCH" | |
$PackageManifestXML.umbPackage.info.package.name = $CreatedPackagesConfigXML.packages.package.name | |
$PackageManifestXML.umbPackage.info.package.license.set_InnerXML($CreatedPackagesConfigXML.packages.package.license.get_InnerXML()) | |
$PackageManifestXML.umbPackage.info.package.license.url = $CreatedPackagesConfigXML.packages.package.license.url | |
$PackageManifestXML.umbPackage.info.package.url = $CreatedPackagesConfigXML.packages.package.url | |
$PackageManifestXML.umbPackage.info.author.name = $CreatedPackagesConfigXML.packages.package.author.get_InnerXML() | |
$PackageManifestXML.umbPackage.info.author.website = $CreatedPackagesConfigXML.packages.package.author.url | |
#clear the files from the manifest | |
$NewFilesXML = $PackageManifestXML.CreateElement("files") | |
#package the files ... This will lookup all files in the file system that need to be there and update | |
# the package manifest XML with the correct data along with copying these files to the temp folder | |
# so they can be zipped with the package | |
Function WritePackageFile ($f) | |
{ | |
Write-Host $f.FullName -foregroundcolor cyan | |
$NewFileXML = $PackageManifestXML.CreateElement("file") | |
$NewFileXML.set_InnerXML("<guid></guid><orgPath></orgPath><orgName></orgName>") | |
$GuidName = ([guid]::NewGuid()).ToString() + "_" + $f.Name | |
$NewFileXML.guid = $GuidName | |
$NewFileXML.orgPath = ReverseMapPath $f | |
$NewFileXML.orgName = $f.Name | |
$NewFilesXML.AppendChild($NewFileXML) | |
Copy-Item $f.FullName "$TempFolder\$GuidName" | |
} | |
Function ReverseMapPath ($f) | |
{ | |
$resultPath = "~"+ $f.Directory.FullName.Replace($WebProjFolder, "").Replace("\","/") | |
Return $resultPath | |
} | |
Function MapPath ($f) | |
{ | |
$resultPath = Join-Path -Path $WebProjFolder -ChildPath ($f.Replace("~", "").Replace("/", "\")) | |
Return $resultPath | |
} | |
foreach($FileXML in $CreatedPackagesConfigXML.packages.package.files.file) | |
{ | |
$File = Get-Item (MapPath $FileXML) | |
if ($File -is [System.IO.DirectoryInfo]) | |
{ | |
Get-ChildItem -path $File -Recurse ` | |
| Where-Object { $_ -isnot [System.IO.DirectoryInfo]} ` | |
| ForEach-Object { WritePackageFile($_) } ` | |
| Out-Null | |
} | |
else { | |
WritePackageFile($File)| Out-Null | |
} | |
} | |
$PackageManifestXML.umbPackage.ReplaceChild($NewFilesXML, $PackageManifestXML.SelectSingleNode("/umbPackage/files")) | Out-Null | |
$PackageManifestXML.Save($PackageManifest) | |
#zip the package | |
$DestZIP = "$ReleaseFolder\Articulate_$Env:GITVERSION_SEMVER.zip" | |
Add-Type -assembly "system.io.compression.filesystem" | |
[io.compression.zipfile]::CreateFromDirectory($TempFolder, $DestZIP) | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: umbraco-zip | |
path: ${{ env.Release_Folder }}/Articulate_*.zip |