.NET Continuous Deployment #46
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 Continuous Deployment | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: SharedCode Test | |
| runs-on: windows-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v6 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Run Tests | |
| run: dotnet test SharedCode.sln --verbosity normal | |
| semantic-release: | |
| needs: test | |
| name: Create a Package Release | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v6 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Bump version and push tag | |
| id: tag_version | |
| uses: mathieudutour/github-tag-action@v6.2 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create a GitHub release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ steps.tag_version.outputs.new_tag }} | |
| name: Release ${{ steps.tag_version.outputs.new_tag }} | |
| body: ${{ steps.tag_version.outputs.changelog }} | |
| - name: Create Nuget Package | |
| run: dotnet build -c Release SharedCode.sln && dotnet pack -c Release -p:PackageVersion=${{ steps.tag_version.outputs.new_version }} -o . SharedCode.sln | |
| - name: Upload Package for Publishing | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: PackedLib | |
| path: ./*.nupkg | |
| github-publish: | |
| needs: semantic-release | |
| name: Publish to Github | |
| runs-on: windows-latest | |
| permissions: | |
| packages: write | |
| steps: | |
| - name: Download built project | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: PackedLib | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v6 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Push Package to GitHub | |
| run: dotnet nuget push --api-key ${{secrets.GITHUB_TOKEN}} --source "https://nuget.pkg.github.com/improvgroup/index.json" *.nupkg | |
| nuget-publish: | |
| needs: semantic-release | |
| name: Publish to Nuget | |
| runs-on: windows-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download built project | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: PackedLib | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v6 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Authenticate with NuGet.org | |
| id: login | |
| uses: NuGet/login@v1 | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Push Package to NuGet | |
| run: dotnet nuget push --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source "https://api.nuget.org/v3/index.json" *.nupkg |