.NET package CD #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: .NET package CD | |
| on: [workflow_dispatch] | |
| # Least privilege: no step in this workflow writes to the repo, | |
| # releases or packages via GITHUB_TOKEN (publishing uses NUGET_API_KEY, | |
| # signing uses GCP_SA_KEY). Fail closed regardless of the org default. | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: BrowserStackLocal | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@0717577d45739eb3c851188b29f50ed6c0b2194e # v2 | |
| - name: Add msbuild to PATH | |
| uses: microsoft/setup-msbuild@c26a08ba26249b81327e26f6ef381897b6a8754d # v1.0.2 | |
| - name: Build BrowserStackLocal | |
| run: | | |
| msbuild BrowserStackLocal -t:restore -p:Configuration=Release | |
| msbuild BrowserStackLocal -t:build -p:Configuration=Release | |
| - name: Build Test project | |
| run: | | |
| msbuild BrowserStackLocalIntegrationTests -t:restore -p:Configuration=Release | |
| msbuild BrowserStackLocalIntegrationTests -t:build -p:Configuration=Release | |
| - name: Setup .NET Core | |
| uses: actions/setup-dotnet@55ec9447dda3d1cf6bd587150f3262f30ee10815 # v3 | |
| with: | |
| dotnet-version: 6.0.x | |
| - name: Setup GCP credentials | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| printf '%s' "$GCP_SA_KEY_RAW" > $RUNNER_TEMP/gcp-sa-key.json | |
| chmod 600 $RUNNER_TEMP/gcp-sa-key.json | |
| echo "GOOGLE_APPLICATION_CREDENTIALS=$RUNNER_TEMP/gcp-sa-key.json" >> $GITHUB_ENV | |
| env: | |
| GCP_SA_KEY_RAW: ${{ secrets.GCP_SA_KEY }} | |
| shell: bash | |
| - name: Install google-auth | |
| working-directory: ${{ github.workspace }} | |
| run: python3 -m pip install google-auth requests | |
| shell: bash | |
| - name: Setup Java | |
| uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Run Integration Tests | |
| env: | |
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | |
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | |
| run: dotnet test BrowserStackLocalIntegrationTests --no-build -p:Configuration=Release | |
| - name: Pack NuGet Package | |
| run: msbuild BrowserStackLocal -t:pack -p:Configuration=Release | |
| - name: Sign Nuget Package | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| chmod +x ./scripts/sign_nupkg.sh | |
| ./scripts/sign_nupkg.sh | |
| shell: bash | |
| - name: Save artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: BrowserStackLocal.nupkg | |
| path: .\BrowserStackLocal\BrowserStackLocal\bin\Release\*.nupkg | |
| - name: Push package to Nuget Repository | |
| working-directory: ${{ github.workspace }} | |
| run: dotnet nuget push BrowserStackLocal/BrowserStackLocal/bin/Release/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| shell: bash | |
| - name: Cleanup credentials | |
| if: always() | |
| working-directory: ${{ github.workspace }} | |
| run: rm -f $RUNNER_TEMP/gcp-sa-key.json | |
| shell: bash |