Version 1.1.0 #6
Workflow file for this run
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: | |
| release: | |
| types: [created] | |
| defaults: | |
| run: | |
| shell: pwsh | |
| env: | |
| baseVersion: 1.0.0 | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Set Version | |
| run: | | |
| echo "${{ github.ref }}" | |
| if ("${{ github.ref }}".startsWith("refs/tags/v")) { | |
| $tagVersion = "${{ github.ref }}".substring(11) | |
| echo "buildVersion=$tagVersion.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "nugetVersion=$tagVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "preRelease=false" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| } else { | |
| echo "buildVersion=${{ env.baseVersion }}.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "nugetVersion=${{ env.baseVersion }}-ci${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| } | |
| - name: Build | |
| run: dotnet build -p:Version=${{ env.buildVersion }} -p:ContinuousIntegrationBuild=True --no-restore --configuration Release | |
| - name: Test | |
| run: dotnet test --no-build --configuration Release --verbosity normal | |
| - name: Pack | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: dotnet pack -p:PackageVersion=${{ env.nugetVersion }} --configuration Release -o ${{github.workspace}}/TestTools.ConsolePack --no-build | |
| - name: Upload Artifacts | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: NuGet | |
| path: ${{github.workspace}}/TestTools.ConsolePack | |
| deploy: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| needs: build-and-test | |
| environment: | |
| name: 'Production' | |
| permissions: | |
| id-token: write # Required for OIDC trusted publishing to nuget.org | |
| steps: | |
| - name: Download artifact from build job | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: NuGet | |
| - name: NuGet login (OIDC → temp API key) | |
| uses: NuGet/login@v1 | |
| id: nuget-login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Push NuGet | |
| run: | | |
| $tagVersion = "${{ github.ref }}".substring(11) | |
| echo "tagVersion=$tagVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| dotnet nuget push IntelliTect.TestTools.Console.$tagVersion.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --skip-duplicate | |
| - name: Upload nupkg to Releases | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| fail_on_unmatched_files: true | |
| generate_release_notes: true | |
| files: IntelliTect.TestTools.Console.${{ env.tagVersion }}.nupkg |