|
| 1 | +# This workflow is triggered by new releases and on a daily schedule. |
| 2 | +# It builds, unit tests, live tests and published the Open AI nuget package. |
| 3 | +# For daily runs, the package is published to the GitHub package registry. |
| 4 | +# For releases, the package is published to the NuGet package registry. |
1 | 5 | name: Release package |
2 | 6 |
|
3 | 7 | on: |
4 | 8 | release: |
5 | 9 | types: [published] |
| 10 | + schedule: |
| 11 | + # run every day at 00:00 |
| 12 | + - cron: '0 0 * * *' |
6 | 13 |
|
7 | 14 | jobs: |
8 | | - deploy: |
| 15 | + build: |
| 16 | + name: Build |
9 | 17 | runs-on: ubuntu-latest |
| 18 | + environment: Live Testing |
| 19 | + env: |
| 20 | + version_suffix_args: ${{ github.event_name == 'schedule' && format('--version-suffix="alpha.{0}"', github.run_number) || '' }} |
10 | 21 | permissions: |
11 | 22 | packages: write |
12 | 23 | contents: write |
13 | 24 | steps: |
14 | | - - uses: actions/checkout@v4 |
15 | | - - uses: actions/setup-dotnet@v3 |
| 25 | + - name: Setup .NET |
| 26 | + uses: actions/setup-dotnet@v3 |
16 | 27 | with: |
17 | | - dotnet-version: '8.x' # SDK Version to use. |
| 28 | + dotnet-version: '8.x' |
| 29 | + |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v2 |
18 | 32 |
|
19 | 33 | # Pack the client nuget package and include url back to the repository and release tag |
20 | 34 | - name: Build and Pack |
21 | 35 | run: dotnet pack |
22 | 36 | --configuration Release |
23 | | - --output "${{github.workspace}}/artifacts/packages" |
| 37 | + --output "${{ github.workspace }}/artifacts/packages" |
24 | 38 | /p:PackageProjectUrl="${{ github.server_url }}/${{ github.repository }}/tree/${{ github.event.release.tag_name }}" |
25 | 39 | /p:PackageReleaseNotes="${{ github.server_url }}/${{ github.repository }}/blob/${{ github.event.release.tag_name }}/CHANGELOG.md" |
| 40 | + ${{ env.version_suffix_args }} |
26 | 41 |
|
27 | | - - name: Test |
| 42 | + - name: Unit Test |
| 43 | + run: dotnet test |
| 44 | + --configuration Release |
| 45 | + --filter="TestCategory=Smoke&TestCategory!=Manual" |
| 46 | + --logger "trx;LogFileName=${{ github.workspace }}/artifacts/test-results/smoke.trx" |
| 47 | + ${{ env.version_suffix_args }} |
| 48 | + |
| 49 | + - name: Run Live Tests |
28 | 50 | run: dotnet test |
29 | 51 | --configuration Release |
30 | | - --filter="TestCategory~Online" |
31 | | - --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/full.trx" |
| 52 | + --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" |
| 53 | + --logger "trx;LogFilePrefix=live" |
| 54 | + --results-directory ${{ github.workspace }}/artifacts/test-results |
| 55 | + ${{ env.version_suffix_args }} |
32 | 56 | env: |
33 | 57 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
34 | 58 |
|
| 59 | + - name: Upload artifact |
| 60 | + uses: actions/upload-artifact@v2 |
| 61 | + if: ${{ !cancelled() }} |
| 62 | + with: |
| 63 | + name: build-artifacts |
| 64 | + path: ${{ github.workspace }}/artifacts |
| 65 | + |
| 66 | + deploy: |
| 67 | + name: Publish Package |
| 68 | + needs: build |
| 69 | + runs-on: ubuntu-latest |
| 70 | + permissions: |
| 71 | + packages: write |
| 72 | + contents: write |
| 73 | + steps: |
| 74 | + - uses: actions/download-artifact@v2 |
| 75 | + |
35 | 76 | # Append the nuget package to the github release that triggered this workflow |
36 | 77 | - name: Upload release asset |
| 78 | + if: github.event_name == 'release' |
37 | 79 | run: gh release upload ${{ github.event.release.tag_name }} |
38 | | - ${{github.workspace}}/artifacts/packages/*.*nupkg |
| 80 | + ${{ github.workspace }}/build-artifacts/packages/*.*nupkg |
39 | 81 | env: |
40 | 82 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
41 | 83 |
|
42 | | - - name: Upload artifact |
43 | | - uses: actions/upload-artifact@v2 |
44 | | - with: |
45 | | - name: build-artifacts |
46 | | - path: ${{github.workspace}}/artifacts |
| 84 | + - name: NuGet authenticate |
| 85 | + run: dotnet nuget add source |
| 86 | + "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" |
| 87 | + --name "github" |
| 88 | + --username ${{ github.actor }} |
| 89 | + --password ${{ secrets.GITHUB_TOKEN }} |
| 90 | + --store-password-in-clear-text |
| 91 | + |
| 92 | + - name: Publish package to local feed |
| 93 | + run: dotnet nuget push |
| 94 | + ${{github.workspace}}/build-artifacts/packages/*.nupkg |
| 95 | + --source github |
| 96 | + --skip-duplicate |
47 | 97 |
|
48 | | - - name: Publish |
| 98 | + - name: Publish package to nuget.org |
| 99 | + if: github.event_name == 'release' |
49 | 100 | run: dotnet nuget push |
50 | | - ${{github.workspace}}/artifacts/packages/*.nupkg |
51 | | - --source https://api.nuget.org/v3/index.json |
52 | | - --api-key ${{ secrets.NUGET_API_KEY }} |
53 | | - --skip-duplicate |
| 101 | + ${{github.workspace}}/build-artifacts/packages/*.nupkg |
| 102 | + --source https://api.nuget.org/v3/index.json |
| 103 | + --api-key ${{ secrets.NUGET_API_KEY }} |
| 104 | + --skip-duplicate |
0 commit comments