doxygen ci cd #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Windows Build | |
on: | |
push: | |
branches: [main, master, develop] # Trigger on pushes to main branches | |
tags: | |
- v*.*.* # Also trigger on version tags for releases | |
pull_request: | |
branches: [main, master] # Also trigger on PRs to main branches | |
jobs: | |
build: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
configuration: [Release, Debug] | |
steps: | |
# Step 1: Checkout the repository | |
- uses: actions/checkout@v4 | |
name: Checkout the repository | |
# Step 2: Setup CMake (same as AppVeyor) | |
- name: Setup CMake | |
uses: jwlawson/[email protected] | |
with: | |
cmake-version: 3.28.0 | |
# Step 3: Verify CMake (same as AppVeyor) | |
- name: Verify CMake | |
run: cmake --version | |
# Step 4: Configure with CMake presets (same as AppVeyor) | |
- name: Configure CMake | |
run: cmake --preset ninja-multi | |
# Step 5: Build with CMake presets (same as AppVeyor) | |
- name: Build with CMake | |
run: | | |
if ("${{ matrix.configuration }}" -eq "Debug") { cmake --build --preset ninja-multi-debug } | |
if ("${{ matrix.configuration }}" -eq "Release") { cmake --build --preset ninja-multi-release } | |
# Step 6: Generate Doxygen documentation | |
- name: Generate Doxygen documentation | |
run: | | |
# Install Doxygen if not available | |
if (-not (Get-Command doxygen -ErrorAction SilentlyContinue)) { | |
choco install doxygen.portable -y | |
} | |
# Create docs directory if it doesn't exist | |
New-Item -ItemType Directory -Force -Path docs | |
# Update Doxyfile for Windows environment | |
$doxyfile = Get-Content Doxyfile -Raw | |
$doxyfile = $doxyfile -replace '/cpp_tutorials/src', 'src' | |
$doxyfile = $doxyfile -replace '/cpp_tutorials/docs', 'docs' | |
$doxyfile = $doxyfile -replace 'OUTPUT_DIRECTORY\s*=\s*\.', 'OUTPUT_DIRECTORY = docs' | |
$doxyfile = $doxyfile -replace 'OUTPUT_TEXT_DIRECTION\s*=\s*None', '# OUTPUT_TEXT_DIRECTION = None' | |
$doxyfile = $doxyfile -replace 'HTML_TIMESTAMP\s*=\s*NO', '# HTML_TIMESTAMP = NO' | |
$doxyfile = $doxyfile -replace 'FORMULA_TRANSPARENT\s*=\s*YES', '# FORMULA_TRANSPARENT = YES' | |
$doxyfile = $doxyfile -replace 'LATEX_SOURCE_CODE\s*=\s*NO', '# LATEX_SOURCE_CODE = NO' | |
$doxyfile = $doxyfile -replace 'LATEX_TIMESTAMP\s*=\s*NO', '# LATEX_TIMESTAMP = NO' | |
$doxyfile = $doxyfile -replace 'RTF_SOURCE_CODE\s*=\s*NO', '# RTF_SOURCE_CODE = NO' | |
$doxyfile = $doxyfile -replace 'DOCBOOK_PROGRAMLISTING\s*=\s*NO', '# DOCBOOK_PROGRAMLISTING = NO' | |
$doxyfile = $doxyfile -replace 'CLASS_DIAGRAMS\s*=\s*YES', '# CLASS_DIAGRAMS = YES' | |
$doxyfile = $doxyfile -replace 'DOT_FONTNAME\s*=\s*Helvetica', '# DOT_FONTNAME = Helvetica' | |
$doxyfile = $doxyfile -replace 'DOT_FONTSIZE\s*=\s*10', '# DOT_FONTSIZE = 10' | |
$doxyfile = $doxyfile -replace 'DOT_TRANSPARENT\s*=\s*NO', '# DOT_TRANSPARENT = NO' | |
$doxyfile = $doxyfile -replace 'HAVE_DOT\s*=\s*YES', 'HAVE_DOT = NO' | |
# Write updated Doxyfile | |
$doxyfile | Out-File -FilePath Doxyfile.windows -Encoding UTF8 | |
# Run Doxygen with updated config | |
doxygen Doxyfile.windows | |
# Step 7: Upload documentation as an artifact | |
- name: Upload documentation | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cpp_documentation_windows_${{ matrix.configuration }} | |
path: docs | |
# Step 8: Upload build artifacts as an artifact | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cpp_build_output_windows_${{ matrix.configuration }} | |
path: build | |
release: | |
needs: build | |
runs-on: windows-latest | |
if: startsWith(github.ref, 'refs/tags/') # Only run on tag pushes | |
steps: | |
# Step 1: Checkout the repository | |
- uses: actions/checkout@v4 | |
name: Checkout the repository | |
# Step 2: Create a GitHub release using the version tag (e.g., v1.0.0, v1.0.1) | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} # Use just the tag name (e.g., v1.0.0) | |
release_name: Release ${{ github.ref_name }} # Name the release after the tag (e.g., v1.0.0) | |
body: | | |
Release notes for version ${{ github.ref_name }}. | |
draft: false | |
prerelease: false | |
# Step 3: Upload build artifacts to release | |
- name: Upload build artifacts to release | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: build/Release/main.exe # Adjust to your actual file | |
asset_name: main_windows.exe # Adjust this to name the artifact file | |
asset_content_type: application/octet-stream | |
# Step 4: Upload documentation to release | |
- name: Upload documentation to release | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: docs | |
asset_name: cpp_documentation_windows | |
asset_content_type: application/zip |