Repository navigation
Updated: 更新版本到 0.2.0 #102
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: Build | |
| on: | |
| workflow_call: | |
| push: | |
| branches: | |
| - main | |
| - beta | |
| pull_request: | |
| branches: | |
| - main | |
| - beta | |
| jobs: | |
| env-linux: | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| runner: ubuntu-latest | |
| - arch: arm64 | |
| runner: ubuntu-24.04-arm | |
| steps: | |
| - name: pull project | |
| uses: actions/checkout@v7 | |
| - name: Install requirements | |
| shell: bash | |
| run: | | |
| sudo apt update | |
| sudo apt install -y build-essential git cmake make ninja-build libgpm-dev gpm googletest libgtest-dev libgmock-dev | |
| - name: Compiling project | |
| shell: bash | |
| run: | | |
| mkdir -p ~/MyLibs/ | |
| cmake -B build -DCMAKE_INSTALL_PREFIX=~/MyLibs/Tiny.cpp \ | |
| -DCMAKE_BUILD_TYPE=Debug -DTINY_USE_GPM=ON \ | |
| -DTINY_GTEST_SRC=OFF | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to configure project!" | |
| exit 1 | |
| fi | |
| cmake --build build --target install -j8 | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to compile and install!" | |
| exit 1 | |
| fi | |
| - name: Test for project | |
| shell: bash | |
| run: | | |
| cd build/bin/gtests | |
| TIMEZONE=`curl ipconfig.io/json | grep time_zone | cut -d'"' -f4` | |
| sudo rm -f /etc/localtime | |
| sudo ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime | |
| for EXE in $(ls -1); do | |
| ./$EXE | |
| if [ $? -ne 0 ]; then | |
| echo "* Test failed: " $EXE | |
| exit 1 | |
| fi | |
| sleep 1 | |
| done | |
| - name: Get version | |
| id: version | |
| shell: bash | |
| run: | | |
| VERSION=$(tr -d '[:space:]' < .github/current_version.txt) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Package artifact | |
| id: package | |
| shell: bash | |
| run: | | |
| cd ~/MyLibs | |
| ARTIFACT_NAME="Tiny_cpp_v${{ steps.version.outputs.version }}_linux_${{ matrix.arch }}" | |
| tar -czf ${ARTIFACT_NAME}.tar.gz Tiny.cpp | |
| echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ steps.package.outputs.artifact_name }} | |
| path: ~/MyLibs/${{ steps.package.outputs.artifact_name }}.tar.gz | |
| env-macos: | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| runner: macos-15-intel | |
| - arch: arm64 | |
| runner: macos-latest | |
| steps: | |
| - name: pull project | |
| uses: actions/checkout@v7 | |
| - name: Install requirements | |
| shell: bash | |
| run: | | |
| brew install cmake ninja googletest | |
| - name: Compiling project | |
| shell: bash | |
| run: | | |
| mkdir -p ~/MyLibs/ | |
| cmake -B build -DCMAKE_INSTALL_PREFIX=~/MyLibs/Tiny.cpp -DCMAKE_BUILD_TYPE=Debug -DTINY_GTEST_SRC=OFF | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to configure project!" | |
| exit 1 | |
| fi | |
| cmake --build build --target install -j8 | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to compile and install!" | |
| exit 1 | |
| fi | |
| - name: Test for project | |
| shell: bash | |
| run: | | |
| cd build/bin/gtests | |
| sudo rm -rf /etc/localtime | |
| TIMEZONE=`curl ipconfig.io/json | grep time_zone | cut -d'"' -f4` | |
| sudo ln -s /usr/share/zoneinfo/$TIMEZONE /etc/localtime | |
| for EXE in $(ls -1); do | |
| ./$EXE | |
| if [ $? -ne 0 ]; then | |
| echo "* Test failed: " $EXE | |
| exit 1 | |
| fi | |
| sleep 1 | |
| done | |
| - name: Get version | |
| id: version | |
| shell: bash | |
| run: | | |
| VERSION=$(tr -d '[:space:]' < .github/current_version.txt) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Package artifact | |
| id: package | |
| shell: bash | |
| run: | | |
| cd ~/MyLibs | |
| ARTIFACT_NAME="Tiny_cpp_v${{ steps.version.outputs.version }}_macos_${{ matrix.arch }}" | |
| tar -czf ${ARTIFACT_NAME}.tar.gz Tiny.cpp | |
| echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ steps.package.outputs.artifact_name }} | |
| path: ~/MyLibs/${{ steps.package.outputs.artifact_name }}.tar.gz | |
| env-freebsd: | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| runner: ubuntu-latest | |
| label_arch: x86_64 | |
| - arch: arm64 | |
| runner: ubuntu-latest | |
| label_arch: aarch64 | |
| steps: | |
| - name: pull project | |
| uses: actions/checkout@v7 | |
| - name: start VM | |
| id: env-freebsd | |
| uses: vmactions/freebsd-vm@v1 | |
| with: | |
| arch: ${{ matrix.label_arch }} | |
| sync: sshfs | |
| sync-time: true | |
| - name: Install requirements | |
| shell: freebsd {0} | |
| run: | | |
| pkg install -y cmake ninja googletest sudo curl | |
| - name: Compiling project | |
| shell: freebsd {0} | |
| run: | | |
| mkdir -p ~/MyLibs/ | |
| cmake -B build -DCMAKE_INSTALL_PREFIX=~/MyLibs/Tiny.cpp -DCMAKE_BUILD_TYPE=Debug -DTINY_GTEST_SRC=OFF | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to configure project!" | |
| exit 1 | |
| fi | |
| cmake --build build --target install -j8 | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to compile and install!" | |
| exit 1 | |
| fi | |
| # - name: Test for project | |
| # shell: freebsd {0} | |
| # run: | | |
| # cd build/bin/gtests | |
| # rm -rf /etc/localtime | |
| # TIMEZONE=`curl ipconfig.io/json | grep time_zone | cut -d'"' -f4` | |
| # ln -s /usr/share/zoneinfo/$TIMEZONE /etc/localtime | |
| # for EXE in $(ls -1); do | |
| # ./$EXE | |
| # if [ $? -ne 0 ]; then | |
| # echo "* Test failed: " $EXE | |
| # exit 1 | |
| # fi | |
| # sleep 1 | |
| # done | |
| - name: Get version | |
| id: version | |
| shell: freebsd {0} | |
| run: | | |
| VERSION=$(tr -d '[:space:]' < .github/current_version.txt) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Package artifact | |
| id: package | |
| shell: freebsd {0} | |
| run: | | |
| cd ~/MyLibs | |
| ARTIFACT_NAME="Tiny_cpp_v${{ steps.version.outputs.version }}_freebsd_${{ matrix.arch }}" | |
| tar -czf $GITHUB_WORKSPACE/${ARTIFACT_NAME}.tar.gz -C ~/MyLibs Tiny.cpp | |
| echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ steps.package.outputs.artifact_name }} | |
| path: ${{ github.workspace }}/${{ steps.package.outputs.artifact_name }}.tar.gz | |
| env-windows-msvc: | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| cmake_arch: x64 | |
| runner: windows-2022 | |
| package-arch: x64-windows | |
| - arch: arm64 | |
| cmake_arch: ARM64 | |
| runner: windows-11-arm | |
| package-arch: arm64-windows | |
| steps: | |
| - name: pull project | |
| uses: actions/checkout@v7 | |
| - name: setup Visual Studio | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: ${{ matrix.cmake_arch }} | |
| - name: Compiling project | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\MyLibs" | |
| cmake -B build -DCMAKE_INSTALL_PREFIX="$env:USERPROFILE\MyLibs\Tiny.cpp" -DCMAKE_BUILD_TYPE=Debug | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "* Failed to configure project!" | |
| exit 1 | |
| } | |
| cmake --build build --target install --config Debug -j8 | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "* Failed to compile and install!" | |
| exit 1 | |
| } | |
| - name: Test for project | |
| shell: pwsh | |
| run: | | |
| cd build\bin\gtests | |
| $exes = Get-ChildItem -Filter *.exe | |
| foreach ($exe in $exes) { | |
| & $exe.FullName | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "* Test failed: " $exe.Name | |
| exit 1 | |
| } | |
| } | |
| - name: Get version | |
| id: version | |
| shell: pwsh | |
| run: | | |
| $version = (Get-Content .github\current_version.txt -Raw).Trim() | |
| echo "version=$version" >> $env:GITHUB_OUTPUT | |
| - name: Package artifact | |
| id: package | |
| shell: pwsh | |
| run: | | |
| $libDir = Join-Path $env:USERPROFILE "MyLibs" | |
| $artifactName = "Tiny_cpp_v${{ steps.version.outputs.version }}_MSVC_windows_${{ matrix.arch }}" | |
| $dest = Join-Path $env:GITHUB_WORKSPACE "$artifactName.zip" | |
| Compress-Archive -Path (Join-Path $libDir "Tiny.cpp") -DestinationPath $dest | |
| echo "artifact_name=$artifactName" >> $env:GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ steps.package.outputs.artifact_name }} | |
| path: ${{ github.workspace }}/${{ steps.package.outputs.artifact_name }}.zip | |
| env-windows-mingw: | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| msystem: MINGW64 | |
| pkg_prefix: mingw-w64-x86_64 | |
| tool_prefix: mingw64 | |
| runner: windows-2022 | |
| - arch: arm64 | |
| msystem: CLANGARM64 | |
| pkg_prefix: mingw-w64-clang-aarch64 | |
| tool_prefix: clangarm64 | |
| runner: windows-11-arm | |
| steps: | |
| - name: pull project | |
| uses: actions/checkout@v7 | |
| - name: Setup MSYS2 | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: ${{ matrix.msystem }} | |
| update: true | |
| install: >- | |
| ${{ matrix.pkg_prefix }}-gcc | |
| ${{ matrix.pkg_prefix }}-cmake | |
| ${{ matrix.pkg_prefix }}-ninja | |
| ${{ matrix.pkg_prefix }}-pkg-config | |
| ${{ matrix.pkg_prefix }}-catch | |
| ${{ matrix.pkg_prefix }}-gtest | |
| git | |
| make | |
| - name: Compiling project | |
| shell: msys2 {0} | |
| run: | | |
| mkdir -p ~/MyLibs/ | |
| cmake -B build -G Ninja -DCMAKE_INSTALL_PREFIX="~/MyLibs/Tiny.cpp" -DCMAKE_BUILD_TYPE=Debug -DTINY_GTEST_SRC=OFF | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to configure project!" | |
| exit 1 | |
| fi | |
| cmake --build build --target install -j8 | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to compile and install!" | |
| exit 1 | |
| fi | |
| # - name: Set Windows timezone | |
| # shell: pwsh | |
| # run: | | |
| # $tzMap = @{ | |
| # "Asia/Shanghai" = "China Standard Time" | |
| # "Asia/Tokyo" = "Tokyo Standard Time" | |
| # "Asia/Hong_Kong" = "China Standard Time" | |
| # "Asia/Singapore" = "Singapore Standard Time" | |
| # "Asia/Taipei" = "Taipei Standard Time" | |
| # "Asia/Seoul" = "Korea Standard Time" | |
| # "America/New_York" = "Eastern Standard Time" | |
| # "America/Chicago" = "Central Standard Time" | |
| # "America/Denver" = "Mountain Standard Time" | |
| # "America/Phoenix" = "Eastern Standard Time" | |
| # "America/Los_Angeles" = "Pacific Standard Time" | |
| # "Europe/London" = "GMT Standard Time" | |
| # "Europe/Paris" = "Romance Standard Time" | |
| # "Europe/Berlin" = "W. Europe Standard Time" | |
| # "UTC" = "UTC" | |
| # } | |
| # $ianaTz = curl -s ipconfig.io/json | ConvertFrom-Json | Select-Object -ExpandProperty time_zone | |
| # Write-Host "Detected IANA timezone: $ianaTz" | |
| # if ($tzMap.ContainsKey($ianaTz)) { | |
| # $winTz = $tzMap[$ianaTz] | |
| # tzutil /s $winTz | |
| # Write-Host "Windows timezone set to: $(tzutil /g)" | |
| # } else { | |
| # Write-Host "Warning: Timezone mapping not found for $ianaTz" | |
| # Write-Host " Using Eastern Standard Time for instead." | |
| # tzutils /s "Eastern Standard Time" | |
| # } | |
| # - name: Test for project | |
| # shell: msys2 {0} | |
| # run: | | |
| # cd build/bin/gtests | |
| # for EXE in $(ls -1); do | |
| # ./$EXE | |
| # if [ $? -ne 0 ]; then | |
| # echo "* Test failed: " $EXE | |
| # exit 1 | |
| # fi | |
| # sleep 1 | |
| # done | |
| - name: Get version | |
| id: version | |
| shell: pwsh | |
| run: | | |
| $version = (Get-Content .github\current_version.txt -Raw).Trim() | |
| echo "version=$version" >> $env:GITHUB_OUTPUT | |
| - name: Package artifact | |
| id: package | |
| shell: pwsh | |
| run: | | |
| $libDir = Join-Path $env:USERPROFILE "MyLibs" | |
| $artifactName = "Tiny_cpp_v${{ steps.version.outputs.version }}_${{ matrix.tool_prefix }}_windows_${{ matrix.arch }}" | |
| $dest = Join-Path $env:GITHUB_WORKSPACE "$artifactName.zip" | |
| Compress-Archive -Path (Join-Path $libDir "Tiny.cpp") -DestinationPath $dest | |
| echo "artifact_name=$artifactName" >> $env:GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ steps.package.outputs.artifact_name }} | |
| path: ${{ github.workspace }}/${{ steps.package.outputs.artifact_name }}.zip |