Fixed build status in README #5
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: CI | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract version from tag | |
| id: get_version | |
| run: | | |
| if [ "${{ github.ref_type }}" == "tag" ]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "is_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=0.0.0-ci.${{ github.run_number }}" >> $GITHUB_OUTPUT | |
| echo "is_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| shell: bash | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install TypeScript | |
| run: npm install -g typescript | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Restore LibMan libraries | |
| run: | | |
| dotnet tool install -g Microsoft.Web.LibraryManager.Cli | |
| libman restore --verbosity detailed | |
| working-directory: src/Octopus.Blazor | |
| - name: Compile TypeScript | |
| run: npx tsc --project src/Octopus.Blazor/tsconfig.json | |
| - name: Update version in csproj files | |
| if: steps.get_version.outputs.is_release == 'true' | |
| run: | | |
| $version = "${{ steps.get_version.outputs.version }}" | |
| foreach ($file in @("src/Octopus.Blazor/Octopus.Blazor.csproj", "src/Octopus.Api.Client/Octopus.Api.Client.csproj")) { | |
| (Get-Content $file) -replace '<Version>.*</Version>', "<Version>$version</Version>" | Set-Content $file | |
| } | |
| shell: pwsh | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Run tests | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| - name: Pack NuGet packages | |
| if: steps.get_version.outputs.is_release == 'true' | |
| run: | | |
| dotnet pack src/Octopus.Api.Client/Octopus.Api.Client.csproj --configuration Release --no-build --output ./artifacts | |
| dotnet pack src/Octopus.Blazor/Octopus.Blazor.csproj --configuration Release --no-build --output ./artifacts | |
| - name: Upload NuGet packages | |
| if: steps.get_version.outputs.is_release == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ./artifacts/*.nupkg | |
| - name: Upload symbol packages | |
| if: steps.get_version.outputs.is_release == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: symbol-packages | |
| path: ./artifacts/*.snupkg | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Extract version from tag | |
| id: get_version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Download NuGet packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ./artifacts | |
| - name: Download symbol packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: symbol-packages | |
| path: ./artifacts | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Push to NuGet.org | |
| run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| ./artifacts/*.nupkg | |
| ./artifacts/*.snupkg | |
| generate_release_notes: true | |
| body: | | |
| ## 📦 NuGet Packages | |
| ### Octopus.Blazor | |
| [NuGet.org](https://www.nuget.org/packages/Octopus.Blazor/${{ steps.get_version.outputs.version }}) | |
| ```bash | |
| dotnet add package Octopus.Blazor --version ${{ steps.get_version.outputs.version }} | |
| ``` | |
| ### Octopus.Api.Client | |
| [NuGet.org](https://www.nuget.org/packages/Octopus.Api.Client/${{ steps.get_version.outputs.version }}) | |
| ```bash | |
| dotnet add package Octopus.Api.Client --version ${{ steps.get_version.outputs.version }} | |
| ``` | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |