Deploy #78
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: Deploy | |
| on: | |
| workflow_run: | |
| workflows: ["Build"] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| concurrency: | |
| group: deploy-${{ github.sha }} | |
| cancel-in-progress: false | |
| jobs: | |
| deploy-abstraction: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| if: | | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'workflow_run' && | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && | |
| startsWith(github.event.workflow_run.head_branch, 'refs/tags/v')) | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| - name: Restore dependencies | |
| run: | | |
| dotnet restore src/StatePulse.Net.Analyzers/StatePulse.Net.Analyzers.csproj | |
| dotnet restore src/StatePulse.Net.Abstractions/StatePulse.Net.Abstractions.csproj | |
| - name: Build StatePulse.Net.Abstractions | |
| run: | | |
| dotnet build src/StatePulse.Net.Analyzers/StatePulse.Net.Analyzers.csproj -c Release --no-restore | |
| dotnet build src/StatePulse.Net.Abstractions/StatePulse.Net.Abstractions.csproj -c Release --no-restore | |
| - name: Pack StatePulse.Net.Abstractions | |
| run: dotnet pack src/StatePulse.Net.Abstractions/StatePulse.Net.Abstractions.csproj -c Release --no-build -o ./artifacts | |
| - name: NuGet login (OIDC → temp API key) | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Push StatePulse.Net.Abstractions | |
| run: dotnet nuget push ./artifacts/StatePulse.Net.Abstractions.*.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| - name: Get package version | |
| id: get_version | |
| run: | | |
| FILE=$(ls ./artifacts/*.nupkg | head -n1) | |
| VERSION=$(basename "$FILE" | sed -E 's/^.*\.([0-9]+\.[0-9]+\.[0-9]+).*\.nupkg$/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Wait for NuGet availability | |
| uses: nick-invision/retry@v2 | |
| with: | |
| timeout_minutes: 10 | |
| retry_wait_seconds: 10 | |
| max_attempts: 60 | |
| command: | | |
| VERSION="${{ steps.get_version.outputs.version }}" | |
| echo "VERSION=>>${{ steps.get_version.outputs.version }}<<" | |
| STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ | |
| "https://api.nuget.org/v3/registration5-gz-semver2/statepulse.net.abstractions/${VERSION}.json") | |
| # NuGet returns 200 if version exists, 404 if not | |
| [ "$STATUS" -eq 200 ] || exit 1 | |
| deploy-core: | |
| needs: deploy-abstraction | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| if: | | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'workflow_run' && | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && | |
| startsWith(github.event.workflow_run.head_branch, 'refs/tags/v')) | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| - name: Restore dependencies | |
| run: | | |
| dotnet restore src/StatePulse.Net.Analyzers/StatePulse.Net.Analyzers.csproj | |
| dotnet restore src/StatePulse.NET/StatePulse.NET.csproj | |
| - name: Build StatePulse.NET | |
| run: | | |
| dotnet build src/StatePulse.Net.Analyzers/StatePulse.Net.Analyzers.csproj -c Release --no-restore | |
| dotnet build src/StatePulse.NET/StatePulse.NET.csproj -c Release --no-restore | |
| - name: Pack StatePulse.NET | |
| run: dotnet pack src/StatePulse.NET/StatePulse.NET.csproj -c Release --no-build -o ./artifacts | |
| - name: NuGet login (OIDC → temp API key) | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Push StatePulse.NET | |
| run: dotnet nuget push ./artifacts/StatePulse.NET.*.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate |