diff --git a/.github/scripts/GenerateVersionNumber.ps1 b/.github/scripts/GenerateVersionNumber.ps1
new file mode 100644
index 0000000..467ce88
--- /dev/null
+++ b/.github/scripts/GenerateVersionNumber.ps1
@@ -0,0 +1,45 @@
+$latestVersions = $(git tag --merged origin/master)
+$latestVersion = [version]"0.0.0"
+Foreach ($version in $latestVersions) {
+ Write-Host $version
+ try {
+ if (([version]$version) -ge $latestVersion) {
+ $latestVersion = $version
+ Write-Host "Setting latest version to: $latestVersion"
+ }
+ }
+ catch {
+ Write-Host "Unable to convert $($version). Skipping"
+ continue;
+ }
+}
+
+$newVersion = [version]$latestVersion
+$phase = ""
+$newVersionString = ""
+switch -regex ($Env:GITHUB_REF) {
+ '^refs\/heads\/master*.' {
+ $newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, $newVersion.Build
+ }
+ '^refs\/heads\/feature\/*.' {
+ $phase = 'alpha'
+ $newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
+ }
+ '^refs\/heads\/release\/*.' {
+ $splitRef = $Env:GITHUB_REF -split "/"
+ $version = [version]($splitRef[-1] -replace "v", "")
+ $phase = 'rc'
+ $newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $version.Major, $version.Minor, $version.Build, $phase, $Env:GITHUB_RUN_NUMBER
+ }
+ '^refs\/heads\/development*.' {
+ $phase = 'beta'
+ $newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
+ }
+ '^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
diff --git a/.github/scripts/UpdateAssemblyVersion.ps1 b/.github/scripts/UpdateAssemblyVersion.ps1
new file mode 100644
index 0000000..e52b31e
--- /dev/null
+++ b/.github/scripts/UpdateAssemblyVersion.ps1
@@ -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";
+}
diff --git a/.github/scripts/ZipBuildOutput.ps1 b/.github/scripts/ZipBuildOutput.ps1
new file mode 100644
index 0000000..14cd92b
--- /dev/null
+++ b/.github/scripts/ZipBuildOutput.ps1
@@ -0,0 +1,41 @@
+# Uncomment these for local testing
+# $Env:GITHUB_WORKSPACE = "C:\Working Directories\PD\essentials"
+# $Env:SOLUTION_FILE = "PepperDashEssentials"
+# $Env:VERSION = "0.0.0-buildType-test"
+
+# Sets the root directory for the operation
+$destination = "$($Env:GITHUB_HOME)\output"
+New-Item -ItemType Directory -Force -Path ($destination)
+Get-ChildItem ($destination)
+$exclusions = @(git submodule foreach --quiet 'echo $name')
+# Trying to get any .json schema files (not currently working)
+# Gets any files with the listed extensions.
+Get-ChildItem -recurse -Path "$($Env:GITHUB_WORKSPACE)" -include "*.clz", "*.cpz", "*.cplz", "*.json" | ForEach-Object {
+ $allowed = $true;
+ # Exclude any files in submodules
+ foreach ($exclude in $exclusions) {
+ if ((Split-Path $_.FullName -Parent).contains("$($exclude)")) {
+ $allowed = $false;
+ break;
+ }
+ }
+ if ($allowed) {
+ Write-Host "allowing $($_)"
+ $_;
+ }
+} | Copy-Item -Destination ($destination) -Force
+Write-Host "Getting matching files..."
+# Get any files from the output folder that match the following extensions
+Get-ChildItem -Path $destination | Where-Object { (($_.Extension -eq ".clz") -or ($_.Extension -eq ".cpz") -or ($_.Extension -eq ".cplz")) } | ForEach-Object {
+ # Replace the extensions with dll or xml and create an array
+ $filenames = @($($_ -replace "cpz|clz|cplz", "dll"), $($_ -replace "cpz|clz|cplz", "xml"))
+ Write-Host "Filenames:"
+ Write-Host $filenames
+ if ($filenames.length -gt 0) {
+ # Attempt to get the files and return them to the output directory
+ Get-ChildItem -Recurse -Path "$($Env:GITHUB_WORKSPACE)" -include $filenames | Copy-Item -Destination ($destination) -Force
+ }
+}
+Compress-Archive -Path $destination -DestinationPath "$($Env:GITHUB_WORKSPACE)\$($Env:SOLUTION_FILE)-$($Env:VERSION).zip" -Force
+Write-Host "Output Contents post Zip"
+Get-ChildItem -Path $destination
\ No newline at end of file
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 0000000..33c0c2d
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,265 @@
+name: Branch Build Using Docker
+
+on:
+ push:
+ branches:
+ - feature/*
+ - hotfix/*
+ - release/*
+ - development
+
+env:
+ # solution path doesn't need slashes unless there it is multiple folders deep
+ # solution name does not include extension. .sln is assumed
+ SOLUTION_PATH: Pepperdash Core
+ SOLUTION_FILE: PepperDash Core
+ # Do not edit this, we're just creating it here
+ VERSION: 0.0.0-buildtype-buildnumber
+ # Defaults to debug for build type
+ BUILD_TYPE: Debug
+ # Defaults to master as the release branch. Change as necessary
+ RELEASE_BRANCH: master
+jobs:
+ Build_Project:
+ runs-on: windows-latest
+ steps:
+ # First we checkout the source repo
+ - name: Checkout repo
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ # And any submodules
+ - 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
+ # Fetch all tags
+ - name: Fetch tags
+ run: git fetch --tags
+ # Generate the appropriate version number
+ - name: Set Version Number
+ shell: powershell
+ run: |
+ $version = ./.github/scripts/GenerateVersionNumber.ps1
+ Write-Output "::set-env name=VERSION::$version"
+ # Use the version number to set the version of the assemblies
+ - name: Update AssemblyInfo.cs
+ shell: powershell
+ run: |
+ Write-Output ${{ env.VERSION }}
+ ./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }}
+ # Login to Docker
+ - name: Login to Docker
+ uses: azure/docker-login@v1
+ with:
+ username: ${{ secrets.dockerhub_user }}
+ password: ${{ secrets.dockerhub_password }}
+ # Build the solutions in the docker image
+ - 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).sln"" -BuildSolutionConfiguration $($ENV:BUILD_TYPE)"
+ # Zip up the output files as needed
+ - name: Zip Build Output
+ shell: powershell
+ run: ./.github/scripts/ZipBuildOutput.ps1
+ # Write the version to a file to be consumed by the push jobs
+ - name: Write Version
+ run: Write-Output "$($Env:VERSION)" | Out-File -FilePath "$($Env:GITHUB_HOME)\output\version.txt"
+ # Upload the build output as an artifact
+ - name: Upload Build Output
+ uses: actions/upload-artifact@v1
+ with:
+ name: Build
+ path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
+ # Upload the Version file as an artifact
+ - name: Upload version.txt
+ uses: actions/upload-artifact@v1
+ with:
+ name: Version
+ path: ${{env.GITHUB_HOME}}\output\version.txt
+ # Create the release on the source repo
+ - name: Create tag for non-rc builds
+ if: contains(env.VERSION, 'alpha') || contains(env.VERSION, 'beta')
+ run: |
+ git tag $($Env:VERSION)
+ git push --tags origin
+ - name: Create Release
+ id: create_release
+ # using contributor's version to allow for pointing at the right commit
+ if: contains(env.VERSION,'-rc-') || contains(env.VERSION,'-hotfix-')
+ uses: fleskesvor/create-release@feature/support-target-commitish
+ with:
+ tag_name: ${{ env.VERSION }}
+ release_name: ${{ env.VERSION }}
+ prerelease: ${{contains('debug', env.BUILD_TYPE)}}
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ # Upload the build package to the release
+ - name: Upload Release Package
+ if: contains(env.VERSION,'-rc-') || contains(env.VERSION,'-hotfix-')
+ id: upload_release
+ uses: actions/upload-release-asset@v1
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
+ asset_name: ${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
+ asset_content_type: application/zip
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ # This step always runs and pushes the build to the internal build rep
+ Internal_Push_Output:
+ needs: Build_Project
+ runs-on: windows-latest
+ steps:
+ # Checkout the repo
+ - name: Checkout Builds Repo
+ uses: actions/checkout@v2
+ with:
+ token: ${{ secrets.BUILDS_TOKEN }}
+ repository: PepperDash-Engineering/pepperdash-core-builds
+ ref: ${{ Env.GITHUB_REF }}
+ # Download the version artifact from the build job
+ - name: Download Build Version Info
+ uses: actions/download-artifact@v1
+ with:
+ name: Version
+ - name: Check Directory
+ run: Get-ChildItem "./"
+ # Set the version number environment variable from the file we just downloaded
+ - name: Set Version Number
+ shell: powershell
+ run: |
+ Get-ChildItem "./Version"
+ $version = Get-Content -Path ./Version/version.txt
+ Write-Host "Version: $version"
+ Write-Output "::set-env name=VERSION::$version"
+ Remove-Item -Path ./Version/version.txt
+ Remove-Item -Path ./Version
+ # Checkout/Create the branch
+ - name: Create new branch
+ run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/")
+ # Download the build output into the repo
+ - name: Download Build output
+ uses: actions/download-artifact@v1
+ with:
+ name: Build
+ path: ./
+ - name: Check directory
+ run: Get-ChildItem ./
+ # Unzip the build package file
+ - name: Unzip Build file
+ run: |
+ Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\
+ Remove-Item -Path .\*.zip
+ - name: Check directory again
+ run: Get-ChildItem ./
+ # Copy Contents of output folder to root directory
+ - name: Copy Files to root & delete output directory
+ run: |
+ Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz")
+ Get-ChildItem -Path .\output\* | Copy-Item -Destination .\
+ Remove-Item -Path .\output -Recurse
+ # Commits the build output to the branch and tags it with the version
+ - name: Commit build output and tag the commit
+ shell: powershell
+ run: |
+ git config user.email "actions@pepperdash.com"
+ git config user.name "GitHub Actions"
+ git add .
+ $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)"
+ Write-Host "Commit: $commit"
+ git commit -m $commit
+ git tag $($Env:VERSION)
+ # Push the commit
+ - name: Push to Builds Repo
+ shell: powershell
+ run: |
+ $branch = $($Env:GITHUB_REF) -replace "refs/heads/"
+ Write-Host "Branch: $branch"
+ git push -u origin $($branch) --force
+ # Push the tags
+ - name: Push tags
+ run: git push --tags origin
+ - name: Check Directory
+ run: Get-ChildItem ./
+ # This step only runs if the branch is master or release/ runs and pushes the build to the public build repo
+ Public_Push_Output:
+ needs: Build_Project
+ runs-on: windows-latest
+ if: contains(github.ref, 'master') || contains(github.ref, 'release')
+ steps:
+ # Checkout the repo
+ - name: Checkout Builds Repo
+ uses: actions/checkout@v2
+ with:
+ token: ${{ secrets.BUILDS_TOKEN }}
+ repository: PepperDash/PepperDashCore-Builds
+ ref: ${{ Env.GITHUB_REF }}
+ # Download the version artifact from the build job
+ - name: Download Build Version Info
+ uses: actions/download-artifact@v1
+ with:
+ name: Version
+ - name: Check Directory
+ run: Get-ChildItem "./"
+ # Set the version number environment variable from the file we just downloaded
+ - name: Set Version Number
+ shell: powershell
+ run: |
+ Get-ChildItem "./Version"
+ $version = Get-Content -Path ./Version/version.txt
+ Write-Host "Version: $version"
+ Write-Output "::set-env name=VERSION::$version"
+ Remove-Item -Path ./Version/version.txt
+ Remove-Item -Path ./Version
+ # Checkout/Create the branch
+ - name: Create new branch
+ run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/")
+ # Download the build output into the repo
+ - name: Download Build output
+ uses: actions/download-artifact@v1
+ with:
+ name: Build
+ path: ./
+ - name: Check directory
+ run: Get-ChildItem ./
+ # Unzip the build package file
+ - name: Unzip Build file
+ run: |
+ Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\
+ Remove-Item -Path .\*.zip
+ - name: Check directory again
+ run: Get-ChildItem ./
+ # Copy Contents of output folder to root directory
+ - name: Copy Files to root & delete output directory
+ run: |
+ Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz")
+ Get-ChildItem -Path .\output\* | Copy-Item -Destination .\
+ Remove-Item -Path .\output -Recurse
+ # Commits the build output to the branch and tags it with the version
+ - name: Commit build output and tag the commit
+ shell: powershell
+ run: |
+ git config user.email "actions@pepperdash.com"
+ git config user.name "GitHub Actions"
+ git add .
+ $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)"
+ Write-Host "Commit: $commit"
+ git commit -m $commit
+ git tag $($Env:VERSION)
+ # Push the commit
+ - name: Push to Builds Repo
+ shell: powershell
+ run: |
+ $branch = $($Env:GITHUB_REF) -replace "refs/heads/"
+ Write-Host "Branch: $branch"
+ git push -u origin $($branch) --force
+ # Push the tags
+ - name: Push tags
+ run: git push --tags origin
+ - name: Check Directory
+ run: Get-ChildItem ./
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index c4cf0f9..0000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-name: Build Non-Release Branch
-
-
-on:
- push:
- branches:
- - feature/*
- - bugfix/*
- - hotfix/*
-
-
-jobs:
- build:
- name: Build
- runs-on: self-hosted
- steps:
- - run: Invoke-WebRequest -URI "http://localhost:8080/job/PepperDash%20Core%20Branch%20Builds/build?token=$($Env:projectToken)" -Headers @{Authorization = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("ndorin:$($Env:token)")))"} -Method POST -UseBasicParsing
- env:
- token: ${{ secrets.TOKEN }}
- projectToken: ${{ secrets.PROJECTTOKEN}}
diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml
new file mode 100644
index 0000000..7a6135c
--- /dev/null
+++ b/.github/workflows/master.yml
@@ -0,0 +1,229 @@
+name: Master Build using Docker
+
+on:
+ release:
+ types:
+ - created
+ branches:
+ - master
+env:
+ # solution path doesn't need slashes unless there it is multiple folders deep
+ # solution name does not include extension. .sln is assumed
+ SOLUTION_PATH: Pepperdash Core
+ SOLUTION_FILE: Pepperdash Core
+ # Do not edit this, we're just creating it here
+ VERSION: 0.0.0-buildtype-buildnumber
+ # Defaults to debug for build type
+ BUILD_TYPE: Release
+ # Defaults to master as the release branch. Change as necessary
+ RELEASE_BRANCH: master
+jobs:
+ Build_Project:
+ runs-on: windows-latest
+ steps:
+ # First we checkout the source repo
+ - name: Checkout repo
+ uses: actions/checkout@v2
+ # And any submodules
+ - 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
+ # Generate the appropriate version number
+ - name: Set Version Number
+ shell: powershell
+ env:
+ TAG_NAME: ${{ github.event.release.tag_name }}
+ run: Write-Output "::set-env name=VERSION::$($Env:TAG_NAME)"
+ # Use the version number to set the version of the assemblies
+ - name: Update AssemblyInfo.cs
+ shell: powershell
+ run: |
+ Write-Output ${{ env.VERSION }}
+ ./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }}
+ # Login to Docker
+ - name: Login to Docker
+ uses: azure/docker-login@v1
+ with:
+ username: ${{ secrets.dockerhub_user }}
+ password: ${{ secrets.dockerhub_password }}
+ # Build the solutions in the docker image
+ - 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).sln"" -BuildSolutionConfiguration $($ENV:BUILD_TYPE)"
+ # Zip up the output files as needed
+ - name: Zip Build Output
+ shell: powershell
+ run: ./.github/scripts/ZipBuildOutput.ps1
+ - name: Upload Build Output
+ uses: actions/upload-artifact@v1
+ with:
+ name: Build
+ path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
+ # Upload the build package to the release
+ - name: Upload Release Package
+ id: upload_release
+ uses: actions/upload-release-asset@v1
+ with:
+ upload_url: ${{ github.event.release.upload_url }}
+ asset_path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
+ asset_name: ${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
+ asset_content_type: application/zip
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ Internal_Push_Output:
+ needs: Build_Project
+ runs-on: windows-latest
+ steps:
+ # Checkout the repo
+ - name: Checkout Builds Repo
+ uses: actions/checkout@v2
+ with:
+ token: ${{ secrets.BUILDS_TOKEN }}
+ repository: PepperDash-Engineering/pepperdash-core-builds
+ ref: ${{ Env.GITHUB_REF }}
+ # Download the version artifact from the build job
+ - name: Download Build Version Info
+ uses: actions/download-artifact@v1
+ with:
+ name: Version
+ - name: Check Directory
+ run: Get-ChildItem "./"
+ # Set the version number environment variable from the file we just downloaded
+ - name: Set Version Number
+ shell: powershell
+ run: |
+ Get-ChildItem "./Version"
+ $version = Get-Content -Path ./Version/version.txt
+ Write-Host "Version: $version"
+ Write-Output "::set-env name=VERSION::$version"
+ Remove-Item -Path ./Version/version.txt
+ Remove-Item -Path ./Version
+ # Checkout/Create the branch
+ - name: Create new branch
+ run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/")
+ # Download the build output into the repo
+ - name: Download Build output
+ uses: actions/download-artifact@v1
+ with:
+ name: Build
+ path: ./
+ - name: Check directory
+ run: Get-ChildItem ./
+ # Unzip the build package file
+ - name: Unzip Build file
+ run: |
+ Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\
+ Remove-Item -Path .\*.zip
+ - name: Check directory again
+ run: Get-ChildItem ./
+ # Copy Contents of output folder to root directory
+ - name: Copy Files to root & delete output directory
+ run: |
+ Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz")
+ Get-ChildItem -Path .\output\* | Copy-Item -Destination .\
+ Remove-Item -Path .\output -Recurse
+ # Commits the build output to the branch and tags it with the version
+ - name: Commit build output and tag the commit
+ shell: powershell
+ run: |
+ git config user.email "actions@pepperdash.com"
+ git config user.name "GitHub Actions"
+ git add .
+ $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)"
+ Write-Host "Commit: $commit"
+ git commit -m $commit
+ git tag $($Env:VERSION)
+ # Push the commit
+ - name: Push to Builds Repo
+ shell: powershell
+ run: |
+ $branch = $($Env:GITHUB_REF) -replace "refs/heads/"
+ Write-Host "Branch: $branch"
+ git push -u origin $($branch) --force
+ # Push the tags
+ - name: Push tags
+ run: git push --tags origin
+ - name: Check Directory
+ run: Get-ChildItem ./
+ # This step only runs if the branch is master or release/ runs and pushes the build to the public build repo
+ Public_Push_Output:
+ needs: Build_Project
+ runs-on: windows-latest
+ if: contains(github.ref, 'master') || contains(github.ref, 'release')
+ steps:
+ # Checkout the repo
+ - name: Checkout Builds Repo
+ uses: actions/checkout@v2
+ with:
+ token: ${{ secrets.BUILDS_TOKEN }}
+ repository: PepperDash/PepperDashCore-Builds
+ ref: ${{ Env.GITHUB_REF }}
+ # Download the version artifact from the build job
+ - name: Download Build Version Info
+ uses: actions/download-artifact@v1
+ with:
+ name: Version
+ - name: Check Directory
+ run: Get-ChildItem "./"
+ # Set the version number environment variable from the file we just downloaded
+ - name: Set Version Number
+ shell: powershell
+ run: |
+ Get-ChildItem "./Version"
+ $version = Get-Content -Path ./Version/version.txt
+ Write-Host "Version: $version"
+ Write-Output "::set-env name=VERSION::$version"
+ Remove-Item -Path ./Version/version.txt
+ Remove-Item -Path ./Version
+ # Checkout/Create the branch
+ - name: Create new branch
+ run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/")
+ # Download the build output into the repo
+ - name: Download Build output
+ uses: actions/download-artifact@v1
+ with:
+ name: Build
+ path: ./
+ - name: Check directory
+ run: Get-ChildItem ./
+ # Unzip the build package file
+ - name: Unzip Build file
+ run: |
+ Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\
+ Remove-Item -Path .\*.zip
+ - name: Check directory again
+ run: Get-ChildItem ./
+ # Copy Contents of output folder to root directory
+ - name: Copy Files to root & delete output directory
+ run: |
+ Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz")
+ Get-ChildItem -Path .\output\* | Copy-Item -Destination .\
+ Remove-Item -Path .\output -Recurse
+ # Commits the build output to the branch and tags it with the version
+ - name: Commit build output and tag the commit
+ shell: powershell
+ run: |
+ git config user.email "actions@pepperdash.com"
+ git config user.name "GitHub Actions"
+ git add .
+ $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)"
+ Write-Host "Commit: $commit"
+ git commit -m $commit
+ git tag $($Env:VERSION)
+ # Push the commit
+ - name: Push to Builds Repo
+ shell: powershell
+ run: |
+ $branch = $($Env:GITHUB_REF) -replace "refs/heads/"
+ Write-Host "Branch: $branch"
+ git push -u origin $($branch) --force
+ # Push the tags
+ - name: Push tags
+ run: git push --tags origin
+ - name: Check Directory
+ run: Get-ChildItem ./
diff --git a/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs
new file mode 100644
index 0000000..f3b5613
--- /dev/null
+++ b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs
@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+using PepperDash.Core;
+
+namespace PepperDash.Core
+{
+ ///
+ /// Controls the ability to disable/enable debugging of TX/RX data sent to/from a device with a built in timer to disable
+ ///
+ public class CommunicationStreamDebugging
+ {
+ ///
+ /// Device Key that this instance configures
+ ///
+ public string ParentDeviceKey { get; private set; }
+
+ ///
+ /// Timer to disable automatically if not manually disabled
+ ///
+ private CTimer DebugExpiryPeriod;
+
+ public eStreamDebuggingSetting DebugSetting { get; private set; }
+
+ private uint _DebugTimeoutInMs;
+ private const uint _DefaultDebugTimeoutMin = 30;
+
+ ///
+ /// Timeout in Minutes
+ ///
+ public uint DebugTimeoutMinutes
+ {
+ get
+ {
+ return _DebugTimeoutInMs/60000;
+ }
+ }
+
+ public bool RxStreamDebuggingIsEnabled{ get; private set; }
+
+ public bool TxStreamDebuggingIsEnabled { get; private set; }
+
+
+ public CommunicationStreamDebugging(string parentDeviceKey)
+ {
+ ParentDeviceKey = parentDeviceKey;
+ }
+
+
+ ///
+ /// Sets the debugging setting and if not setting to off, assumes the default of 30 mintues
+ ///
+ ///
+ public void SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting setting)
+ {
+ if (setting == eStreamDebuggingSetting.Off)
+ {
+ DisableDebugging();
+ return;
+ }
+
+ SetDebuggingWithSpecificTimeout(setting, _DefaultDebugTimeoutMin);
+ }
+
+ ///
+ /// Sets the debugging setting for the specified number of minutes
+ ///
+ ///
+ ///
+ public void SetDebuggingWithSpecificTimeout(eStreamDebuggingSetting setting, uint minutes)
+ {
+ if (setting == eStreamDebuggingSetting.Off)
+ {
+ DisableDebugging();
+ return;
+ }
+
+ _DebugTimeoutInMs = minutes * 60000;
+
+ if (DebugExpiryPeriod != null)
+ {
+ DisableDebugging();
+ }
+
+ DebugExpiryPeriod = new CTimer((o) => DisableDebugging(), _DebugTimeoutInMs);
+
+ if ((setting & eStreamDebuggingSetting.Rx) == eStreamDebuggingSetting.Rx)
+ RxStreamDebuggingIsEnabled = true;
+
+ if ((setting & eStreamDebuggingSetting.Tx) == eStreamDebuggingSetting.Tx)
+ TxStreamDebuggingIsEnabled = true;
+
+ Debug.SetDeviceDebugSettings(ParentDeviceKey, setting);
+
+ }
+
+ ///
+ /// Disabled debugging
+ ///
+ private void DisableDebugging()
+ {
+ DebugExpiryPeriod.Stop();
+ DebugExpiryPeriod.Dispose();
+ DebugExpiryPeriod = null;
+
+ RxStreamDebuggingIsEnabled = false;
+ TxStreamDebuggingIsEnabled = false;
+
+ Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off);
+ }
+ }
+
+ ///
+ /// The available settings for stream debugging
+ ///
+ [Flags]
+ public enum eStreamDebuggingSetting
+ {
+ Off = 0,
+ Rx = 1,
+ Tx = 2,
+ Both = Rx | Tx
+ }
+}
\ No newline at end of file
diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs
index ef57ae0..69fa3be 100644
--- a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs
+++ b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs
@@ -11,8 +11,10 @@ namespace PepperDash.Core
///
///
///
- public class GenericSshClient : Device, ISocketStatus, IAutoReconnect
+ public class GenericSshClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
{
+ public CommunicationStreamDebugging StreamDebugging { get; private set; }
+
///
/// Event that fires when data is received. Delivers args with byte array
///
@@ -139,6 +141,7 @@ namespace PepperDash.Core
public GenericSshClient(string key, string hostname, int port, string username, string password) :
base(key)
{
+ StreamDebugging = new CommunicationStreamDebugging(key);
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
Key = key;
Hostname = hostname;
@@ -240,7 +243,7 @@ namespace PepperDash.Core
try
{
Client.Connect();
- TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 65534);
+ TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 100000);
TheStream.DataReceived += Stream_DataReceived;
//TheStream.ErrorOccurred += TheStream_ErrorOccurred;
Debug.Console(1, this, "Connected");
@@ -381,6 +384,10 @@ namespace PepperDash.Core
{
var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
textHandler(this, new GenericCommMethodReceiveTextArgs(str));
+
+ if (StreamDebugging.RxStreamDebuggingIsEnabled)
+ Debug.Console(0, this, "Recevied: '{0}'", str);
+
}
}
}
@@ -422,8 +429,12 @@ namespace PepperDash.Core
{
if (Client != null)
{
+ if (StreamDebugging.TxStreamDebuggingIsEnabled)
+ Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text);
+
TheStream.Write(text);
TheStream.Flush();
+
}
}
catch
@@ -444,6 +455,9 @@ namespace PepperDash.Core
{
if (Client != null)
{
+ if (StreamDebugging.TxStreamDebuggingIsEnabled)
+ Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
+
TheStream.Write(bytes, 0, bytes.Length);
TheStream.Flush();
}
diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs
index c1384f9..3d77ad1 100644
--- a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs
+++ b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs
@@ -14,8 +14,10 @@ namespace PepperDash.Core
///
/// A class to handle basic TCP/IP communications with a server
///
- public class GenericTcpIpClient : Device, ISocketStatus, IAutoReconnect
+ public class GenericTcpIpClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
{
+ public CommunicationStreamDebugging StreamDebugging { get; private set; }
+
///
/// Fires when data is received from the server and returns it as a Byte array
///
@@ -176,7 +178,7 @@ namespace PepperDash.Core
public GenericTcpIpClient(string key, string address, int port, int bufferSize)
: base(key)
{
-
+ StreamDebugging = new CommunicationStreamDebugging(key);
Hostname = address;
Port = port;
BufferSize = bufferSize;
@@ -192,6 +194,7 @@ namespace PepperDash.Core
public GenericTcpIpClient(string key)
: base(key)
{
+ StreamDebugging = new CommunicationStreamDebugging(key);
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
AutoReconnectIntervalMs = 5000;
BufferSize = 2000;
@@ -224,7 +227,7 @@ namespace PepperDash.Core
if (programEventType == eProgramStatusEventType.Stopping)
{
Debug.Console(1, this, "Program stopping. Closing connection");
- DisconnectClient();
+ Disconnect();
}
}
@@ -348,8 +351,15 @@ namespace PepperDash.Core
if (textHandler != null)
{
var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
+
+ if (StreamDebugging.RxStreamDebuggingIsEnabled)
+ Debug.Console(0, this, "Recevied: '{0}'", str);
+
textHandler(this, new GenericCommMethodReceiveTextArgs(str));
+
}
+
+
}
client.ReceiveDataAsync(Receive);
@@ -363,10 +373,12 @@ namespace PepperDash.Core
{
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
// Check debug level before processing byte array
- //if (Debug.Level == 2)
- // Debug.Console(2, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
+ if (StreamDebugging.TxStreamDebuggingIsEnabled)
+ Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
if(Client != null)
Client.SendData(bytes, bytes.Length);
+
+
}
///
@@ -388,8 +400,8 @@ namespace PepperDash.Core
///
public void SendBytes(byte[] bytes)
{
- //if (Debug.Level == 2)
- // Debug.Console(2, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
+ if (StreamDebugging.TxStreamDebuggingIsEnabled)
+ Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
if(Client != null)
Client.SendData(bytes, bytes.Length);
}
diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs
index d675646..1e9dddd 100644
--- a/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs
+++ b/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs
@@ -15,8 +15,9 @@ using Newtonsoft.Json.Linq;
namespace PepperDash.Core
{
- public class GenericUdpServer : Device, IBasicCommunication, ISocketStatus
+ public class GenericUdpServer : Device, ISocketStatusWithStreamDebugging
{
+ public CommunicationStreamDebugging StreamDebugging { get; private set; }
///
///
///
@@ -138,6 +139,7 @@ namespace PepperDash.Core
public GenericUdpServer(string key, string address, int port, int buffefSize)
: base(key)
{
+ StreamDebugging = new CommunicationStreamDebugging(key);
Hostname = address;
Port = port;
BufferSize = buffefSize;
@@ -268,8 +270,9 @@ namespace PepperDash.Core
var textHandler = TextReceived;
if (textHandler != null)
{
-
- Debug.Console(2, this, "RX: {0}", str);
+ if (StreamDebugging.RxStreamDebuggingIsEnabled)
+ Debug.Console(0, this, "Recevied: '{0}'", str);
+
textHandler(this, new GenericCommMethodReceiveTextArgs(str));
}
else
@@ -323,7 +326,9 @@ namespace PepperDash.Core
if (IsConnected && Server != null)
{
- Debug.Console(2, this, "TX: {0}", text);
+ if (StreamDebugging.TxStreamDebuggingIsEnabled)
+ Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text);
+
Server.SendData(bytes, bytes.Length);
}
}
@@ -334,8 +339,9 @@ namespace PepperDash.Core
///
public void SendBytes(byte[] bytes)
{
- //if (Debug.Level == 2)
- // Debug.Console(2, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
+ if (StreamDebugging.TxStreamDebuggingIsEnabled)
+ Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
+
if (IsConnected && Server != null)
Server.SendData(bytes, bytes.Length);
}
diff --git a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs
index 2c8c0bc..c5892a4 100644
--- a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs
+++ b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs
@@ -32,6 +32,22 @@ namespace PepperDash.Core
void SendBytes(byte[] bytes);
}
+ ///
+ /// Represents a device that implements IBasicCommunication and IStreamDebugging
+ ///
+ public interface IBasicCommunicationWithStreamDebugging : IBasicCommunication, IStreamDebugging
+ {
+
+ }
+
+ ///
+ /// Represents a device with stream debugging capablities
+ ///
+ public interface IStreamDebugging
+ {
+ CommunicationStreamDebugging StreamDebugging { get; }
+ }
+
///
/// For IBasicCommunication classes that have SocketStatus. GenericSshClient,
/// GenericTcpIpClient
@@ -42,6 +58,13 @@ namespace PepperDash.Core
SocketStatus ClientStatus { get; }
}
+ ///
+ /// Represents a device that implements ISocketStatus and IStreamDebugging
+ ///
+ public interface ISocketStatusWithStreamDebugging : ISocketStatus, IStreamDebugging
+ {
+
+ }
public interface IAutoReconnect
{
diff --git a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs
index cf4d8df..5d245d2 100644
--- a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs
+++ b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs
@@ -274,6 +274,28 @@ namespace PepperDash.Core
}
}
+ ///
+ /// sets the settings for a device or creates a new entry
+ ///
+ ///
+ ///
+ ///
+ public static void SetDeviceDebugSettings(string deviceKey, object settings)
+ {
+ Contexts.SetDebugSettingsForKey(deviceKey, settings);
+ SaveMemoryOnTimeout();
+ }
+
+ ///
+ /// Gets the device settings for a device by key or returns null
+ ///
+ ///
+ ///
+ public static object GetDeviceDebugSettingsForKey(string deviceKey)
+ {
+ return Contexts.GetDebugSettingsForKey(deviceKey);
+ }
+
///
/// Sets the flag to prevent application starting on next boot
///
diff --git a/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs b/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs
index 6dcb65f..1b0fea1 100644
--- a/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs
+++ b/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs
@@ -5,16 +5,31 @@ using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
namespace PepperDash.Core.DebugThings
{
public class DebugContextCollection
{
+ ///
+ /// To prevent threading issues with the DeviceDebugSettings collection
+ ///
+ private CCriticalSection DeviceDebugSettingsLock;
+
[JsonProperty("items")]
Dictionary Items;
+ ///
+ /// Collection of the debug settings for each device where the dictionary key is the device key
+ ///
+ [JsonProperty("deviceDebugSettings")]
+ private Dictionary DeviceDebugSettings { get; set; }
+
+
public DebugContextCollection()
{
+ DeviceDebugSettingsLock = new CCriticalSection();
+ DeviceDebugSettings = new Dictionary();
Items = new Dictionary();
}
@@ -43,6 +58,35 @@ namespace PepperDash.Core.DebugThings
Items[contextKey] = new DebugContextItem(this) { Level = 0 };
return Items[contextKey];
}
+
+
+ ///
+ /// sets the settings for a device or creates a new entry
+ ///
+ ///
+ ///
+ ///
+ public void SetDebugSettingsForKey(string deviceKey, object settings)
+ {
+ var existingSettings = DeviceDebugSettings[deviceKey];
+
+ if (existingSettings != null)
+ {
+ existingSettings = settings;
+ }
+ else
+ DeviceDebugSettings.Add(deviceKey, settings);
+ }
+
+ ///
+ /// Gets the device settings for a device by key or returns null
+ ///
+ ///
+ ///
+ public object GetDebugSettingsForKey(string deviceKey)
+ {
+ return DeviceDebugSettings[deviceKey];
+ }
}
public class DebugContextItem
@@ -59,7 +103,6 @@ namespace PepperDash.Core.DebugThings
[JsonProperty("doNotLoadOnNextBoot")]
public bool DoNotLoadOnNextBoot { get; set; }
-
public DebugContextItem(DebugContextCollection parent)
{
diff --git a/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj b/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj
index 92ce8c8..d4fbf18 100644
--- a/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj
+++ b/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj
@@ -69,6 +69,7 @@
+
diff --git a/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoToSimpl.cs b/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoToSimpl.cs
index 80c8246..1d58a80 100644
--- a/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoToSimpl.cs
+++ b/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoToSimpl.cs
@@ -432,6 +432,7 @@ namespace PepperDash.Core.SystemInfo
protected void OnProgramChange(ProgramInfo program, ushort index, ushort type)
{
var handler = ProgramChange;
+
if (handler != null)
{
var args = new ProgramChangeEventArgs(program, type);