|
1 | | -name: Continuous |
2 | | - |
3 | | -on: |
4 | | - # PRs will be built, and a package posted to GH Packages |
5 | | - pull_request: |
6 | | - |
7 | | - push: |
8 | | - paths-ignore: |
9 | | - - 'README.md' |
10 | | - - 'docs/**' |
11 | | - |
12 | | - # We'll build, pack, and push a pre-release to NuGet on master |
13 | | - branches: [ master ] |
14 | | - |
15 | | - # Tagging with v* will build that version number and push a release to Nuget |
16 | | - # e.g. v1.2, v3.4.5, etc. |
17 | | - tags: |
18 | | - - 'v*' |
19 | | - |
20 | | -defaults: |
21 | | - run: |
22 | | - shell: pwsh |
23 | | - |
24 | | -jobs: |
25 | | - build: |
26 | | - runs-on: ubuntu-latest |
27 | | - steps: |
28 | | - - uses: actions/checkout@v2 |
29 | | - - name: Setup .NET Core |
30 | | - uses: actions/setup-dotnet@v1 |
31 | | - with: |
32 | | - dotnet-version: 6.0.202 |
33 | | - |
34 | | - # Run unit tests |
35 | | - - name: Test |
36 | | - run: dotnet test --configuration Release --verbosity normal |
37 | | - |
38 | | - # Package Release |
39 | | - - name: Pack |
40 | | - run: | |
41 | | - <# If we're a tag, force VersionPrefix to the tag value #> |
42 | | - if ('${{ github.ref }}' -match '^refs/tags/v') { |
43 | | - $match = [regex]::Match('${{ github.ref }}', '^refs/tags/v([0-9]+(\.[0-9]+){1,2})') |
44 | | - if ($match.Success) { |
45 | | - $env:VersionPrefix = $match.Groups[1].Value |
46 | | - } else { |
47 | | - throw 'Invalid tag version: ${{ github.ref }}' |
48 | | - } |
49 | | - } |
50 | | - else { |
51 | | - <# All other pushes get a CI suffix #> |
52 | | - $env:VersionSuffix = 'ci{0:0000}' -f ${{ github.run_number }} |
53 | | - } |
54 | | -
|
55 | | - dotnet pack --configuration Release --verbosity normal --output . |
56 | | - |
57 | | - - name: Upload NuGet |
58 | | - uses: actions/upload-artifact@v3 |
59 | | - with: |
60 | | - name: NuGet |
61 | | - if-no-files-found: error |
62 | | - path: | |
63 | | - **/*.nupkg |
64 | | - **/*.snupkg |
65 | | - |
66 | | - # Update the docs |
67 | | - - name: Update Docs |
68 | | - if: github.event_name == 'push' |
69 | | - run: | |
70 | | - dotnet tool install xmldocmd |
71 | | - dotnet tool run xmldocmd .\Moq.AutoMock\bin\Release\net461\Moq.AutoMock.dll .\docs |
72 | | -
|
73 | | - $modified = $(git status -u --porcelain) |
74 | | - if ($modified.Where({$_.Contains(" docs/")}, 'First').Count -lt 1) { |
75 | | - return 0 |
76 | | - } |
77 | | - |
78 | | - # Create docs pull request |
79 | | - - name: Create Pull Request |
80 | | - uses: peter-evans/create-pull-request@v3 |
81 | | - if: github.event_name == 'push' |
82 | | - with: |
83 | | - commit-message: | |
84 | | - [Docs update detected by Github Action]. |
85 | | - Auto generated pull request. |
86 | | - branch: docs/automated-update |
87 | | - delete-branch: true |
88 | | - base: master |
89 | | - title: Update Docs [GitHub Action] |
90 | | - body: | |
91 | | - [Docs update detected by Github Action]. |
92 | | - Auto generated pull request. |
93 | | -
|
94 | | - # Publish to NuGet and GitHub Packages |
95 | | - - name: Publish |
96 | | - if: github.event_name == 'push' |
97 | | - run: | |
98 | | - dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate |
99 | | - dotnet nuget push *.nupkg ` |
100 | | - --source 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' ` |
101 | | - --api-key '${{ github.token }}' ` |
102 | | - --skip-duplicate |
| 1 | +name: Continuous |
| 2 | + |
| 3 | +on: |
| 4 | + # PRs will be built, and a package posted to GH Packages |
| 5 | + pull_request: |
| 6 | + |
| 7 | + push: |
| 8 | + paths-ignore: |
| 9 | + - 'README.md' |
| 10 | + - 'docs/**' |
| 11 | + |
| 12 | + # We'll build, pack, and push a pre-release to NuGet on master |
| 13 | + branches: [ master ] |
| 14 | + |
| 15 | + # Tagging with v* will build that version number and push a release to Nuget |
| 16 | + # e.g. v1.2, v3.4.5, etc. |
| 17 | + tags: |
| 18 | + - 'v*' |
| 19 | + |
| 20 | +defaults: |
| 21 | + run: |
| 22 | + shell: pwsh |
| 23 | + |
| 24 | +jobs: |
| 25 | + build: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v2 |
| 29 | + |
| 30 | + - name: Setup .NET Core |
| 31 | + uses: actions/setup-dotnet@v1 |
| 32 | + |
| 33 | + # Run unit tests |
| 34 | + - name: Test |
| 35 | + run: dotnet test --configuration Release --verbosity normal |
| 36 | + |
| 37 | + # Package Release |
| 38 | + - name: Pack |
| 39 | + run: | |
| 40 | + <# If we're a tag, force VersionPrefix to the tag value #> |
| 41 | + if ('${{ github.ref }}' -match '^refs/tags/v') { |
| 42 | + $match = [regex]::Match('${{ github.ref }}', '^refs/tags/v([0-9]+(\.[0-9]+){1,2})') |
| 43 | + if ($match.Success) { |
| 44 | + $env:VersionPrefix = $match.Groups[1].Value |
| 45 | + } else { |
| 46 | + throw 'Invalid tag version: ${{ github.ref }}' |
| 47 | + } |
| 48 | + } |
| 49 | + else { |
| 50 | + <# All other pushes get a CI suffix #> |
| 51 | + $env:VersionSuffix = 'ci{0:0000}' -f ${{ github.run_number }} |
| 52 | + } |
| 53 | +
|
| 54 | + dotnet pack --configuration Release --verbosity normal --output . |
| 55 | + |
| 56 | + - name: Upload NuGet |
| 57 | + uses: actions/upload-artifact@v3 |
| 58 | + with: |
| 59 | + name: NuGet |
| 60 | + if-no-files-found: error |
| 61 | + path: | |
| 62 | + **/*.nupkg |
| 63 | + **/*.snupkg |
| 64 | + |
| 65 | + # Update the docs |
| 66 | + - name: Update Docs |
| 67 | + if: github.event_name == 'push' |
| 68 | + run: | |
| 69 | + dotnet tool install xmldocmd |
| 70 | + dotnet tool run xmldocmd .\Moq.AutoMock\bin\Release\net461\Moq.AutoMock.dll .\docs |
| 71 | +
|
| 72 | + $modified = $(git status -u --porcelain) |
| 73 | + if ($modified.Where({$_.Contains(" docs/")}, 'First').Count -lt 1) { |
| 74 | + return 0 |
| 75 | + } |
| 76 | + |
| 77 | + # Create docs pull request |
| 78 | + - name: Create Pull Request |
| 79 | + uses: peter-evans/create-pull-request@v3 |
| 80 | + if: github.event_name == 'push' |
| 81 | + with: |
| 82 | + commit-message: | |
| 83 | + [Docs update detected by Github Action]. |
| 84 | + Auto generated pull request. |
| 85 | + branch: docs/automated-update |
| 86 | + delete-branch: true |
| 87 | + base: master |
| 88 | + title: Update Docs [GitHub Action] |
| 89 | + body: | |
| 90 | + [Docs update detected by Github Action]. |
| 91 | + Auto generated pull request. |
| 92 | +
|
| 93 | + # Publish to NuGet and GitHub Packages |
| 94 | + - name: Publish |
| 95 | + if: github.event_name == 'push' |
| 96 | + run: | |
| 97 | + dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate |
| 98 | + dotnet nuget push *.nupkg ` |
| 99 | + --source 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' ` |
| 100 | + --api-key '${{ github.token }}' ` |
| 101 | + --skip-duplicate |
0 commit comments