|
| 1 | +name: CI |
| 2 | +'on': |
| 3 | + pull_request: |
| 4 | + types: [opened, reopened, edited, synchronize] |
| 5 | + paths-ignore: |
| 6 | + - "**/*.md" |
| 7 | + - "**/*.gitignore" |
| 8 | + - "**/*.gitattributes" |
| 9 | +jobs: |
| 10 | + Run-Lint: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + env: |
| 13 | + github-token: '${{ secrets.GITHUB_TOKEN }}' |
| 14 | + steps: |
| 15 | + - name: Step-01 Checkout code |
| 16 | + uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + - name: Step-02 Lint Code Base |
| 20 | + uses: github/super-linter@v4 |
| 21 | + env: |
| 22 | + VALIDATE_ALL_CODEBASE: false |
| 23 | + FILTER_REGEX_INCLUDE: .*src/.* |
| 24 | + DEFAULT_BRANCH: master |
| 25 | + GITHUB_TOKEN: '${{ env.github-token }}' |
| 26 | + Build-Beta: |
| 27 | + if: ${{ !startsWith(github.head_ref, 'release/')}} |
| 28 | + runs-on: ubuntu-latest |
| 29 | + outputs: |
| 30 | + semVersion: ${{ steps.gitversion.outputs.MajorMinorPatch }} |
| 31 | + branchName: ${{ steps.gitversion.outputs.branchName }} |
| 32 | + env: |
| 33 | + working-directory: /home/runner/work/FileUtil.Core/FileUtil.Core |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Step-01 Install GitVersion |
| 37 | + uses: gittools/actions/gitversion/[email protected] |
| 38 | + with: |
| 39 | + versionSpec: 5.x |
| 40 | + |
| 41 | + - name: Step-02 Check out Code |
| 42 | + uses: actions/checkout@v2 |
| 43 | + with: |
| 44 | + fetch-depth: 0 |
| 45 | + |
| 46 | + - name: Step-03 Calculate Version |
| 47 | + id: gitversion |
| 48 | + uses: gittools/actions/gitversion/[email protected] |
| 49 | + with: |
| 50 | + useConfigFile: true |
| 51 | + |
| 52 | + - name: Step-04 Install .NET |
| 53 | + uses: actions/setup-dotnet@v3 |
| 54 | + with: |
| 55 | + dotnet-version: 6.0.x |
| 56 | + |
| 57 | + - name: Step-05 Restore dependencies |
| 58 | + run: dotnet restore |
| 59 | + working-directory: '${{ env.working-directory }}' |
| 60 | + |
| 61 | + - name: Step-06 Build Beta Version |
| 62 | + run: dotnet build --configuration Release --no-restore -p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersion }} |
| 63 | + working-directory: '${{ env.working-directory }}' |
| 64 | + |
| 65 | + - name: Step-07 Test Solution |
| 66 | + run: dotnet test --configuration Release --no-build --no-restore --verbosity normal |
| 67 | + working-directory: '${{ env.working-directory }}' |
| 68 | + |
| 69 | + - name: Step-08 Upload Build Artifacts |
| 70 | + uses: actions/upload-artifact@v3 |
| 71 | + with: |
| 72 | + name: build-artifact |
| 73 | + path: ${{env.working-directory}} |
| 74 | + retention-days: 1 |
| 75 | + Build-Release: |
| 76 | + if: ${{ startsWith(github.head_ref, 'release/') }} |
| 77 | + runs-on: ubuntu-latest |
| 78 | + outputs: |
| 79 | + semVersion: ${{ steps.gitversion.outputs.MajorMinorPatch }} |
| 80 | + branchName: ${{ steps.gitversion.outputs.branchName }} |
| 81 | + env: |
| 82 | + working-directory: /home/runner/work/FileUtil.Core/FileUtil.Core |
| 83 | + |
| 84 | + steps: |
| 85 | + - name: Step-01 Install GitVersion |
| 86 | + uses: gittools/actions/gitversion/[email protected] |
| 87 | + with: |
| 88 | + versionSpec: 5.x |
| 89 | + |
| 90 | + - name: Step-02 Check out Code |
| 91 | + uses: actions/checkout@v2 |
| 92 | + with: |
| 93 | + fetch-depth: 0 |
| 94 | + |
| 95 | + - name: Step-03 Calculate Version |
| 96 | + id: gitversion |
| 97 | + uses: gittools/actions/gitversion/[email protected] |
| 98 | + with: |
| 99 | + useConfigFile: true |
| 100 | + |
| 101 | + - name: Step-04 Install .NET |
| 102 | + uses: actions/setup-dotnet@v3 |
| 103 | + with: |
| 104 | + dotnet-version: 6.0.x |
| 105 | + |
| 106 | + - name: Step-05 Restore dependencies |
| 107 | + run: dotnet restore |
| 108 | + working-directory: '${{ env.working-directory }}' |
| 109 | + |
| 110 | + - name: Step-06 Build Release Version |
| 111 | + if: ('startsWith(github.ref, ''refs/heads/release'')') |
| 112 | + run: dotnet build --configuration Release --no-restore -p:PackageVersion=${{ steps.gitversion.outputs.MajorMinorPatch }} |
| 113 | + working-directory: '${{ env.working-directory }}' |
| 114 | + |
| 115 | + - name: Step-07 Test Solution |
| 116 | + run: dotnet test --configuration Release --no-build --no-restore --verbosity normal |
| 117 | + working-directory: '${{ env.working-directory }}' |
| 118 | + |
| 119 | + - name: Step-08 Upload Build Artifacts |
| 120 | + uses: actions/upload-artifact@v3 |
| 121 | + with: |
| 122 | + name: build-artifact |
| 123 | + path: ${{env.working-directory}} |
| 124 | + retention-days: 1 |
| 125 | + Package-Release: |
| 126 | + needs: [Build-Beta, Build-Release] |
| 127 | + if: | |
| 128 | + always() && |
| 129 | + (needs.Build-Beta.result == 'success' || needs.Build-Release.result == 'success') |
| 130 | + runs-on: ubuntu-latest |
| 131 | + outputs: |
| 132 | + semVersion: ${{ needs.Build-Release.outputs.semVersion }} |
| 133 | + env: |
| 134 | + github-token: '${{ secrets.GITHUB_TOKEN }}' |
| 135 | + nuget-token: '${{ secrets.NUGET_API_KEY }}' |
| 136 | + working-directory: /home/runner/work/FileUtil.Core/FileUtil.Core |
| 137 | + steps: |
| 138 | + - name: Step-01 Retrieve Build Artifacts |
| 139 | + uses: actions/download-artifact@v3 |
| 140 | + with: |
| 141 | + name: build-artifact |
| 142 | + path: ${{env.working-directory}} |
| 143 | + |
| 144 | + - name: Step-02 Install Github Packages |
| 145 | + run: dotnet tool install gpr --global |
| 146 | + |
| 147 | + - name: Step-03 Publish to Github Packages |
| 148 | + run: find -name "*.nupkg" -print -exec gpr push -k ${{env.github-token}} {} \; |
| 149 | + |
| 150 | + - name: Step-02 Create Github Release |
| 151 | + if: ${{ startsWith(github.head_ref, 'release/')}} |
| 152 | + run: | |
| 153 | + curl \ |
| 154 | + -X POST \ |
| 155 | + -H "Accept:application/vnd.github+json" \ |
| 156 | + -H "Authorization:token ${{ env.github-token }}" \ |
| 157 | + https://api.github.com/ninjarocks/FileUtil.Core/releases \ |
| 158 | + -d '{"tag_name":v1.0.0,"target_commitish":"master","name":"FileUtil.Core","body":"","draft":false,"prerelease":false,"generate_release_notes":false}' |
| 159 | +
|
| 160 | + - name: Step-03 Release to Nuget Org |
| 161 | + if: ${{ startsWith(github.head_ref, 'release/')}} |
| 162 | + run: dotnet nuget push ${{env.working-directory}}/src/FileUtil.Core/bin/Release/*.nupkg --skip-duplicate --api-key ${{ env.nuget-token }} --source https://api.nuget.org/v3/index.json |
0 commit comments