|
| 1 | +name: Windows Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, master, develop] # Trigger on pushes to main branches |
| 6 | + tags: |
| 7 | + - v*.*.* # Also trigger on version tags for releases |
| 8 | + pull_request: |
| 9 | + branches: [main, master] # Also trigger on PRs to main branches |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: windows-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + # Step 1: Checkout the repository |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + name: Checkout the repository |
| 19 | + |
| 20 | + # Step 2: Setup CMake |
| 21 | + - name: Setup CMake |
| 22 | + uses: jwlawson/actions-setup-cmake@v1.14 |
| 23 | + with: |
| 24 | + cmake-version: 3.28.0 |
| 25 | + |
| 26 | + # Step 3: Setup Ninja |
| 27 | + - name: Setup Ninja |
| 28 | + uses: actions/setup-python@v5 |
| 29 | + with: |
| 30 | + python-version: "3.11" |
| 31 | + |
| 32 | + - name: Install Ninja |
| 33 | + run: | |
| 34 | + python -m pip install ninja |
| 35 | + echo "$env:LOCALAPPDATA\Python\Python311\Scripts" >> $env:GITHUB_PATH |
| 36 | +
|
| 37 | + # Step 4: Verify tools availability |
| 38 | + - name: Verify tools |
| 39 | + run: | |
| 40 | + cmake --version |
| 41 | + ninja --version |
| 42 | +
|
| 43 | + # Step 5: Configure CMake |
| 44 | + - name: Configure CMake |
| 45 | + run: cmake -S . -G "Ninja Multi-Config" -B build |
| 46 | + |
| 47 | + # Step 6: Build with CMake |
| 48 | + - name: Build with CMake |
| 49 | + run: cmake --build build --config Release |
| 50 | + |
| 51 | + # Step 7: Verify if build files are generated |
| 52 | + - name: List build directory contents |
| 53 | + run: Get-ChildItem -Path build -Recurse | Select-Object Name, FullName |
| 54 | + |
| 55 | + # Step 8: Generate Doxygen documentation |
| 56 | + - name: Generate Doxygen documentation |
| 57 | + run: | |
| 58 | + # Install Doxygen if not available |
| 59 | + if (-not (Get-Command doxygen -ErrorAction SilentlyContinue)) { |
| 60 | + choco install doxygen.portable -y |
| 61 | + } |
| 62 | + doxygen Doxyfile |
| 63 | +
|
| 64 | + # Step 9: Verify if documentation files are generated |
| 65 | + - name: List documentation directory contents |
| 66 | + run: Get-ChildItem -Path docs -Recurse | Select-Object Name, FullName |
| 67 | + |
| 68 | + # Step 10: Upload documentation as an artifact (if files exist) |
| 69 | + - name: Upload documentation |
| 70 | + uses: actions/upload-artifact@v4 |
| 71 | + with: |
| 72 | + name: cpp_documentation_windows |
| 73 | + path: docs |
| 74 | + |
| 75 | + # Step 11: Upload build artifacts as an artifact (if files exist) |
| 76 | + - name: Upload build artifacts |
| 77 | + uses: actions/upload-artifact@v4 |
| 78 | + with: |
| 79 | + name: cpp_build_output_windows |
| 80 | + path: build |
| 81 | + |
| 82 | + release: |
| 83 | + needs: build |
| 84 | + runs-on: windows-latest |
| 85 | + if: startsWith(github.ref, 'refs/tags/') # Only run on tag pushes |
| 86 | + |
| 87 | + steps: |
| 88 | + # Step 1: Checkout the repository |
| 89 | + - uses: actions/checkout@v4 |
| 90 | + name: Checkout the repository |
| 91 | + |
| 92 | + # Step 2: Create a GitHub release using the version tag (e.g., v1.0.0, v1.0.1) |
| 93 | + - name: Create Release |
| 94 | + id: create_release |
| 95 | + uses: actions/create-release@v1 |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + with: |
| 99 | + tag_name: ${{ github.ref_name }} # Use just the tag name (e.g., v1.0.0) |
| 100 | + release_name: Release ${{ github.ref_name }} # Name the release after the tag (e.g., v1.0.0) |
| 101 | + body: | |
| 102 | + Release notes for version ${{ github.ref_name }}. |
| 103 | + draft: false |
| 104 | + prerelease: false |
| 105 | + |
| 106 | + # Step 3: Upload build artifacts to release |
| 107 | + - name: Upload build artifacts to release |
| 108 | + uses: actions/upload-release-asset@v1 |
| 109 | + with: |
| 110 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 111 | + asset_path: build/Release/main.exe # Adjust to your actual file |
| 112 | + asset_name: main_windows.exe # Adjust this to name the artifact file |
| 113 | + asset_content_type: application/octet-stream |
| 114 | + |
| 115 | + # Step 4: Upload documentation to release |
| 116 | + - name: Upload documentation to release |
| 117 | + uses: actions/upload-release-asset@v1 |
| 118 | + with: |
| 119 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 120 | + asset_path: docs |
| 121 | + asset_name: cpp_documentation_windows |
| 122 | + asset_content_type: application/zip |
0 commit comments