From 9da4bd300ce38615048a8f050c32ff5dcb91d864 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Thu, 7 Mar 2024 14:25:09 -0800 Subject: [PATCH 1/7] Add workflow actions for build, pack and test --- .github/workflows/main.yml | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bbe92ae53..b419a3228 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,9 @@ name: Validate OpenAPI definition on: + workflow_dispatch: + push: + branches: + - main pull_request: types: [opened, reopened, synchronize] @@ -25,3 +29,38 @@ jobs: with: swagger-editor-url: http://localhost/ definition-file: openapi.yaml + + # Test, pack and publish the Open AI nuget package as a build artifact + build: + runs-on: ubuntu-latest + steps: + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.x' + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Restore dependencies + run: dotnet restore + working-directory: .dotnet + + - name: Build + run: dotnet build --no-restore + working-directory: .dotnet + + - name: Test + run: dotnet test --no-build --verbosity normal + working-directory: .dotnet + + - name: Pack + run: dotnet pack --no-build -c Release -o out + working-directory: .dotnet + + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: package + path: out/*.nupkg + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} From ffe7ae8aa5ecd2c77b60481f914a920622f54645 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Thu, 7 Mar 2024 14:32:41 -0800 Subject: [PATCH 2/7] Update .net verions in workflow --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b419a3228..3ce29ad0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' + dotnet-version: 8.x - name: Checkout code uses: actions/checkout@v2 From 4412abe0386aba1739f00c21aa86ddac1fcc5923 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Mon, 11 Mar 2024 13:48:19 -0700 Subject: [PATCH 3/7] Change artifact upload condition to !pull_request --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3ce29ad0d..aa634b56e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,4 +63,4 @@ jobs: with: name: package path: out/*.nupkg - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + if: ${{ github.event_name != 'pull_request' }} From 10b3e1a618110685e65a30b9c94dda2973575080 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Mon, 11 Mar 2024 15:23:49 -0700 Subject: [PATCH 4/7] Add strong name key --- .dotnet/src/OpenAI.csproj | 2 ++ .dotnet/src/sgKey.snk | Bin 0 -> 596 bytes 2 files changed, 2 insertions(+) create mode 100644 .dotnet/src/sgKey.snk diff --git a/.dotnet/src/OpenAI.csproj b/.dotnet/src/OpenAI.csproj index ed91914a5..2772f5e68 100644 --- a/.dotnet/src/OpenAI.csproj +++ b/.dotnet/src/OpenAI.csproj @@ -7,6 +7,8 @@ netstandard2.0 latest true + true + sgKey.snk diff --git a/.dotnet/src/sgKey.snk b/.dotnet/src/sgKey.snk new file mode 100644 index 0000000000000000000000000000000000000000..fa09b4dee086e0e7d0c267abce07e7849511d424 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa500988mojfITmCL8N$V;FzUXnqT*#C%TQ_wT zmolw^Y)>#r7U%I)DO85|%&YIC!J7r0QOy~ce8STjF_qRJI?$AcV)Y!x9K-8VU&vD5 zNd(PRYhjS1(#SCe9fk&mi*_gK)C5rIZ8gw^NJf&EzMBMd`wGwVSHH({YYIo)xUuT z`gzBo$WRh%2s!lZyxvP80}p>i!5rOh@#?SfYkJ26U!8cvu#62#ks}rs+`lOr5y&}( is@JZelHsuF4mkx-P&BUWi_Yg= Date: Mon, 11 Mar 2024 16:02:28 -0700 Subject: [PATCH 5/7] Add update-client script --- .dotnet/scripts/Update-Client.ps1 | 21 +++++++++++++++++++++ .dotnet/src/OpenAI.csproj | 2 -- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .dotnet/scripts/Update-Client.ps1 diff --git a/.dotnet/scripts/Update-Client.ps1 b/.dotnet/scripts/Update-Client.ps1 new file mode 100644 index 000000000..8832c2393 --- /dev/null +++ b/.dotnet/scripts/Update-Client.ps1 @@ -0,0 +1,21 @@ +$repoRoot = Join-Path $PSScriptRoot .. .. -Resolve +$dotnetFolder = Join-Path $repoRoot .dotnet + +function Invoke([scriptblock]$script) { + $scriptString = $script | Out-String + Write-Host "--------------------------------------------------------------------------------`n> $scriptString" + & $script +} + +Push-Location $repoRoot +try { + Invoke { npm ci } + Invoke { npm exec --no -- tsp compile main.tsp --emit @typespec/openapi3 } + Invoke { npm exec --no -- tsp compile main.tsp --emit @azure-tools/typespec-csharp --option @azure-tools/typespec-csharp.emitter-output-dir="$dotnetFolder" } + Invoke { .dotnet\scripts\Update-ClientModel.ps1 } + Invoke { .dotnet\scripts\ConvertTo-Internal.ps1 } + Invoke { .dotnet\scripts\Add-Customizations.ps1 } +} +finally { + Pop-Location +} diff --git a/.dotnet/src/OpenAI.csproj b/.dotnet/src/OpenAI.csproj index 2772f5e68..ed91914a5 100644 --- a/.dotnet/src/OpenAI.csproj +++ b/.dotnet/src/OpenAI.csproj @@ -7,8 +7,6 @@ netstandard2.0 latest true - true - sgKey.snk From d525d5606c1df9429ae1d989c37a590878b9f42b Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Wed, 13 Mar 2024 12:19:54 -0700 Subject: [PATCH 6/7] Add assembly strong naming to Directory.Build.props --- .dotnet/src/Directory.Build.props | 6 ++++++ .dotnet/src/{sgKey.snk => OpenAI.snk} | Bin .github/workflows/main.yml | 13 +------------ 3 files changed, 7 insertions(+), 12 deletions(-) create mode 100644 .dotnet/src/Directory.Build.props rename .dotnet/src/{sgKey.snk => OpenAI.snk} (100%) diff --git a/.dotnet/src/Directory.Build.props b/.dotnet/src/Directory.Build.props new file mode 100644 index 000000000..722190624 --- /dev/null +++ b/.dotnet/src/Directory.Build.props @@ -0,0 +1,6 @@ + + + true + OpenAI.snk + + \ No newline at end of file diff --git a/.dotnet/src/sgKey.snk b/.dotnet/src/OpenAI.snk similarity index 100% rename from .dotnet/src/sgKey.snk rename to .dotnet/src/OpenAI.snk diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa634b56e..67442cf69 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,20 +42,9 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Restore dependencies - run: dotnet restore - working-directory: .dotnet - - - name: Build - run: dotnet build --no-restore - working-directory: .dotnet - - - name: Test - run: dotnet test --no-build --verbosity normal - working-directory: .dotnet - name: Pack - run: dotnet pack --no-build -c Release -o out + run: dotnet pack -c Release -o out working-directory: .dotnet - name: Upload artifact From e1e8711438a0580e2ba60455055acca50feedf54 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Wed, 13 Mar 2024 12:44:06 -0700 Subject: [PATCH 7/7] Use dev nuget feed --- .dotnet/nuget.config | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .dotnet/nuget.config diff --git a/.dotnet/nuget.config b/.dotnet/nuget.config new file mode 100644 index 000000000..824446d51 --- /dev/null +++ b/.dotnet/nuget.config @@ -0,0 +1,9 @@ + + + + + + + + +