diff --git a/.github/workflows/PackageManagerClientMSbuild.yml b/.github/workflows/PackageManagerClientMSbuild.yml index 0de9aa1..a930dbd 100644 --- a/.github/workflows/PackageManagerClientMSbuild.yml +++ b/.github/workflows/PackageManagerClientMSbuild.yml @@ -23,7 +23,7 @@ jobs: - name: Look for PackageManagerClient run: | Write-Output "***Locating PackageManagerClient!***" - if (Test-Path -Path "${{ github.workspace }}\PackageManagerClient\bin\Debug\net6.0\Greg.dll") { + if (Test-Path -Path "${{ github.workspace }}\PackageManagerClient\bin\Debug\net8.0\Greg.dll") { Write-Output "PackageManagerClient exists!" } else { Write-Error "PackageManagerClient was not found!" diff --git a/CHANGELOG.md b/CHANGELOG.md index 27fb790..56a2dda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ +### 3.0.1 +* switch pipeline.yml scripts to use internal shared scripts ### version 3.0 -* update RestSharp to 109.0.1, this comes with many API breaking changes, some affecting us, see below: +* update RestSharp to 108.0.1, this comes with many API breaking changes, some affecting us, see below: * removal of basic auth - our API no longer makes sense with RestSharp immutable clients. * switch from newtonsoft.json to system.text.json * add unit test project diff --git a/cicdscripts/BuildSolution.ps1 b/cicdscripts/BuildSolution.ps1 deleted file mode 100644 index 0b1f694..0000000 --- a/cicdscripts/BuildSolution.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -<# -Date: 07/02/2020 -Purpose: To build Greg inside a windows docker container -#> -$ErrorActionPreference = "Stop" - -$errorMessage = "The build was not successful, check for errors" -$dockerImage = "artifactory.dev.adskengineer.net/dynamo/desktop/buildtools/2022:1.2.3" - -#Clear Nuget Cache -&"$env:WORKSPACE\$env:COMMON_TOOLS_DIR\$env:NUGETTOOL" locals all -clear - -try { - # Stop container - docker stop $env:DOCKER_CONTAINER - - # Remove the previous container so that we start with a fresh container - docker rm $env:DOCKER_CONTAINER - - # One time pull of the docker image - docker pull $dockerImage - - # Creating the container - docker run -m 8GB -d -t --mount type=bind,source=$env:WORKSPACE,target=$env:DOCKER_WORKSPACE --name $env:DOCKER_CONTAINER $dockerImage - - # Restore Nuget packages Greg solution - docker exec $env:DOCKER_CONTAINER $env:DOCKER_WORKSPACE\$env:COMMON_TOOLS_DIR\$env:NUGETTOOL restore $env:DOCKER_WORKSPACE\src\GregClient.sln - - # Build Greg solution - docker exec $env:DOCKER_CONTAINER msbuild -restore $env:DOCKER_WORKSPACE\src\GregClient.sln /property:Configuration=Release - - if($LASTEXITCODE -ne 0) { - throw $errorMessage - } -} -catch { - if($error[0].Exception.Message -eq $errorMessage){ - Invoke-Expression -Command "$env:WORKSPACE\cicdscripts\PostDeploy.ps1" - } - else { - Invoke-Expression -Command "$env:WORKSPACE\cicdscripts\RestartDockerDesktop.ps1" - } - - Write-Host $error[0] - throw $LASTEXITCODE -} diff --git a/cicdscripts/DownloadCICDResources.ps1 b/cicdscripts/DownloadCICDResources.ps1 new file mode 100644 index 0000000..a8e4a20 --- /dev/null +++ b/cicdscripts/DownloadCICDResources.ps1 @@ -0,0 +1,34 @@ +<# + Purpose: Pull of the source from git +#> +$ErrorActionPreference = "Stop" + +try { + + #Redirecting GIT output + $env:GIT_REDIRECT_STDERR = '2>&1' + + if ([string]::IsNullOrWhiteSpace($env:URL_REPO_TOOLS) -or [string]::IsNullOrWhiteSpace($env:BRANCH_TOOLS)) + { + throw "The tool repository parameters had not been set properly" + } + else + { + $JUser = "$env:GITADSK_USERNAME" + $JPassword = [System.Web.HttpUtility]::UrlEncode("$env:GITADSK_PASSWORD") + + $GitUrl = "https://" + "$JUser" + ":" + "$JPassword" + "@$env:URL_REPO_TOOLS" + + git clone -b $env:BRANCH_TOOLS "$GitUrl" "$env:WORKSPACE\$env:COMMON_TOOLS_DIR" + + if($LASTEXITCODE -ne 0) + { + throw "The download of the tools failed" + } + } + +} +catch { + Write-Host $error[0] + throw $LASTEXITCODE +} \ No newline at end of file diff --git a/cicdscripts/ExecuteContainerDeploy.ps1 b/cicdscripts/ExecuteContainerDeploy.ps1 deleted file mode 100644 index 7fb4006..0000000 --- a/cicdscripts/ExecuteContainerDeploy.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -<# -Date: 07/02/2020 -Purpose: To build Greg inside a windows docker container -#> -$ErrorActionPreference = "Stop" - -try { - docker exec $env:DOCKER_CONTAINER powershell -command "$env:DOCKER_WORKSPACE\cicdscripts\ProcessNugetPackage.ps1" -Workspace $env:DOCKER_WORKSPACE -NugetPath $env:DOCKER_WORKSPACE\$env:COMMON_TOOLS_DIR\$env:NUGETTOOL -ApiKey $env:APIKEY - - if($LASTEXITCODE -ne 0) { - throw "Package/Publish of the nuget package failed" - } -} -catch { - - if($error[0].Exception.Message -eq $errorMessage){ - Invoke-Expression -Command "$env:WORKSPACE\cicdscripts\PostDeploy.ps1" - } - else { - Invoke-Expression -Command "$env:WORKSPACE\cicdscripts\RestartDockerDesktop.ps1" - } - - Write-Host $error[0] - throw $LASTEXITCODE -} diff --git a/cicdscripts/PostDeploy.ps1 b/cicdscripts/PostDeploy.ps1 deleted file mode 100644 index add38c4..0000000 --- a/cicdscripts/PostDeploy.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -<# - Date: 07/04/2019 - Purpose: Post Build Script of Dynamo -#> -$ErrorActionPreference = "Stop" - -try { - docker container stop $env:DOCKER_CONTAINER - docker container rm $env:DOCKER_CONTAINER -} -catch { - Invoke-Expression -Command "$env:WORKSPACE\cicdscripts\RestartDockerDesktop.ps1" - Write-Host $error[0] - throw $LASTEXITCODE -} -finally { - docker container prune -f -} diff --git a/cicdscripts/ProcessNugetPackage.ps1 b/cicdscripts/ProcessNugetPackage.ps1 deleted file mode 100644 index 6f50f10..0000000 --- a/cicdscripts/ProcessNugetPackage.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# -Date: 07/02/2020 -Purpose: To create and publish the Greg nuget package -#> -[CmdletBinding()] -param ( - [Parameter(Mandatory)] - [string] - $Workspace, - [Parameter(Mandatory)] - [string] - $NugetPath, - [Parameter(Mandatory)] - [string] - $ApiKey -) - -$ErrorActionPreference = "Stop" - -$assemblyPath = "$Workspace\bin\Release" - -try { - - $nupkgFile = Get-ChildItem $assemblyPath\*.nupkg -Depth 1 - - & "$NugetPath" push $nupkgFile.FullName -ApiKey $ApiKey -Source nuget.org -} -catch { - Write-Host $error[0] - throw $LASTEXITCODE -} \ No newline at end of file diff --git a/cicdscripts/PublishPackage.ps1 b/cicdscripts/PublishPackage.ps1 new file mode 100644 index 0000000..33fc6ff --- /dev/null +++ b/cicdscripts/PublishPackage.ps1 @@ -0,0 +1,46 @@ +[CmdletBinding()] +param ( + [Parameter()] + [string[]] + $ReleaseBranches +) + +$ErrorActionPreference = "Stop" + +$regexBranches = @() +foreach ($branch in $ReleaseBranches -split ",") +{ + $regexBranches += "(^" + $branch + "*)" +} +$regex = $regexBranches -join "|" + +Write-Host $env:BRANCH_NAME +Write-Host $regex + +<# +Regex matching release branches +#> +$reBranch = [regex]$regex + +if ($env:BRANCH_NAME -match $reBranch) +{ + try { + + #deploy already built package. + $assemblyPath = "\bin\release" + $nupkgFile = Get-ChildItem $assemblyPath\*.nupkg -Depth 1 + dotnet nuget push $nupkgFile --api-key $env:API_KEY --source $env:NUGET_PUBLISH_SOURCE + + if($LASTEXITCODE -ne 0) { + throw "The package-generation process failed" + } + } + catch { + Write-Host $error[0] + throw $LASTEXITCODE + } +} +else +{ + Write-Host("Deployment is skipped because this is not a release branch") +} \ No newline at end of file diff --git a/cicdscripts/RestartDockerDesktop.ps1 b/cicdscripts/RestartDockerDesktop.ps1 deleted file mode 100644 index c1b697a..0000000 --- a/cicdscripts/RestartDockerDesktop.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -$ErrorActionPreference = "Stop" - -try { - - Write-Host "Looking for docker process" - $processes = Get-Process "*docker desktop*" - if ($processes.Count -gt 0) - { - Write-Host "Docker desktop found" - $processes[0].Kill() - $processes[0].WaitForExit() - } - - Write-Host "Starting again Docker Desktop" - Start-Process "$env:ProgramFiles\Docker\Docker\Docker Desktop.exe" # -Verb RunAs - - Write-Host "Giving some time to Docker desktop" - Start-Sleep -Seconds 30 - - Write-Host "Cleaning the containers that are not started" - docker container prune -f -} -catch { - Write-Host $error[0] - throw $LASTEXITCODE -} \ No newline at end of file diff --git a/cicdscripts/SetupHost.ps1 b/cicdscripts/SetupHost.ps1 deleted file mode 100644 index 4b0f87b..0000000 --- a/cicdscripts/SetupHost.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# - Purpose: Setup with the applications needed for the CICD pipeline -#> -$ErrorActionPreference = "Stop" - -#Getting directory names to install the tools -$nugetSubDir = ($env:NUGETTOOL -split "\\")[0] -$elementsPath = ($env:WORKSPACE -split "\\") - -$toolsDir = $elementsPath[0] + '\' + $elementsPath[1] + '\tools' -$nugetDir = "$env:WORKSPACE\$env:COMMON_TOOLS_DIR\$nugetSubDir" - -#Creation of the tools directories -New-Item -Path $nugetDir -ItemType Directory - -#Download of latest version of Nuget -Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "$nugetDir\nuget.exe" - -try { - #Instal Python from nuget - &"$env:WORKSPACE\$env:COMMON_TOOLS_DIR\$env:NUGETTOOL" install python -source nuget.org -ExcludeVersion -OutputDirectory $toolsDir - - if($LASTEXITCODE -ne 0) { - throw "Install of Python has failed" - } -} -catch { - Write-Host $error[0] - throw $LASTEXITCODE -} \ No newline at end of file diff --git a/config/nuget.config b/config/nuget.config new file mode 100644 index 0000000..0dc2659 --- /dev/null +++ b/config/nuget.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pipeline.yml b/pipeline.yml index 364a840..6316a90 100644 --- a/pipeline.yml +++ b/pipeline.yml @@ -1,18 +1,27 @@ version: 0.1.1 env: - - JENKINS_NODE_WIN: "DynamoDockerWin" + - JENKINS_NODE_WIN: "Dynamo_Win_Perf" - SLACK_QUANTUM_BUILD_CHANNEL : "#dynamo-jenkinsbuild" - SLACK_QUANTUM_BUILD_CREDENTIAL_ID : "slack-notify-token" - MAIL_QUANTUM_BUILD_RECIPIENT : "dynamo.dev@autodesk.com" - - DOCKER_WORKSPACE : "c:\\Greg" - NUGETTOOL : "Nuget\\nuget.exe" - - DOCKER_CONTAINER : "buildContainer" - - HARMONY_REPO : "DynamoDS/PackageManagerClient" + - NUNITTOOL : "NUnit\\NUnit.ConsoleRunner\\tools\\nunit3-console.exe" + - URL_REPO_TOOLS : "git.autodesk.com/Dynamo/CICDResources.git" + - BRANCH_TOOLS : "master" + - NUGET_PUBLISH_SOURCE: "https://api.nuget.org/v3/index.json" + - COMMON_TOOLS_DIR : "CICDResources_shared" + - DOTCOVERTOOL : "DotCover\\JetBrains.dotCover.CommandLineTools\\tools\\dotCover.exe" + - SONARSCANTOOL : "SonarScannerMsbuild\\dotnet-framework-sonarscanner\\tools\\SonarScanner.MSBuild.exe" + - NUGET_SOURCES : "nuget.org" + - NUGET_CONFIG : "Config\\nuget.config" + check_changelog_updated_on_pr: true pipeline_os: "Windows" force_slack_notification : true language: csharp +use_garasign: true + schedule: cron_schedule: "once_a_week" @@ -22,37 +31,50 @@ jenkins_creds: type: secretText credentialsId: dynamovisualprogramming_nuget_api_key secretText: APIKEY + - + type: usernamePassword + credentialsId: local-svc_p_ors + username: GITADSK_USERNAME + password: GITADSK_PASSWORD build: - setup_proj_deps : true + solution: src\\GregClient.sln scripts: - - "pwsh.exe -ExecutionPolicy ByPass -File .\\cicdscripts\\SetupHost.ps1" - - "pwsh.exe -ExecutionPolicy ByPass -File .\\cicdscripts\\BuildSolution.ps1" + - "pwsh.exe -ExecutionPolicy ByPass -File .\\cicdscripts\\DownloadCICDResources.ps1" + - "pwsh.exe -ExecutionPolicy ByPass -File .\\%COMMON_TOOLS_DIR%\\scripts\\SetupHost.ps1" + - "dotnet build src/gregClient.sln --configuration Release" +ci_test: + tests: + - + scripts: + - dotnet test src/GregClientTests/GregClientTests.csproj --logger:"junit;LogFilePath=testresults\\testresults.xml" + + test_report_dir: GregClientTests\\testresults + test_report_pattern: + format: "junit" + pattern: "*.xml" soc2: harmony: hidden_email_list: dynamo_ws_access - repository: env.HARMONY_REPO third_party_lib_paths: - - "bin\\release" + - bin\\Release\\net8.0\\ deployment: - - - type: customized - scripts: - - "pwsh.exe -ExecutionPolicy ByPass -File .\\cicdscripts\\ExecuteContainerDeploy.ps1" - - "pwsh.exe -ExecutionPolicy ByPass -File .\\cicdscripts\\PostDeploy.ps1" - -ci_test: - tests: - - + + - + type: sign + files_to_sign: + - "bin\\Release\\net8.0\\greg.dll" + - + type: customized scripts: - - "dotnet test src/GregClientTests/GregClientTests.csproj --logger:'junit;LogFilePath=testresults\\testresults.xml'" + - "pwsh.exe -ExecutionPolicy ByPass -File .\\cicdscripts\\PublishPackage.ps1 -ReleaseBranches master" + + + - test_report_dir: TestResults - test_report_pattern: - format: "junit" - pattern: "*.xml" diff --git a/src/AssemblyInfoGenerator/AssemblyInfo.cs b/src/AssemblyInfoGenerator/AssemblyInfo.cs index e00c6f5..6185ab8 100644 --- a/src/AssemblyInfoGenerator/AssemblyInfo.cs +++ b/src/AssemblyInfoGenerator/AssemblyInfo.cs @@ -36,7 +36,7 @@ // to distinguish one build from another. AssemblyFileVersion is specified // in AssemblyVersionInfo.cs so that it can be easily incremented by the // automated build process. -[assembly: AssemblyVersion("3.0.0.2886")] +[assembly: AssemblyVersion("3.0.1.4167")] // By default, the "Product version" shown in the file properties window is @@ -55,4 +55,4 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("3.0.0.2886")] +[assembly: AssemblyFileVersion("3.0.1.4167")] diff --git a/src/AssemblyInfoGenerator/AssemblyInfo.tt b/src/AssemblyInfoGenerator/AssemblyInfo.tt index 9b8de4f..205244a 100644 --- a/src/AssemblyInfoGenerator/AssemblyInfo.tt +++ b/src/AssemblyInfoGenerator/AssemblyInfo.tt @@ -60,7 +60,7 @@ using System.Runtime.InteropServices; <#+ int MajorVersion = 3; int MinorVersion = 0; -int BuildNumber = 0; +int BuildNumber = 1; // The datetime baseline we choose using this algorithm will affect build number and all nuget packages uploaded // Please only change when major or minor version got incremented int RevisionNumber = ((int)(DateTime.UtcNow - new DateTime(2023,1,1)).TotalDays)*10+((int)DateTime.UtcNow.Hour)/3; diff --git a/src/GregClient/GregClient.csproj b/src/GregClient/GregClient.csproj index 874d785..954ce88 100644 --- a/src/GregClient/GregClient.csproj +++ b/src/GregClient/GregClient.csproj @@ -5,42 +5,20 @@ Greg Autodesk - 8.0.30703 - 2.0 {644207B4-7E7F-474A-952E-3453960D8A01} Library Properties Greg Greg - net6.0 - 512 - + net8.0 false - false True $(GenerateNuspecDependsOn);ReadPackageVersionFromOutputAssembly logo_square_32x32.png The Dynamo Package Manager .Net Client. + ..\..\bin\$(Configuration)\ - - true - full - false - ..\..\bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - ..\..\bin\Release\ - TRACE - prompt - 4 - false - + diff --git a/src/GregClientTests/GregClientTests.csproj b/src/GregClientTests/GregClientTests.csproj index 756c771..3809c88 100644 --- a/src/GregClientTests/GregClientTests.csproj +++ b/src/GregClientTests/GregClientTests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable