added updated files & scripts

This commit is contained in:
Andrew Welker
2020-03-16 12:30:31 -06:00
parent b372f4d369
commit 6cf5fe5ec4
5 changed files with 178 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
$tagCount = $(git rev-list --tags='*.*.*' --count)
if ($tagCount -eq 0) {
$latestVersion = "0.0.0"
}
else {
$latestVersions = $(git describe --tags $(git rev-list --tags='*.*.*' --max-count=10) --abbrev=0)
$latestVersion = ""
Foreach ($version in $latestVersions) {
Write-Output $version
if ($version -match '^[1-9]+.\d+.\d+$') {
$latestVersion = $version
Write-Output "Setting latest version to: $latestVersion"
break
}
}
}
$newVersion = [version]$latestVersion
$phase = ""
$newVersionString = ""
switch -regex ($Env:GITHUB_REF) {
'^refs\/heads\/master\/*.' {
$newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1)
}
'^refs\/heads\/feature\/*.' {
$phase = 'alpha'
}
'^refs\/heads\/release\/*.' {
$phase = 'rc'
}
'^refs\/heads\/development\/*.' {
$phase = 'beta'
}
'^refs\/heads\/hotfix\/*.' {
$phase = 'hotfix'
}
}
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
Write-Output $newVersionString

View File

@@ -0,0 +1,40 @@
function Update-SourceVersion {
Param ([string]$Version)
#$fullVersion = $Version
$baseVersion = [regex]::Match($Version, "(\d+.\d+.\d+).*").captures.groups[1].value
$NewAssemblyVersion = AssemblyVersion(" + $baseVersion + .*")
Write-Output "AssemblyVersion = $NewAssemblyVersion"
$NewAssemblyInformationalVersion = AssemblyInformationalVersion(" + $Version + ")
Write-Output "AssemblyInformationalVersion = $NewAssemblyInformationalVersion"
foreach ($o in $input) {
Write-output $o.FullName
$TmpFile = $o.FullName + .tmp
get-content $o.FullName |
ForEach-Object {
$_ -replace AssemblyVersion\(".*"\), $NewAssemblyVersion } |
ForEach-Object {
$_ -replace AssemblyInformationalVersion\(".*"\), $NewAssemblyInformationalVersion
} > $TmpFile
move-item $TmpFile $o.FullName -force
}
}
function Update-AllAssemblyInfoFiles ( $version ) {
foreach ($file in AssemblyInfo.cs, AssemblyInfo.vb ) {
get-childitem -Path $Env:GITHUB_WORKSPACE -recurse | Where-Object { $_.Name -eq $file } | Update-SourceVersion $version ;
}
}
# validate arguments
$r = [System.Text.RegularExpressions.Regex]::Match($args[0], "\d+\.\d+\.\d+.*");
if ($r.Success) {
Write-Output "Updating Assembly Version to $args ...";
Update-AllAssemblyInfoFiles $args[0];
}
else {
Write-Output ;
Write-Output Error: Input version does not match x.y.z format!
Write-Output ;
Write-Output "Unable to apply version to AssemblyInfo.cs files";
}

23
.github/scripts/ZipBuildOutput.ps1 vendored Normal file
View File

@@ -0,0 +1,23 @@
$destination = "$($Env:GITHUB_WORKSPACE)\output"
New-Item -ItemType Directory -Force -Path ($destination)
Get-ChildItem ($destination)
$exclusions = @(git submodule foreach --quiet 'echo $name')
Write-Output "Exclusions $($exclusions)"
Get-ChildItem -recurse -Path "$($Env:GITHUB_WORKSPACE)" -include @("*.clz", "*.cpz", "*.cplz") | ForEach-Object{
Write-Host "checking $($_)"
$allowed = $true;
foreach($exclude in $exclusions) {
if((Split-Path $_.FullName -Parent).contains("$($exclude)")) {
Write-Host "excluding $($_)"
$allowed = $false;
break;
}
}
if($allowed) {
Write-Host "allowing $($_)"
$_;
}
} | Copy-Item -Destination ($destination)
Get-ChildItem "$($Env:GITHUB_WORKSPACE)\output"
Compress-Archive -Path "$($Env:GITHUB_WORKSPACE)\output\*" -DestinationPath "$($Env:GITHUB_WORKSPACE)\output.zip"
Get-ChildItem "$($Env:GITHUB_WORKSPACE)\"

75
.github/workflows/docker.yml vendored Normal file
View File

@@ -0,0 +1,75 @@
name: Branch Build
on:
push:
branches:
- feature/*
env:
# solution path doesn't need slashes unless there it is multiple folders deep
SOLUTION_PATH: pepperdash-generic-colorlightz6-epi
SOLUTION_FILE: pepperdash-generic-colorlightz6-epi.sln
VERSION: 0.0.0-buildtype-buildnumber
BUILD_TYPE: Debug
RELEASE_BRANCH: master
jobs:
build_project:
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Checkout submodules
shell: bash
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Set Build to Relase if triggered from Master
run: |
if("$($Env:GITHUB_REF)".contains("$($Env:RELEASE_BRANCH)")) {
Write-Host "Setting build type to Release"
Write-Output "::set-env name=BUILD_TYPE::Release"
}
- name: Set Version Number
shell: powershell
run: |
$version = ./.github/scripts/GenerateVersionNumber.ps1
Write-Output "::set-env name=VERSION::$version"
- name: Update AssemblyInfo.cs
shell: powershell
run: |
Write-Output ${{ env.VERSION }}
./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }}
- name: Build Solution
shell: powershell
run: |
Invoke-Expression "docker run --rm --mount type=bind,source=""$($Env:GITHUB_WORKSPACE)"",target=""c:/project"" pepperdash/sspbuilder c:\cihelpers\vsidebuild.exe -Solution ""c:\project\$($Env:SOLUTION_PATH)\$($Env:SOLUTION_FILE)"" -BuildSolutionConfiguration $($ENV:BUILD_TYPE)"
./.github/scripts/ZipBuildOutput.ps1
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: Build
path: ./output.zip
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: v${{ env.VERSION }}
release_name: v${{ env.VERSION }}
prerelease: ${{contains('debug', env.BUILD_TYPE)}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload
id: upload_release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./output.zip
asset_name: output.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}