|
| 1 | +name: Build and Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + Build: |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + os: [windows-latest, windows-11-arm] |
| 18 | + platform: [x64, x86, ARM64, ARM64EC] |
| 19 | + config: [Debug, Release] |
| 20 | + fail-fast: false |
| 21 | + runs-on: ${{matrix.os}} |
| 22 | + steps: |
| 23 | + - name: Source checkout |
| 24 | + uses: actions/checkout@main |
| 25 | + with: |
| 26 | + submodules: recursive |
| 27 | + - name: Prepare MSBuild |
| 28 | + uses: microsoft/setup-msbuild@main |
| 29 | + - name: Build |
| 30 | + run: msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=${{matrix.config}} /p:Platform=${{matrix.platform}} /p:RestorePackagesConfig=true |
| 31 | + - name: Run Unit Test |
| 32 | + if: ${{(matrix.os == 'windows-latest' && (matrix.platform == 'x64' || matrix.platform == 'x86') || matrix.os == 'windows-11-arm')}} |
| 33 | + run: .\Source\OutDir\${{matrix.platform}}\${{matrix.config}}\UnitTest.exe -Run |
| 34 | + Publish: |
| 35 | + if: ${{github.base_ref == '' && startsWith(github.event.head_commit.message, '[VERSION] ')}} |
| 36 | + needs: Build |
| 37 | + permissions: |
| 38 | + contents: write |
| 39 | + runs-on: windows-latest |
| 40 | + steps: |
| 41 | + - name: Set release version |
| 42 | + id: relver |
| 43 | + shell: pwsh |
| 44 | + run: | |
| 45 | + $relver="${{github.event.head_commit.message}}".Substring(10) |
| 46 | + Write-Output "relver=$relver">>$env:GITHUB_OUTPUT |
| 47 | + - name: Source checkout |
| 48 | + uses: actions/checkout@main |
| 49 | + with: |
| 50 | + submodules: recursive |
| 51 | + - name: Prepare MSBuild |
| 52 | + uses: microsoft/setup-msbuild@main |
| 53 | + - name: Build |
| 54 | + run: | |
| 55 | + msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=Release /p:Platform=x64 /p:RestorePackagesConfig=true |
| 56 | + msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=Release /p:Platform=x86 /p:RestorePackagesConfig=true |
| 57 | + msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=Release /p:Platform=ARM64 /p:RestorePackagesConfig=true |
| 58 | + msbuild .\Source\KNSoft.NDK.sln /restore /m /p:Configuration=Release /p:Platform=ARM64EC /p:RestorePackagesConfig=true |
| 59 | + - name: Run Unit Test |
| 60 | + run: | |
| 61 | + .\Source\OutDir\x64\Release\UnitTest.exe -Run |
| 62 | + .\Source\OutDir\x86\Release\UnitTest.exe -Run |
| 63 | + - name: Create NuGet package |
| 64 | + run: | |
| 65 | + cd .\Source |
| 66 | + nuget pack |
| 67 | + - name: Create release |
| 68 | + uses: softprops/action-gh-release@v2 |
| 69 | + with: |
| 70 | + name: v${{steps.relver.outputs.relver}} |
| 71 | + tag_name: v${{steps.relver.outputs.relver}} |
| 72 | + body: "**NuGet Package**: https://www.nuget.org/packages/KNSoft.NDK/${{steps.relver.outputs.relver}}" |
| 73 | + prerelease: true |
| 74 | + preserve_order: true |
| 75 | + fail_on_unmatched_files: true |
| 76 | + generate_release_notes: true |
| 77 | + files: ./Source/KNSoft.NDK.${{steps.relver.outputs.relver}}.nupkg |
0 commit comments