|
| 1 | +name: ClassLibrary1 CI/CD Pipeline |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main] |
| 5 | + paths-ignore: |
| 6 | + - .codecov |
| 7 | + - .docfx |
| 8 | + - .github |
| 9 | + - .nuget |
| 10 | + pull_request: |
| 11 | + branches: [main] |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + configuration: |
| 15 | + type: choice |
| 16 | + description: The build configuration to use in the deploy stage. |
| 17 | + required: true |
| 18 | + default: Release |
| 19 | + options: |
| 20 | + - Debug |
| 21 | + - Release |
| 22 | + |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + name: 🛠️ Build |
| 26 | + runs-on: ubuntu-22.04 |
| 27 | + outputs: |
| 28 | + version: ${{ steps.minver-calculate.outputs.version }} |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: codebeltnet/git-checkout@main |
| 32 | + |
| 33 | + - name: Install .NET |
| 34 | + uses: codebeltnet/install-dotnet@main |
| 35 | + |
| 36 | + - name: Install MinVer |
| 37 | + uses: codebeltnet/dotnet-tool-install-minver@main |
| 38 | + |
| 39 | + - id: minver-calculate |
| 40 | + name: Calculate Version |
| 41 | + uses: codebeltnet/minver-calculate@main |
| 42 | + |
| 43 | + - name: Download sharedkernel.snk file |
| 44 | + uses: codebeltnet/gcp-download-file@main |
| 45 | + with: |
| 46 | + serviceAccountKey: ${{ secrets.GCP_TOKEN }} |
| 47 | + bucketName: ${{ secrets.GCP_BUCKETNAME }} |
| 48 | + objectName: sharedkernel.snk |
| 49 | + |
| 50 | + - name: Restore Dependencies |
| 51 | + uses: codebeltnet/dotnet-restore@main |
| 52 | + |
| 53 | + - name: Build for Preview |
| 54 | + uses: codebeltnet/dotnet-build@main |
| 55 | + with: |
| 56 | + configuration: Debug |
| 57 | + |
| 58 | + - name: Build for Production |
| 59 | + uses: codebeltnet/dotnet-build@main |
| 60 | + with: |
| 61 | + configuration: Release |
| 62 | + |
| 63 | + pack: |
| 64 | + name: 📦 Pack |
| 65 | + runs-on: ubuntu-22.04 |
| 66 | + strategy: |
| 67 | + matrix: |
| 68 | + configuration: [Debug, Release] |
| 69 | + needs: [build] |
| 70 | + steps: |
| 71 | + - name: Pack for ${{ matrix.configuration }} |
| 72 | + uses: codebeltnet/dotnet-pack@main |
| 73 | + with: |
| 74 | + configuration: ${{ matrix.configuration }} |
| 75 | + uploadPackedArtifact: true |
| 76 | + version: ${{ needs.build.outputs.version }} |
| 77 | + |
| 78 | + test: |
| 79 | + name: 🧪 Test |
| 80 | + needs: [build] |
| 81 | + strategy: |
| 82 | + matrix: |
| 83 | + os: [ubuntu-22.04, windows-2022] |
| 84 | + runs-on: ${{ matrix.os }} |
| 85 | + steps: |
| 86 | + - name: Checkout |
| 87 | + uses: codebeltnet/git-checkout@main |
| 88 | + |
| 89 | + - name: Install .NET |
| 90 | + uses: codebeltnet/install-dotnet@main |
| 91 | + |
| 92 | + - name: Install .NET Tool - Report Generator |
| 93 | + uses: codebeltnet/dotnet-tool-install-reportgenerator@main |
| 94 | + |
| 95 | + - name: Test with Debug build |
| 96 | + uses: codebeltnet/dotnet-test@main |
| 97 | + with: |
| 98 | + configuration: Debug |
| 99 | + buildSwitches: -p:SkipSignAssembly=true |
| 100 | + |
| 101 | + - name: Test with Release build |
| 102 | + uses: codebeltnet/dotnet-test@main |
| 103 | + with: |
| 104 | + configuration: Release |
| 105 | + buildSwitches: -p:SkipSignAssembly=true |
| 106 | + |
| 107 | + sonarcloud: |
| 108 | + name: 🔬 Code Quality Analysis |
| 109 | + needs: [build,test] |
| 110 | + runs-on: ubuntu-22.04 |
| 111 | + steps: |
| 112 | + - name: Checkout |
| 113 | + uses: codebeltnet/git-checkout@main |
| 114 | + |
| 115 | + - name: Install .NET |
| 116 | + uses: codebeltnet/install-dotnet@main |
| 117 | + |
| 118 | + - name: Install .NET Tool - Sonar Scanner |
| 119 | + uses: codebeltnet/dotnet-tool-install-sonarscanner@main |
| 120 | + |
| 121 | + - name: Restore Dependencies |
| 122 | + uses: codebeltnet/dotnet-restore@main |
| 123 | + |
| 124 | + - name: Run SonarCloud Analysis |
| 125 | + uses: codebeltnet/sonarcloud-scan@main |
| 126 | + with: |
| 127 | + token: ${{ secrets.SONAR_TOKEN }} |
| 128 | + organization: geekle |
| 129 | + projectKey: sharedkernel |
| 130 | + version: ${{ needs.build.outputs.version }} |
| 131 | + |
| 132 | + - name: Build |
| 133 | + uses: codebeltnet/dotnet-build@main |
| 134 | + with: |
| 135 | + buildSwitches: -p:SkipSignAssembly=true |
| 136 | + uploadBuildArtifact: false |
| 137 | + |
| 138 | + - name: Finalize SonarCloud Analysis |
| 139 | + uses: codebeltnet/sonarcloud-scan-finalize@main |
| 140 | + with: |
| 141 | + token: ${{ secrets.SONAR_TOKEN }} |
| 142 | + |
| 143 | + codecov: |
| 144 | + name: 📊 Code Coverage Analysis |
| 145 | + needs: [build,test] |
| 146 | + runs-on: ubuntu-22.04 |
| 147 | + steps: |
| 148 | + - name: Checkout |
| 149 | + uses: codebeltnet/git-checkout@main |
| 150 | + |
| 151 | + - name: Run CodeCov Analysis |
| 152 | + uses: codebeltnet/codecov-scan@main |
| 153 | + with: |
| 154 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 155 | + repository: codebeltnet/shared-kernel |
| 156 | + |
| 157 | + codeql: |
| 158 | + name: 🛡️ Security Analysis |
| 159 | + needs: [build,test] |
| 160 | + runs-on: ubuntu-22.04 |
| 161 | + steps: |
| 162 | + - name: Checkout |
| 163 | + uses: codebeltnet/git-checkout@main |
| 164 | + |
| 165 | + - name: Install .NET |
| 166 | + uses: codebeltnet/install-dotnet@main |
| 167 | + |
| 168 | + - name: Restore Dependencies |
| 169 | + uses: codebeltnet/dotnet-restore@main |
| 170 | + |
| 171 | + - name: Prepare CodeQL SAST Analysis |
| 172 | + uses: codebeltnet/codeql-scan@main |
| 173 | + |
| 174 | + - name: Build |
| 175 | + uses: codebeltnet/dotnet-build@main |
| 176 | + with: |
| 177 | + buildSwitches: -p:SkipSignAssembly=true |
| 178 | + uploadBuildArtifact: false |
| 179 | + |
| 180 | + - name: Finalize CodeQL SAST Analysis |
| 181 | + uses: codebeltnet/codeql-scan-finalize@main |
| 182 | + |
| 183 | + deploy: |
| 184 | + name: 🚀 Deploy v${{ needs.build.outputs.version }} |
| 185 | + runs-on: ubuntu-22.04 |
| 186 | + needs: [build,pack,test,sonarcloud,codecov,codeql] |
| 187 | + environment: Production |
| 188 | + steps: |
| 189 | + - uses: codebeltnet/nuget-push@main |
| 190 | + with: |
| 191 | + token: ${{ secrets.NUGET_TOKEN }} |
| 192 | + configuration: ${{ inputs.configuration == '' && 'Release' || inputs.configuration }} |
0 commit comments