Egil.Orleans.Messaging #24
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
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: egil-orleans-messaging | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - 'main' | |
| - 'release/egil-orleans-messaging/v*' | |
| paths: | |
| - 'Egil.Orleans.Messaging/**' | |
| - '.github/workflows/egil-orleans-messaging-ci.yml' | |
| pull_request: | |
| branches: | |
| - 'main' | |
| paths: | |
| - 'Egil.Orleans.Messaging/**' | |
| - '.github/workflows/egil-orleans-messaging-ci.yml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
| DOTNET_NOLOGO: true | |
| NuGetDirectory: ${{ github.workspace }}/nuget | |
| TestResultsDirectory: ${{ github.workspace }}/TestResults | |
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
| Project: Egil.Orleans.Messaging | |
| permissions: | |
| contents: read | |
| jobs: | |
| create-nuget: | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.prepare-release != 'true' | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.x | |
| - name: Build and pack | |
| run: | | |
| dotnet build ./Egil.Orleans.Messaging/Egil.Orleans.Messaging.slnx -c Release -p:ContinuousIntegrationBuild=true | |
| for project in ./Egil.Orleans.Messaging/src/*/*.csproj; do | |
| dotnet pack "$project" -c Release --no-build -p:ContinuousIntegrationBuild=true --output ${{ env.NuGetDirectory }} | |
| done | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget | |
| if-no-files-found: error | |
| retention-days: 7 | |
| path: ${{ env.NuGetDirectory }}/*.nupkg | |
| validate-nuget: | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.prepare-release != 'true' | |
| needs: [ create-nuget ] | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.x | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget | |
| path: ${{ env.NuGetDirectory }} | |
| - name: Install nuget validator | |
| run: dotnet tool restore | |
| - name: Validate package | |
| shell: pwsh | |
| run: dotnet meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg") --excluded-rules IconMustBeSet | |
| run-test: | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.prepare-release != 'true' | |
| timeout-minutes: 30 | |
| env: | |
| TestResultsDirectory: ${{ github.workspace }}/TestResults | |
| permissions: | |
| contents: read | |
| checks: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.x | |
| - name: Run tests | |
| working-directory: Egil.Orleans.Messaging | |
| run: | | |
| export GITHUB_ENV=/dev/null | |
| dotnet test --solution ./Egil.Orleans.Messaging.slnx --configuration Release | |
| release: | |
| needs: [validate-nuget, run-test] | |
| if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/heads/release/egil-orleans-messaging/v') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget | |
| path: ${{ env.NuGetDirectory }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.x | |
| - name: NuGet login (trusted publishing) | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Publish NuGet package | |
| shell: pwsh | |
| run: | | |
| foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) { | |
| dotnet nuget push $file --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| } | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure GIT | |
| run: | | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| - name: Add git tag using dotnet nbgv | |
| run: | | |
| cd ${{ env.Project }} | |
| dotnet tool restore | |
| dotnet nbgv tag | |
| git push origin --tags | |
| - name: Delete release branch on origin | |
| if: startsWith(github.ref, 'refs/heads/release/egil-orleans-messaging/v') | |
| run: git push origin --delete "${{ env.BRANCH_NAME }}" |