-
-
Notifications
You must be signed in to change notification settings - Fork 106
150 lines (123 loc) · 5.98 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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