diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..39d11a0 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,67 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: NugetRevisionDemo + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +jobs: + build: + + runs-on: windows-latest + env: + GitVersionVersion: 5.12.0 + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: nuget install GitVersion.Commandline -version ${{ env.GitVersionVersion }} + - run: get-childitem -recurse + shell: pwsh + + - name: GitVersion action + id: gitversion + # You may pin to the exact commit or the version. + # uses: nmcc/actions-gitversion@4ab384d333506ede37c82ca3e03f4005b18b7573 + uses: nmcc/actions-gitversion@v1 + with: + # Path to the gitversion executable + path-to-gitversion: ${{ github.workspace }}/GitVersion.CommandLine.${{ env.GitVersionVersion }}/tools/gitversion.exe + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + + - name: Version - Modify version number + uses: mingjun97/file-regex-replace@v1 + env: + version-number: ${{ steps.gitversion.outputs.AssemblySemVer }} + with: + regex: '[[0-9]+(\.([0-9]+|\*)){1,3}' + replacement: '${{ env.version-number}}' + flags: "gi" # Optional, defaults to "g" + include: '.csproj' # Optional, defaults to ".*" + exclude: '.^' # Optional, defaults to '.^' + encoding: 'utf8' # Optional, defaults to 'utf8' + path: '.' # Optional, defaults to '.' + + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.2 + with: + # Artifact name + name: NugetPackage + path: '**/*.nupkg'