|
| 1 | +name: "Build and Validate" |
| 2 | + |
| 3 | +env: |
| 4 | + CAKE_TARGET: "BuildAll" |
| 5 | + CAKE_VERBOSITY: "Normal" |
| 6 | + RELEASE_MODE: "Beta" |
| 7 | + RUN_TESTS: "true" |
| 8 | + |
| 9 | +permissions: |
| 10 | + checks: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: |
| 20 | + - "develop" |
| 21 | + - "release/*" |
| 22 | + pull_request: |
| 23 | + branches: |
| 24 | + - "develop" |
| 25 | + - "release/*" |
| 26 | + workflow_dispatch: |
| 27 | + inputs: |
| 28 | + CAKE_TARGET: |
| 29 | + description: "Cake Target" |
| 30 | + type: "string" |
| 31 | + default: "BuildAll" |
| 32 | + CAKE_VERBOSITY: |
| 33 | + description: "Cake Verbosity" |
| 34 | + type: "choice" |
| 35 | + default: "Normal" |
| 36 | + options: |
| 37 | + - "Quiet" |
| 38 | + - "Minimal" |
| 39 | + - "Normal" |
| 40 | + - "Verbose" |
| 41 | + - "Diagnostic" |
| 42 | + RELEASE_MODE: |
| 43 | + description: "Release Mode" |
| 44 | + type: "choice" |
| 45 | + default: "Beta" |
| 46 | + options: |
| 47 | + - "Alpha" |
| 48 | + - "Beta" |
| 49 | + - "RC" |
| 50 | + - "Stable" |
| 51 | + RUN_TESTS: |
| 52 | + description: "Run Tests?" |
| 53 | + type: boolean |
| 54 | + default: true |
| 55 | + |
| 56 | +jobs: |
| 57 | + build-and-validate: |
| 58 | + name: "Build and Validate" |
| 59 | + runs-on: "windows-2025-vs2026" |
| 60 | + defaults: |
| 61 | + run: |
| 62 | + shell: "pwsh" |
| 63 | + steps: |
| 64 | + - name: "Checkout" |
| 65 | + uses: "actions/checkout@v6.0.2" |
| 66 | + |
| 67 | + # Built-in caching is broken for Yarn, using setup-node twice |
| 68 | + # See https://github.com/actions/setup-node/issues/531#issuecomment-3335630863 |
| 69 | + - name: "Setup Node.js" |
| 70 | + uses: "actions/setup-node@v6.3.0" |
| 71 | + with: |
| 72 | + node-version-file: ".node-version" |
| 73 | + package-manager-cache: false |
| 74 | + |
| 75 | + - name: "Enable Corepack" |
| 76 | + run: "corepack enable" |
| 77 | + |
| 78 | + - name: "Setup Yarn cache" |
| 79 | + uses: "actions/setup-node@v6.3.0" |
| 80 | + with: |
| 81 | + cache: "yarn" |
| 82 | + |
| 83 | + - name: "Setup .NET SDK" |
| 84 | + uses: "actions/setup-dotnet@v5.2.0" |
| 85 | + with: |
| 86 | + global-json-file: "global.json" |
| 87 | + |
| 88 | + - name: "Initialize Git User" |
| 89 | + run: | |
| 90 | + git config --global user.email 'noreply@dnncommunity.org'; |
| 91 | + git config --global user.name 'DNN Platform CI Bot'; |
| 92 | +
|
| 93 | + - name: "Update Alpha/Beta/Stable flag" |
| 94 | + run: | |
| 95 | + $path = '.\DNN Platform\Library\Properties\AssemblyInfo.cs' |
| 96 | + $pattern3 = '\[assembly: AssemblyStatus' |
| 97 | + (Get-Content $path) | ForEach-Object { |
| 98 | + if ($_ -match $pattern3) { |
| 99 | + # We have found the matching line |
| 100 | + '[assembly: AssemblyStatus(ReleaseMode.{0})]' -f '${{ env.RELEASE_MODE }}' |
| 101 | + } else { |
| 102 | + $_ |
| 103 | + } |
| 104 | + } | Set-Content $path |
| 105 | +
|
| 106 | + - name: "Run DNN Build via Cake" |
| 107 | + run: "./build.ps1 --target=${{ env.CAKE_TARGET }} --verbosity=${{ env.CAKE_VERBOSITY }}" |
| 108 | + |
| 109 | + - name: "Run Unit Tests via Cake" |
| 110 | + if: ${{ env.RUN_TESTS == 'true' }} |
| 111 | + run: "./build.ps1 --target=UnitTests --verbosity=${{ env.CAKE_VERBOSITY }}" |
| 112 | + continue-on-error: true |
| 113 | + |
| 114 | + - name: "Publish Test Results" |
| 115 | + uses: "EnricoMi/publish-unit-test-result-action/windows@v2.23.0" |
| 116 | + if: ${{ !cancelled() && env.RUN_TESTS == 'true' }} |
| 117 | + with: |
| 118 | + files: "**/TestResults/*.trx" |
| 119 | + action_fail: true |
| 120 | + |
| 121 | + - name: "Publish Artifacts" |
| 122 | + uses: "actions/upload-artifact@v7.0.0" |
| 123 | + if: ${{ !cancelled() }} |
| 124 | + with: |
| 125 | + path: "Artifacts" |
| 126 | + if-no-files-found: "error" |
| 127 | + compression-level: "0" |
| 128 | + overwrite: true |
| 129 | + |
| 130 | + - name: "Create GitHub Pull Request" |
| 131 | + if: ${{ success() && !contains('pull_request', github.event_name) && (contains(fromJSON('["develop", "main"]'), github.ref_name) || startsWith('release/', github.ref_name)) }} |
| 132 | + run: "./build.ps1 --target=CreateGitHubPullRequest --verbosity=${{ env.CAKE_VERBOSITY }}" |
| 133 | + env: |
| 134 | + GITHUB_APP_ID: ${{ secrets.GITHUB_APP_ID }} |
| 135 | + GITHUB_APP_PRIVATE_KEY: ${{ secrets.GITHUB_APP_PRIVATE_KEY }} |
0 commit comments