From 01afc3523e6b1e30555e55ee7f99e9eff11badeb Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Mon, 13 May 2024 08:22:52 -0700 Subject: [PATCH 01/16] updating the fix nuget feeds to optionally restore with a solution file --- .github/Composite-Actions/Fix-Nuget-Feeds/action.yml | 11 +++++++++++ Powershell/Scripts/set-nugetfeeds.ps1 | 11 ++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml b/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml index 3feca0e..e7ab8d0 100644 --- a/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml +++ b/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml @@ -14,6 +14,9 @@ inputs: PROGET_API_KEY: description: 'API key for NuGet.' required: true + SOLUTION_FILE: + description: 'Optional Solution File if you want to run a restore' + required: false runs: using: 'composite' steps: @@ -24,7 +27,15 @@ runs: nuget-api-key: ${{ inputs.PROGET_API_KEY }} - name: test then run set-nugetfeeds.ps1 + if: inputs.SOLUTION_FILE == null run: | ${{ github.action_path }}/../../../Powershell/Scripts\set-nugetfeeds.ps1 -nugetPublish "${{ inputs.NUGET_PUBLISH }}" -nugetSource "${{ inputs.NUGET_SOURCE }}" -nugetLibrary "${{ inputs.NUGET_LIBRARY }}" -nugetApiKey "${{ inputs.PROGET_API_KEY }}" -nugetConfigFullPath "${{ github.workspace }}\nuget.config" + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" + + - name: test then run set-nugetfeeds.ps1 + if: inputs.SOLUTION_FILE + run: | + ${{ github.action_path }}/../../../Powershell/Scripts\set-nugetfeeds.ps1 -nugetPublish "${{ inputs.NUGET_PUBLISH }}" -nugetSource "${{ inputs.NUGET_SOURCE }}" -nugetLibrary "${{ inputs.NUGET_LIBRARY }}" -nugetApiKey "${{ inputs.PROGET_API_KEY }}" -nugetConfigFullPath "${{ github.workspace }}\nuget.config" -solutionFile ${{ inputs.SOLUTION_FILE }} shell: | pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" \ No newline at end of file diff --git a/Powershell/Scripts/set-nugetfeeds.ps1 b/Powershell/Scripts/set-nugetfeeds.ps1 index 96706dc..0d1b293 100644 --- a/Powershell/Scripts/set-nugetfeeds.ps1 +++ b/Powershell/Scripts/set-nugetfeeds.ps1 @@ -15,6 +15,9 @@ param ( [parameter(Mandatory=$true)] [string] $nugetApiKey, + [parameter(Mandatory=$false)] + [string] + $solutionFile, [parameter()] [string] $nugetConfigFullPath = "$env:GITHUB_WORKSPACE\nuget.config" @@ -65,6 +68,8 @@ write-output "display nuget sources detailed verbosity" # Display NuGet sources with detailed verbosity nuget.exe source -Verbosity detailed -write-output "nuget restore" -# Nuget Restore -nuget.exe restore Cogstate.Platform\Cogstate.Platform.sln -force -recursive -ConfigFile $nugetConfigFullPath -Verbosity detailed \ No newline at end of file +if($null -ne $solutionFile){ + write-output "SolutionFile supplied, running the nuget restore" + # Nuget Restore + nuget.exe restore $env:GITHUB_WORKSPACE\$soultionFile -force -recursive -ConfigFile $nugetConfigFullPath -Verbosity detailed +} \ No newline at end of file From e24cd82f44ae79250f4b2c7a7429a71971bb7d3c Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Mon, 13 May 2024 08:37:23 -0700 Subject: [PATCH 02/16] adding some logic to checking the solution file, it tried to run it even though it was not provided. --- .github/Composite-Actions/Fix-Nuget-Feeds/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml b/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml index e7ab8d0..6752fca 100644 --- a/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml +++ b/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml @@ -27,14 +27,14 @@ runs: nuget-api-key: ${{ inputs.PROGET_API_KEY }} - name: test then run set-nugetfeeds.ps1 - if: inputs.SOLUTION_FILE == null + if: inputs.SOLUTION_FILE == null || inputs.SOLUTION_FILE == '' run: | ${{ github.action_path }}/../../../Powershell/Scripts\set-nugetfeeds.ps1 -nugetPublish "${{ inputs.NUGET_PUBLISH }}" -nugetSource "${{ inputs.NUGET_SOURCE }}" -nugetLibrary "${{ inputs.NUGET_LIBRARY }}" -nugetApiKey "${{ inputs.PROGET_API_KEY }}" -nugetConfigFullPath "${{ github.workspace }}\nuget.config" shell: | pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" - name: test then run set-nugetfeeds.ps1 - if: inputs.SOLUTION_FILE + if: inputs.SOLUTION_FILE && inputs.SOLUTION_FILE != '' run: | ${{ github.action_path }}/../../../Powershell/Scripts\set-nugetfeeds.ps1 -nugetPublish "${{ inputs.NUGET_PUBLISH }}" -nugetSource "${{ inputs.NUGET_SOURCE }}" -nugetLibrary "${{ inputs.NUGET_LIBRARY }}" -nugetApiKey "${{ inputs.PROGET_API_KEY }}" -nugetConfigFullPath "${{ github.workspace }}\nuget.config" -solutionFile ${{ inputs.SOLUTION_FILE }} shell: | From 5cf809de4370a8ad7a00864b094f8fce683eb7e1 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Mon, 13 May 2024 09:12:37 -0700 Subject: [PATCH 03/16] adding write-output to print the contents of the solution file as it seems to not be null. --- Powershell/Scripts/set-nugetfeeds.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Powershell/Scripts/set-nugetfeeds.ps1 b/Powershell/Scripts/set-nugetfeeds.ps1 index 0d1b293..7d8cd34 100644 --- a/Powershell/Scripts/set-nugetfeeds.ps1 +++ b/Powershell/Scripts/set-nugetfeeds.ps1 @@ -70,6 +70,7 @@ nuget.exe source -Verbosity detailed if($null -ne $solutionFile){ write-output "SolutionFile supplied, running the nuget restore" + write-output "Contents of the solutionfile variable: $solutionFile" # Nuget Restore nuget.exe restore $env:GITHUB_WORKSPACE\$soultionFile -force -recursive -ConfigFile $nugetConfigFullPath -Verbosity detailed } \ No newline at end of file From 8df118f27571c5807e00a23e169ab08b1663e33f Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Mon, 13 May 2024 09:17:23 -0700 Subject: [PATCH 04/16] changing the comparison operator to an is nullorempty method. --- Powershell/Scripts/set-nugetfeeds.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Powershell/Scripts/set-nugetfeeds.ps1 b/Powershell/Scripts/set-nugetfeeds.ps1 index 7d8cd34..9dd6eb8 100644 --- a/Powershell/Scripts/set-nugetfeeds.ps1 +++ b/Powershell/Scripts/set-nugetfeeds.ps1 @@ -68,7 +68,7 @@ write-output "display nuget sources detailed verbosity" # Display NuGet sources with detailed verbosity nuget.exe source -Verbosity detailed -if($null -ne $solutionFile){ +if(!([string]::IsNullOrEmpty($solutionFile))){ write-output "SolutionFile supplied, running the nuget restore" write-output "Contents of the solutionfile variable: $solutionFile" # Nuget Restore From ab04c75502c284ce8eec63690dcfc003a9452ab8 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Mon, 13 May 2024 10:28:52 -0700 Subject: [PATCH 05/16] adding ${{ }} to evaluate the if statement as an expression. --- .github/Composite-Actions/Fix-Nuget-Feeds/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml b/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml index 6752fca..408521f 100644 --- a/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml +++ b/.github/Composite-Actions/Fix-Nuget-Feeds/action.yml @@ -27,14 +27,14 @@ runs: nuget-api-key: ${{ inputs.PROGET_API_KEY }} - name: test then run set-nugetfeeds.ps1 - if: inputs.SOLUTION_FILE == null || inputs.SOLUTION_FILE == '' + if: ${{ inputs.SOLUTION_FILE == null || inputs.SOLUTION_FILE == '' }} run: | ${{ github.action_path }}/../../../Powershell/Scripts\set-nugetfeeds.ps1 -nugetPublish "${{ inputs.NUGET_PUBLISH }}" -nugetSource "${{ inputs.NUGET_SOURCE }}" -nugetLibrary "${{ inputs.NUGET_LIBRARY }}" -nugetApiKey "${{ inputs.PROGET_API_KEY }}" -nugetConfigFullPath "${{ github.workspace }}\nuget.config" shell: | pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" - name: test then run set-nugetfeeds.ps1 - if: inputs.SOLUTION_FILE && inputs.SOLUTION_FILE != '' + if: ${{ inputs.SOLUTION_FILE && inputs.SOLUTION_FILE != ''}} run: | ${{ github.action_path }}/../../../Powershell/Scripts\set-nugetfeeds.ps1 -nugetPublish "${{ inputs.NUGET_PUBLISH }}" -nugetSource "${{ inputs.NUGET_SOURCE }}" -nugetLibrary "${{ inputs.NUGET_LIBRARY }}" -nugetApiKey "${{ inputs.PROGET_API_KEY }}" -nugetConfigFullPath "${{ github.workspace }}\nuget.config" -solutionFile ${{ inputs.SOLUTION_FILE }} shell: | From 1f906b2ba51bc6713f04759f8a2c3df71b0a02e6 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Mon, 13 May 2024 18:16:08 -0700 Subject: [PATCH 06/16] adding build-status and changing set-branch-variables to use pwsh and lowercase the strings. --- .../Composite-Actions/Build-Status/action.yml | 24 +++++++ .../Set-Branch-Variables/action.yml | 70 +++++++++---------- 2 files changed, 59 insertions(+), 35 deletions(-) create mode 100644 .github/Composite-Actions/Build-Status/action.yml diff --git a/.github/Composite-Actions/Build-Status/action.yml b/.github/Composite-Actions/Build-Status/action.yml new file mode 100644 index 0000000..1d3fb4b --- /dev/null +++ b/.github/Composite-Actions/Build-Status/action.yml @@ -0,0 +1,24 @@ +name: 'Build Status' +description: 'Tags repostitory and shows the build status' +author: 'Mike Burgess' +inputs: + VERSION: + description: 'Version for tagging' + required: true + +runs: + using: 'composite' + + steps: + - name: Checkout files on agent + uses: actions/checkout@v3 + + - name: Tagging repostitory + run: | + git tag ${{ inputs.VERSION }} + git push origin ${{ inputs.VERSION }} + shell: bash + + - name: Show build success + run: echo "The build ${{ inputs.VERSION }} successfully completed" + shell: bash \ No newline at end of file diff --git a/.github/Composite-Actions/Set-Branch-Variables/action.yml b/.github/Composite-Actions/Set-Branch-Variables/action.yml index fb1e641..2b1165a 100644 --- a/.github/Composite-Actions/Set-Branch-Variables/action.yml +++ b/.github/Composite-Actions/Set-Branch-Variables/action.yml @@ -58,19 +58,19 @@ runs: id: set-dev-variables if: contains(inputs.BRANCH_NAME,'feature') run: | - echo "BUILD_TYPE=dev" >> $GITHUB_ENV - echo "BUILD_CONFIG=Debug" >> $GITHUB_ENV - echo "NUGET_PUBLISH=https://proget.cogstate.com/nuget/cogstate-releases-dev/" >> $GITHUB_ENV - echo "NUGET_SOURCE=https://proget.cogstate.com/nuget/nuget-dev/" >> $GITHUB_ENV - echo "NUGET_LIBRARY=https://proget.cogstate.com/nuget/cogstate-library-nuget-dev/" >> $GITHUB_ENV - shell: bash + Write-Output $("BUILD_TYPE=dev").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output $("BUILD_TYPE=Debug").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output $("NUGET_PUBLISH=https://proget.cogstate.com/nuget/cogstate-releases-dev/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output $("NUGET_SOURCE=https://proget.cogstate.com/nuget/nuget-dev/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output $("NUGET_LIBRARY=https://proget.cogstate.com/nuget/cogstate-library-nuget-dev/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh - name: Set dev version id: set-dev-version if: contains(inputs.BRANCH_NAME,'feature') run: | - echo "preversion=${{ steps.branch-regex.outputs.group1 }}-${{ env.BUILD_TYPE }}.${{ steps.branch-regex.outputs.group2 }}.${{ github.run_number }}${{ github.run_attempt }}" >> $GITHUB_ENV - shell: bash + Write-Output $("preversion=${{ steps.branch-regex.outputs.group1 }}-${{ env.BUILD_TYPE }}.${{ steps.branch-regex.outputs.group2 }}.${{ github.run_number }}${{ github.run_attempt }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh #Set the RC Variables if the branch contains release @@ -78,19 +78,19 @@ runs: id: set-rc-variables if: contains(inputs.BRANCH_NAME,'release') run: | - echo "BUILD_TYPE=rc" >> $GITHUB_ENV - echo "BUILD_CONFIG=Release" >> $GITHUB_ENV - echo "NUGET_PUBLISH=https://proget.cogstate.com/nuget/cogstate-releases-candidate/" >> $GITHUB_ENV - echo "NUGET_SOURCE=https://proget.cogstate.com/nuget/nuget-dev/" >> $GITHUB_ENV - echo "NUGET_LIBRARY=https://proget.cogstate.com/nuget/cogstate-library-nuget/" >> $GITHUB_ENV - shell: bash + Write-Output $("BUILD_TYPE=rc").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output $("BUILD_CONFIG=Release").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output $("NUGET_PUBLISH=https://proget.cogstate.com/nuget/cogstate-releases-candidate/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output $("NUGET_SOURCE=https://proget.cogstate.com/nuget/nuget-dev/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output $("NUGET_LIBRARY=https://proget.cogstate.com/nuget/cogstate-library-nuget/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh - name: Set rc version id: set-rc-version if: contains(inputs.BRANCH_NAME,'release') run: | - echo "preversion=${{ steps.branch-regex.outputs.group1 }}-${{ env.BUILD_TYPE }}.${{ github.run_number }}${{ github.run_attempt }}" >> $GITHUB_ENV - shell: bash + Write-Output $("preversion=${{ steps.branch-regex.outputs.group1 }}-${{ env.BUILD_TYPE }}.${{ github.run_number }}${{ github.run_attempt }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh #Override the publish variables if they are provided as inputs @@ -98,15 +98,15 @@ runs: id: override-nuget-publish if: inputs.NUGET_PUBLISH_OVERRIDE && contains(inputs.BRANCH_NAME,'release') run: | - echo "NUGET_PUBLISH=${{ inputs.NUGET_PUBLISH_OVERRIDE }}" >> $GITHUB_ENV - shell: bash + Write-Output $("NUGET_PUBLISH=${{ inputs.NUGET_PUBLISH_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh - name: Override Nuget Dev Publish id: override-nuget-dev-publish if: inputs.NUGET_PUBLISH_DEV_OVERRIDE && contains(inputs.BRANCH_NAME,'feature') run: | - echo "NUGET_PUBLISH=${{ inputs.NUGET_PUBLISH_DEV_OVERRIDE }}" >> $GITHUB_ENV - shell: bash + Write-Output $("NUGET_PUBLISH=${{ inputs.NUGET_PUBLISH_DEV_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh #Override the Nuget Library variables if they are provided as inputs @@ -114,15 +114,15 @@ runs: id: override-nuget-library if: inputs.NUGET_LIBRARY_OVERRIDE && contains(inputs.BRANCH_NAME,'release') run: | - echo "NUGET_LIBRARY=${{ inputs.NUGET_LIBRARY_OVERRIDE }}" >> $GITHUB_ENV - shell: bash + Write-Output $("NUGET_LIBRARY=${{ inputs.NUGET_LIBRARY_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh - name: Override Nuget Dev Library id: override-nuget-dev-library if: inputs.NUGET_LIBRARY_DEV_OVERRIDE && contains(inputs.BRANCH_NAME,'feature') run: | - echo "NUGET_LIBRARY=${{ inputs.NUGET_LIBRARY_DEV_OVERRIDE }}" >> $GITHUB_ENV - shell: bash + Write-Output $("NUGET_LIBRARY=${{ inputs.NUGET_LIBRARY_DEV_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh #Override the Nuget Source variables if they are provided as inputs @@ -130,23 +130,23 @@ runs: id: override-nuget-source if: inputs.NUGET_SOURCE_OVERRIDE && contains(inputs.BRANCH_NAME,'release') run: | - echo "NUGET_SOURCE=${{ inputs.NUGET_SOURCE_OVERRIDE }}" >> $GITHUB_ENV - shell: bash + Write-Output $("NUGET_SOURCE=${{ inputs.NUGET_SOURCE_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh - name: Override Nuget Dev Source id: override-nuget-dev-source if: inputs.NUGET_SOURCE_DEV_OVERRIDE && contains(inputs.BRANCH_NAME,'feature') run: | - echo "NUGET_SOURCE=${{ inputs.NUGET_SOURCE_DEV_OVERRIDE }}" >> $GITHUB_ENV - shell: bash + Write-Output $("NUGET_SOURCE=${{ inputs.NUGET_SOURCE_DEV_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh - name: Set output variables id: set-vars run: | - echo "version=${{ env.preversion }}" >> $GITHUB_OUTPUT - echo "build-config=${{ env.BUILD_CONFIG }}" >> $GITHUB_OUTPUT - echo "build-type=${{ env.BUILD_TYPE }}" >> $GITHUB_OUTPUT - echo "nuget-publish=${{ env.NUGET_PUBLISH }}" >> $GITHUB_OUTPUT - echo "nuget-source=${{ env.NUGET_SOURCE }}" >> $GITHUB_OUTPUT - echo "nuget-library=${{ env.NUGET_LIBRARY }}" >> $GITHUB_OUTPUT - shell: bash + Write-Output $("version=${{ env.preversion }}").tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output $("build-config=${{ env.BUILD_CONFIG }}").tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output $("build-type=${{ env.BUILD_TYPE }}").tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output $("nuget-publish=${{ env.NUGET_PUBLISH }}").tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output $("nuget-source=${{ env.NUGET_SOURCE }}".tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output $("nuget-library=${{ env.NUGET_LIBRARY }}".tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + shell: pwsh From d16741f19e97a68ccd2ef7cd3a953af6ed52f74f Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Tue, 14 May 2024 07:37:43 -0700 Subject: [PATCH 07/16] updating to lowercase the version and use powershell. --- .../Set-Branch-Variables/action.yml | 92 ++++++++++++------- 1 file changed, 57 insertions(+), 35 deletions(-) diff --git a/.github/Composite-Actions/Set-Branch-Variables/action.yml b/.github/Composite-Actions/Set-Branch-Variables/action.yml index 2b1165a..218ee5c 100644 --- a/.github/Composite-Actions/Set-Branch-Variables/action.yml +++ b/.github/Composite-Actions/Set-Branch-Variables/action.yml @@ -58,19 +58,27 @@ runs: id: set-dev-variables if: contains(inputs.BRANCH_NAME,'feature') run: | - Write-Output $("BUILD_TYPE=dev").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output $("BUILD_TYPE=Debug").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output $("NUGET_PUBLISH=https://proget.cogstate.com/nuget/cogstate-releases-dev/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output $("NUGET_SOURCE=https://proget.cogstate.com/nuget/nuget-dev/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output $("NUGET_LIBRARY=https://proget.cogstate.com/nuget/cogstate-library-nuget-dev/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + Write-Output "BUILD_TYPE=dev" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "BUILD_CONFIG=Debug" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "NUGET_PUBLISH=https://proget.cogstate.com/nuget/cogstate-releases-dev/" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "NUGET_SOURCE=https://proget.cogstate.com/nuget/nuget-dev/" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "NUGET_LIBRARY=https://proget.cogstate.com/nuget/cogstate-library-nuget-dev/" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" - name: Set dev version id: set-dev-version if: contains(inputs.BRANCH_NAME,'feature') run: | - Write-Output $("preversion=${{ steps.branch-regex.outputs.group1 }}-${{ env.BUILD_TYPE }}.${{ steps.branch-regex.outputs.group2 }}.${{ github.run_number }}${{ github.run_attempt }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + $BranchRegexGroup1 = $(${{ steps.branch-regex.outputs.group1 }}).tolower() + $BuildType = $(${{ env.BUILD_TYPE }}).tolower() + $BranchRegexGroup2 = $(${{ steps.branch-regex.outputs.group2 }}).tolower() + $GitHubRunNumber = $(${{ github.run_number }}).tolower() + $GitHubRunAttempt= $(${{ github.run_attempt }}).tolower() + + Write-Output "preversion=$BranchRegex-$BuildType.$BranchRegexGroup2.$GithubRunNumber$GitHubRunAttempt" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" #Set the RC Variables if the branch contains release @@ -78,19 +86,26 @@ runs: id: set-rc-variables if: contains(inputs.BRANCH_NAME,'release') run: | - Write-Output $("BUILD_TYPE=rc").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output $("BUILD_CONFIG=Release").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output $("NUGET_PUBLISH=https://proget.cogstate.com/nuget/cogstate-releases-candidate/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output $("NUGET_SOURCE=https://proget.cogstate.com/nuget/nuget-dev/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Write-Output $("NUGET_LIBRARY=https://proget.cogstate.com/nuget/cogstate-library-nuget/").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + Write-Output "BUILD_TYPE=rc" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "BUILD_CONFIG=Release" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "NUGET_PUBLISH=https://proget.cogstate.com/nuget/cogstate-releases-candidate/" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "NUGET_SOURCE=https://proget.cogstate.com/nuget/nuget-dev/" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "NUGET_LIBRARY=https://proget.cogstate.com/nuget/cogstate-library-nuget/" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" - name: Set rc version id: set-rc-version if: contains(inputs.BRANCH_NAME,'release') run: | - Write-Output $("preversion=${{ steps.branch-regex.outputs.group1 }}-${{ env.BUILD_TYPE }}.${{ github.run_number }}${{ github.run_attempt }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + $BranchRegexGroup1 = $(${{ steps.branch-regex.outputs.group1 }}).tolower() + $BuildType = $(${{ env.BUILD_TYPE }}).tolower() + $GitHubRunNumber = $(${{ github.run_number }}).tolower() + $GitHubRunAttempt= $(${{ github.run_attempt }}).tolower() + + Write-Output "preversion=$BranchRegexGroup1-$BuildType.$GitHubRunNumber$GitHubRunAttempt" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" #Override the publish variables if they are provided as inputs @@ -98,15 +113,17 @@ runs: id: override-nuget-publish if: inputs.NUGET_PUBLISH_OVERRIDE && contains(inputs.BRANCH_NAME,'release') run: | - Write-Output $("NUGET_PUBLISH=${{ inputs.NUGET_PUBLISH_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + Write-Output "NUGET_PUBLISH=${{ inputs.NUGET_PUBLISH_OVERRIDE }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" - name: Override Nuget Dev Publish id: override-nuget-dev-publish if: inputs.NUGET_PUBLISH_DEV_OVERRIDE && contains(inputs.BRANCH_NAME,'feature') run: | - Write-Output $("NUGET_PUBLISH=${{ inputs.NUGET_PUBLISH_DEV_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + Write-Output "NUGET_PUBLISH=${{ inputs.NUGET_PUBLISH_DEV_OVERRIDE }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" #Override the Nuget Library variables if they are provided as inputs @@ -114,15 +131,17 @@ runs: id: override-nuget-library if: inputs.NUGET_LIBRARY_OVERRIDE && contains(inputs.BRANCH_NAME,'release') run: | - Write-Output $("NUGET_LIBRARY=${{ inputs.NUGET_LIBRARY_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + Write-Output "NUGET_LIBRARY=${{ inputs.NUGET_LIBRARY_OVERRIDE }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" - name: Override Nuget Dev Library id: override-nuget-dev-library if: inputs.NUGET_LIBRARY_DEV_OVERRIDE && contains(inputs.BRANCH_NAME,'feature') run: | - Write-Output $("NUGET_LIBRARY=${{ inputs.NUGET_LIBRARY_DEV_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + Write-Output "NUGET_LIBRARY=${{ inputs.NUGET_LIBRARY_DEV_OVERRIDE }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" #Override the Nuget Source variables if they are provided as inputs @@ -130,23 +149,26 @@ runs: id: override-nuget-source if: inputs.NUGET_SOURCE_OVERRIDE && contains(inputs.BRANCH_NAME,'release') run: | - Write-Output $("NUGET_SOURCE=${{ inputs.NUGET_SOURCE_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + Write-Output "NUGET_SOURCE=${{ inputs.NUGET_SOURCE_OVERRIDE }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" - name: Override Nuget Dev Source id: override-nuget-dev-source if: inputs.NUGET_SOURCE_DEV_OVERRIDE && contains(inputs.BRANCH_NAME,'feature') run: | - Write-Output $("NUGET_SOURCE=${{ inputs.NUGET_SOURCE_DEV_OVERRIDE }}").tolower() | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - shell: pwsh + Write-Output "NUGET_SOURCE=${{ inputs.NUGET_SOURCE_DEV_OVERRIDE }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" - name: Set output variables id: set-vars run: | - Write-Output $("version=${{ env.preversion }}").tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - Write-Output $("build-config=${{ env.BUILD_CONFIG }}").tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - Write-Output $("build-type=${{ env.BUILD_TYPE }}").tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - Write-Output $("nuget-publish=${{ env.NUGET_PUBLISH }}").tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - Write-Output $("nuget-source=${{ env.NUGET_SOURCE }}".tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - Write-Output $("nuget-library=${{ env.NUGET_LIBRARY }}".tolower() | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - shell: pwsh + Write-Output "version=${{ env.preversion }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output "build-config=${{ env.BUILD_CONFIG }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output "build-type=${{ env.BUILD_TYPE }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output "nuget-publish=${{ env.NUGET_PUBLISH }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output "nuget-source=${{ env.NUGET_SOURCE }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output "nuget-library=${{ env.NUGET_LIBRARY }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" From 27842203d91eaf7fb75319616948497fc3115777 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Tue, 14 May 2024 07:54:19 -0700 Subject: [PATCH 08/16] double quoting the input variables so that powershell recognizes them as a string. --- .../Set-Branch-Variables/action.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/Composite-Actions/Set-Branch-Variables/action.yml b/.github/Composite-Actions/Set-Branch-Variables/action.yml index 218ee5c..83cb3ee 100644 --- a/.github/Composite-Actions/Set-Branch-Variables/action.yml +++ b/.github/Composite-Actions/Set-Branch-Variables/action.yml @@ -70,11 +70,11 @@ runs: id: set-dev-version if: contains(inputs.BRANCH_NAME,'feature') run: | - $BranchRegexGroup1 = $(${{ steps.branch-regex.outputs.group1 }}).tolower() - $BuildType = $(${{ env.BUILD_TYPE }}).tolower() - $BranchRegexGroup2 = $(${{ steps.branch-regex.outputs.group2 }}).tolower() - $GitHubRunNumber = $(${{ github.run_number }}).tolower() - $GitHubRunAttempt= $(${{ github.run_attempt }}).tolower() + $BranchRegexGroup1 = $("${{ steps.branch-regex.outputs.group1 }}").tolower() + $BuildType = $("${{ env.BUILD_TYPE }}").tolower() + $BranchRegexGroup2 = $("${{ steps.branch-regex.outputs.group2 }}").tolower() + $GitHubRunNumber = $("${{ github.run_number }}").tolower() + $GitHubRunAttempt= $("${{ github.run_attempt }}").tolower() Write-Output "preversion=$BranchRegex-$BuildType.$BranchRegexGroup2.$GithubRunNumber$GitHubRunAttempt" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append shell: | @@ -98,10 +98,10 @@ runs: id: set-rc-version if: contains(inputs.BRANCH_NAME,'release') run: | - $BranchRegexGroup1 = $(${{ steps.branch-regex.outputs.group1 }}).tolower() - $BuildType = $(${{ env.BUILD_TYPE }}).tolower() - $GitHubRunNumber = $(${{ github.run_number }}).tolower() - $GitHubRunAttempt= $(${{ github.run_attempt }}).tolower() + $BranchRegexGroup1 = $("${{ steps.branch-regex.outputs.group1 }}").tolower() + $BuildType = $("${{ env.BUILD_TYPE }}").tolower() + $GitHubRunNumber = $("${{ github.run_number }}").tolower() + $GitHubRunAttempt= $("${{ github.run_attempt }}").tolower() Write-Output "preversion=$BranchRegexGroup1-$BuildType.$GitHubRunNumber$GitHubRunAttempt" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append shell: | From 8ec8e6494552096149ab15f4bbff4efffa201d87 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Tue, 14 May 2024 08:12:59 -0700 Subject: [PATCH 09/16] I messed up a variable, it was unused (wish there was a hybrid file type it knows it's github action yaml but doesn't provide gui interface for the powershell sections) --- .github/Composite-Actions/Set-Branch-Variables/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/Composite-Actions/Set-Branch-Variables/action.yml b/.github/Composite-Actions/Set-Branch-Variables/action.yml index 83cb3ee..be21129 100644 --- a/.github/Composite-Actions/Set-Branch-Variables/action.yml +++ b/.github/Composite-Actions/Set-Branch-Variables/action.yml @@ -76,7 +76,7 @@ runs: $GitHubRunNumber = $("${{ github.run_number }}").tolower() $GitHubRunAttempt= $("${{ github.run_attempt }}").tolower() - Write-Output "preversion=$BranchRegex-$BuildType.$BranchRegexGroup2.$GithubRunNumber$GitHubRunAttempt" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "preversion=$BranchRegexGroup1-$BuildType.$BranchRegexGroup2.$GithubRunNumber$GitHubRunAttempt" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append shell: | pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" From 2804656f3ce214cbca20bb3d7929f158d78741eb Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Tue, 14 May 2024 08:24:09 -0700 Subject: [PATCH 10/16] adding write outputs as the tolower() doesn't seem to work. --- .../Composite-Actions/Set-Branch-Variables/action.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/Composite-Actions/Set-Branch-Variables/action.yml b/.github/Composite-Actions/Set-Branch-Variables/action.yml index be21129..3b054cd 100644 --- a/.github/Composite-Actions/Set-Branch-Variables/action.yml +++ b/.github/Composite-Actions/Set-Branch-Variables/action.yml @@ -76,6 +76,12 @@ runs: $GitHubRunNumber = $("${{ github.run_number }}").tolower() $GitHubRunAttempt= $("${{ github.run_attempt }}").tolower() + Write-Output "Branch Regex Group 1: $BranchRegexGroup1" + Write-Output "Build Type: $BuildType" + Write-Output "Branch Regex Group 2: $BranchRegexGroup2" + Write-Output "GitHubRunNumber: $GitHubRunNumber" + Write-Output "GitHubRunAttempt: $GitHubRunAttempt" + Write-Output "preversion=$BranchRegexGroup1-$BuildType.$BranchRegexGroup2.$GithubRunNumber$GitHubRunAttempt" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append shell: | pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" @@ -103,6 +109,11 @@ runs: $GitHubRunNumber = $("${{ github.run_number }}").tolower() $GitHubRunAttempt= $("${{ github.run_attempt }}").tolower() + Write-Output "Branch Regex Group 1: $BranchRegexGroup1" + Write-Output "Build Type: $BuildType" + Write-Output "GitHubRunNumber: $GitHubRunNumber" + Write-Output "GitHubRunAttempt: $GitHubRunAttempt" + Write-Output "preversion=$BranchRegexGroup1-$BuildType.$GitHubRunNumber$GitHubRunAttempt" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append shell: | pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" From 677216bc74ccfe65676468139b3184f74898fe28 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Thu, 16 May 2024 16:04:16 -0700 Subject: [PATCH 11/16] Adding a funciton to version-control.psm1 Calling the function in new script set-versions-json.ps1 Adding a composite workflow to call this. This is to create a versions file from the version variable. --- .../Create-Versions-Json/action.yml | 19 ++++++ Powershell/Modules/Version-Control.psm1 | 58 ++++++++++++++++++- Powershell/Scripts/Set-Versions-Json.ps1 | 42 ++++++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 .github/Composite-Actions/Create-Versions-Json/action.yml create mode 100644 Powershell/Scripts/Set-Versions-Json.ps1 diff --git a/.github/Composite-Actions/Create-Versions-Json/action.yml b/.github/Composite-Actions/Create-Versions-Json/action.yml new file mode 100644 index 0000000..359dfb9 --- /dev/null +++ b/.github/Composite-Actions/Create-Versions-Json/action.yml @@ -0,0 +1,19 @@ +name: 'Create Versions Json' +description: 'Creates a versions.json file' +author: 'Mike Burgess' +inputs: + VERSION: + description: 'Version generated from Set-Branch-Variables' + required: true +runs: + using: 'composite' + steps: + - name: Checkout files on agent + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: test then run set-nugetfeeds.ps1 + run: | + ${{ github.action_path }}/../../../Powershell/Scripts\Set-Versions-Json.ps1 -version ${{ inputs.VERSION }} + shell: | + pwsh -noninteractive -command "try {{ $ErrorActionPreference='Stop'; . '{0}' }} catch {{ Write-Error ""FAILED: $_""; throw; }} if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) {{ exit $LASTEXITCODE }}" \ No newline at end of file diff --git a/Powershell/Modules/Version-Control.psm1 b/Powershell/Modules/Version-Control.psm1 index a36a9f0..da8d141 100644 --- a/Powershell/Modules/Version-Control.psm1 +++ b/Powershell/Modules/Version-Control.psm1 @@ -400,4 +400,60 @@ function Invoke-ConfigTransformation { Write-Host "Transformation failed." exit 1 } -} \ No newline at end of file +} + +function New-VersionsJson { + param ( + [string]$version + ) + + + # Example of calling the function + # $versionString = "6.0.0-rc.cgm-381.7711" + # New-VersionJson -version $versionString + + # Extract major, minor, and patch parts + $major, $minor, $patchSection = $version -split '\.', 3 + + # Initialize default values + $patch = "0" + $revision = "0" + $semanticPart = "" + + # Extract semantic part and the patch and revision numbers + if ($patchSection -match '^(.*?)-(\d+)\.(\d+)$') { + $semanticPart = $matches[1] + $revision = $matches[2] + $patch = $matches[3] + } elseif ($patchSection -match '^(.*?)-(\d+)\.(\d+)$') { + $semanticPart = $matches[1] + $revision = $matches[2] + $patch = $matches[3] + } else { + $patch = $patchSection + $revision = "0" + } + + # Construct the JSON object with ordered properties + $jsonObject = [PSCustomObject]@{ + "cogstate.version.major" = $major + "cogstate.version.minor" = $minor + "cogstate.version.patch" = $patch + "cogstate.version.revision" = "0" + "cogstate.version.semantic2" = $version + "cogstate.version.semantic2.normalized" = "$major.$minor.0-$semanticPart.-$revision.$patch" + "cogstate.version.simple" = "$major.$minor.0.$patch" + } + + # Convert to JSON + $jsonString = $jsonObject | ConvertTo-Json -Depth 3 + + # Save to a file + $outputFile = "versions.json" + $jsonString | Out-File -FilePath $outputFile + + Write-Output "JSON content saved to $outputFile" +} + + + diff --git a/Powershell/Scripts/Set-Versions-Json.ps1 b/Powershell/Scripts/Set-Versions-Json.ps1 new file mode 100644 index 0000000..de5e6aa --- /dev/null +++ b/Powershell/Scripts/Set-Versions-Json.ps1 @@ -0,0 +1,42 @@ +[CmdletBinding()] +param ( + [parameter(Mandatory=$true)] + [String] + $Version +) + +$WarningPreference = "Continue" +$ErrorActionPreference = "Stop" +$VerbosePreference = "Continue" +$DebugPreference = "Continue" + +trap +{ + Write-Error "$($_.Exception)`n`nActual Stack Trace:`n$($_.ScriptStackTrace)`n`nError Output Stack Trace:" + exit 1 +} + +$currentDirectory = Get-Location +Write-Output "Current Directory is: $currentDirectory" + +$parentDirectory = Join-Path -Path $currentDirectory -ChildPath ".." +Write-Output "Parent directory is: $parentDirectory" + +$modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 +if (-not $modulePath) { + Write-Output "Module path not found in current directory, going up a directory..." + $parentDirectory = Set-Location (Join-Path -Path $parentDirectory -ChildPath "..") + Write-Output "Parent directory is now: $parentDirectory" + $modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 +} + +if ($modulePath) { + Write-Output "Module path found: $($modulePath.FullName)" + Import-Module $modulePath.FullName +} else { + Write-Output "Module path not found. Exiting..." + Write-Error "Error: Module path is empty." + exit 2 +} + +New-VersionsJson -version $Version \ No newline at end of file From eb68349aed76889e3632c03e4b66902a6cb392cc Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Thu, 16 May 2024 16:31:04 -0700 Subject: [PATCH 12/16] removing some white space, it's saying it's not imporitng which is strange. --- Powershell/Modules/Version-Control.psm1 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Powershell/Modules/Version-Control.psm1 b/Powershell/Modules/Version-Control.psm1 index da8d141..a81909e 100644 --- a/Powershell/Modules/Version-Control.psm1 +++ b/Powershell/Modules/Version-Control.psm1 @@ -453,7 +453,4 @@ function New-VersionsJson { $jsonString | Out-File -FilePath $outputFile Write-Output "JSON content saved to $outputFile" -} - - - +} \ No newline at end of file From b55abbb6a4a82bbf469f9fa97831e910e32ebde7 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Fri, 17 May 2024 11:31:12 -0700 Subject: [PATCH 13/16] moving the file directory up then re importing the module rather than doing that complex search. --- Powershell/Scripts/Set-Versions-Json.ps1 | 58 ++++++++++++------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/Powershell/Scripts/Set-Versions-Json.ps1 b/Powershell/Scripts/Set-Versions-Json.ps1 index de5e6aa..ac07aba 100644 --- a/Powershell/Scripts/Set-Versions-Json.ps1 +++ b/Powershell/Scripts/Set-Versions-Json.ps1 @@ -10,33 +10,35 @@ $ErrorActionPreference = "Stop" $VerbosePreference = "Continue" $DebugPreference = "Continue" -trap -{ - Write-Error "$($_.Exception)`n`nActual Stack Trace:`n$($_.ScriptStackTrace)`n`nError Output Stack Trace:" - exit 1 -} - -$currentDirectory = Get-Location -Write-Output "Current Directory is: $currentDirectory" - -$parentDirectory = Join-Path -Path $currentDirectory -ChildPath ".." -Write-Output "Parent directory is: $parentDirectory" - -$modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 -if (-not $modulePath) { - Write-Output "Module path not found in current directory, going up a directory..." - $parentDirectory = Set-Location (Join-Path -Path $parentDirectory -ChildPath "..") - Write-Output "Parent directory is now: $parentDirectory" - $modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 -} - -if ($modulePath) { - Write-Output "Module path found: $($modulePath.FullName)" - Import-Module $modulePath.FullName -} else { - Write-Output "Module path not found. Exiting..." - Write-Error "Error: Module path is empty." - exit 2 -} +# trap +# { +# Write-Error "$($_.Exception)`n`nActual Stack Trace:`n$($_.ScriptStackTrace)`n`nError Output Stack Trace:" +# exit 1 +# } + +# $currentDirectory = Get-Location +# Write-Output "Current Directory is: $currentDirectory" + +# $parentDirectory = Join-Path -Path $currentDirectory -ChildPath ".." +# Write-Output "Parent directory is: $parentDirectory" + +# $modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 +# if (-not $modulePath) { +# Write-Output "Module path not found in current directory, going up a directory..." +# $parentDirectory = Set-Location (Join-Path -Path $parentDirectory -ChildPath "..") +# Write-Output "Parent directory is now: $parentDirectory" +# $modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 +# } + +# if ($modulePath) { +# Write-Output "Module path found: $($modulePath.FullName)" +# Import-Module $modulePath.FullName +# } else { +# Write-Output "Module path not found. Exiting..." +# Write-Error "Error: Module path is empty." +# exit 2 +# } + +Import-Module $PSScriptRoot\..\modules\Version-Control.psm1 New-VersionsJson -version $Version \ No newline at end of file From d94e8a324d1f9d58f1ae4aab173f61ef495c4c84 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Fri, 17 May 2024 12:30:40 -0700 Subject: [PATCH 14/16] cleaning up comments and fixing the directory pathing for Confirm-PreivousCommitsMerged.ps1 --- .../Scripts/Confirm-PreviousCommitsMerged.ps1 | 29 +------------------ Powershell/Scripts/Set-Versions-Json.ps1 | 29 ------------------- 2 files changed, 1 insertion(+), 57 deletions(-) diff --git a/Powershell/Scripts/Confirm-PreviousCommitsMerged.ps1 b/Powershell/Scripts/Confirm-PreviousCommitsMerged.ps1 index 2503796..58bf265 100644 --- a/Powershell/Scripts/Confirm-PreviousCommitsMerged.ps1 +++ b/Powershell/Scripts/Confirm-PreviousCommitsMerged.ps1 @@ -3,34 +3,7 @@ $ErrorActionPreference = "Stop" $VerbosePreference = "Continue" $DebugPreference = "Continue" -trap -{ - Write-Error "$($_.Exception)`n`nActual Stack Trace:`n$($_.ScriptStackTrace)`n`nError Output Stack Trace:" - exit 1 -} - -$currentDirectory = Get-Location -Write-Output "Current Directory is: $currentDirectory" - -$parentDirectory = Join-Path -Path $currentDirectory -ChildPath ".." -Write-Output "Parent directory is: $parentDirectory" - -$modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 -if (-not $modulePath) { - Write-Output "Module path not found in current directory, going up a directory..." - $parentDirectory = Set-Location (Join-Path -Path $parentDirectory -ChildPath "..") - Write-Output "Parent directory is now: $parentDirectory" - $modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 -} - -if ($modulePath) { - Write-Output "Module path found: $($modulePath.FullName)" - Import-Module $modulePath.FullName -} else { - Write-Output "Module path not found. Exiting..." - Write-Error "Error: Module path is empty." - exit 2 -} +Import-Module $PSScriptRoot\..\modules\Version-Control.psm1 VerifyAllGitDirectories diff --git a/Powershell/Scripts/Set-Versions-Json.ps1 b/Powershell/Scripts/Set-Versions-Json.ps1 index ac07aba..74c4966 100644 --- a/Powershell/Scripts/Set-Versions-Json.ps1 +++ b/Powershell/Scripts/Set-Versions-Json.ps1 @@ -10,35 +10,6 @@ $ErrorActionPreference = "Stop" $VerbosePreference = "Continue" $DebugPreference = "Continue" -# trap -# { -# Write-Error "$($_.Exception)`n`nActual Stack Trace:`n$($_.ScriptStackTrace)`n`nError Output Stack Trace:" -# exit 1 -# } - -# $currentDirectory = Get-Location -# Write-Output "Current Directory is: $currentDirectory" - -# $parentDirectory = Join-Path -Path $currentDirectory -ChildPath ".." -# Write-Output "Parent directory is: $parentDirectory" - -# $modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 -# if (-not $modulePath) { -# Write-Output "Module path not found in current directory, going up a directory..." -# $parentDirectory = Set-Location (Join-Path -Path $parentDirectory -ChildPath "..") -# Write-Output "Parent directory is now: $parentDirectory" -# $modulePath = Get-ChildItem $parentDirectory -Recurse -Filter "Version-Control.psm1" | Select-Object -First 1 -# } - -# if ($modulePath) { -# Write-Output "Module path found: $($modulePath.FullName)" -# Import-Module $modulePath.FullName -# } else { -# Write-Output "Module path not found. Exiting..." -# Write-Error "Error: Module path is empty." -# exit 2 -# } - Import-Module $PSScriptRoot\..\modules\Version-Control.psm1 New-VersionsJson -version $Version \ No newline at end of file From c27b63f7923590112c7dbaa8e069105030851522 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Tue, 21 May 2024 12:26:28 -0700 Subject: [PATCH 15/16] changing from nuget.exe to mono /usr/local/bin/nuget.exe to run on linux. --- Powershell/Scripts/run-nunit.ps1 | 2 +- Powershell/Scripts/set-nugetfeeds.ps1 | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Powershell/Scripts/run-nunit.ps1 b/Powershell/Scripts/run-nunit.ps1 index cc7d080..78251b1 100644 --- a/Powershell/Scripts/run-nunit.ps1 +++ b/Powershell/Scripts/run-nunit.ps1 @@ -23,7 +23,7 @@ param ( #install nunit Write-Output "installing nunit" -nuget.exe install NUnit -Version 4.0.1 -Source $nugetSource -OutputDirectory $PWD +mono /usr/local/bin/nuget.exe install NUnit -Version 4.0.1 -Source $nugetSource -OutputDirectory $PWD Write-Output "nunit installed complete" diff --git a/Powershell/Scripts/set-nugetfeeds.ps1 b/Powershell/Scripts/set-nugetfeeds.ps1 index 9dd6eb8..56b445a 100644 --- a/Powershell/Scripts/set-nugetfeeds.ps1 +++ b/Powershell/Scripts/set-nugetfeeds.ps1 @@ -58,19 +58,19 @@ $configContent | Set-Content -Path $nugetConfigFullPath # Update NuGet sources write-output "nuget source update proget" -nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget -Username api -Password $nugetApiKey +mono /usr/local/bin/nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget -Username api -Password $nugetApiKey write-output "nuget source update proget-lib" -nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget-lib -Username api -Password $nugetApiKey +mono /usr/local/bin/nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget-lib -Username api -Password $nugetApiKey write-output "nuget source update proget-deployable" -nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget-deployable -Username api -Password $nugetApiKey +mono /usr/local/bin/nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget-deployable -Username api -Password $nugetApiKey write-output "display nuget sources detailed verbosity" # Display NuGet sources with detailed verbosity -nuget.exe source -Verbosity detailed +mono /usr/local/bin/nuget.exe source -Verbosity detailed if(!([string]::IsNullOrEmpty($solutionFile))){ write-output "SolutionFile supplied, running the nuget restore" write-output "Contents of the solutionfile variable: $solutionFile" # Nuget Restore - nuget.exe restore $env:GITHUB_WORKSPACE\$soultionFile -force -recursive -ConfigFile $nugetConfigFullPath -Verbosity detailed + mono /usr/local/bin/nuget.exe restore $env:GITHUB_WORKSPACE\$soultionFile -force -recursive -ConfigFile $nugetConfigFullPath -Verbosity detailed } \ No newline at end of file From 2d152d54547b45bdcfc1b2ca27a0d9acbf6aedb6 Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Tue, 21 May 2024 12:33:10 -0700 Subject: [PATCH 16/16] changing back to use nuget.exe --- Powershell/Scripts/run-nunit.ps1 | 2 +- Powershell/Scripts/set-nugetfeeds.ps1 | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Powershell/Scripts/run-nunit.ps1 b/Powershell/Scripts/run-nunit.ps1 index 78251b1..cc7d080 100644 --- a/Powershell/Scripts/run-nunit.ps1 +++ b/Powershell/Scripts/run-nunit.ps1 @@ -23,7 +23,7 @@ param ( #install nunit Write-Output "installing nunit" -mono /usr/local/bin/nuget.exe install NUnit -Version 4.0.1 -Source $nugetSource -OutputDirectory $PWD +nuget.exe install NUnit -Version 4.0.1 -Source $nugetSource -OutputDirectory $PWD Write-Output "nunit installed complete" diff --git a/Powershell/Scripts/set-nugetfeeds.ps1 b/Powershell/Scripts/set-nugetfeeds.ps1 index 56b445a..9dd6eb8 100644 --- a/Powershell/Scripts/set-nugetfeeds.ps1 +++ b/Powershell/Scripts/set-nugetfeeds.ps1 @@ -58,19 +58,19 @@ $configContent | Set-Content -Path $nugetConfigFullPath # Update NuGet sources write-output "nuget source update proget" -mono /usr/local/bin/nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget -Username api -Password $nugetApiKey +nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget -Username api -Password $nugetApiKey write-output "nuget source update proget-lib" -mono /usr/local/bin/nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget-lib -Username api -Password $nugetApiKey +nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget-lib -Username api -Password $nugetApiKey write-output "nuget source update proget-deployable" -mono /usr/local/bin/nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget-deployable -Username api -Password $nugetApiKey +nuget.exe source update -ConfigFile "$nugetConfigFullPath" -Name proget-deployable -Username api -Password $nugetApiKey write-output "display nuget sources detailed verbosity" # Display NuGet sources with detailed verbosity -mono /usr/local/bin/nuget.exe source -Verbosity detailed +nuget.exe source -Verbosity detailed if(!([string]::IsNullOrEmpty($solutionFile))){ write-output "SolutionFile supplied, running the nuget restore" write-output "Contents of the solutionfile variable: $solutionFile" # Nuget Restore - mono /usr/local/bin/nuget.exe restore $env:GITHUB_WORKSPACE\$soultionFile -force -recursive -ConfigFile $nugetConfigFullPath -Verbosity detailed + nuget.exe restore $env:GITHUB_WORKSPACE\$soultionFile -force -recursive -ConfigFile $nugetConfigFullPath -Verbosity detailed } \ No newline at end of file