From 25be61448cc2e8ae2c4bb75c58c1fa241994bdf8 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Fri, 12 Dec 2025 20:17:11 +0200 Subject: [PATCH 1/2] ci: Consolidate GitHub Actions config and trigger on all branches Move matrix.json and matrix-makefile.json from the project root to .github/workflows/ where they belong, alongside the workflow files that use them. Remove the branch restriction on push triggers to allow CI runs on all feature branches, not just on main. --- .github/workflows/build-makefile.yml | 3 +-- .github/workflows/build.yml | 3 +-- matrix-makefile.json => .github/workflows/matrix-makefile.json | 0 matrix.json => .github/workflows/matrix.json | 0 4 files changed, 2 insertions(+), 4 deletions(-) rename matrix-makefile.json => .github/workflows/matrix-makefile.json (100%) rename matrix.json => .github/workflows/matrix.json (100%) diff --git a/.github/workflows/build-makefile.yml b/.github/workflows/build-makefile.yml index 2fd487c..5b71c1e 100644 --- a/.github/workflows/build-makefile.yml +++ b/.github/workflows/build-makefile.yml @@ -1,7 +1,6 @@ name: build-makefile on: push: - branches: [ main ] pull_request: workflow_dispatch: @@ -22,7 +21,7 @@ jobs: - name: Set matrix outputs id: set-matrix run: | - echo "matrix=$(jq -c '.' matrix-makefile.json)" >> $GITHUB_OUTPUT + echo "matrix=$(jq -c '.' .github/workflows/matrix-makefile.json)" >> $GITHUB_OUTPUT build-makefile: name: ${{ matrix.name }}-makefile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec66ce8..5a87fe6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,6 @@ name: build-cmake on: push: - branches: [ main ] pull_request: workflow_dispatch: @@ -22,7 +21,7 @@ jobs: - name: Set matrix outputs id: set-matrix run: | - echo "matrix=$(jq -c '.' matrix.json)" >> $GITHUB_OUTPUT + echo "matrix=$(jq -c '.' .github/workflows/matrix.json)" >> $GITHUB_OUTPUT build-cmake: name: ${{ matrix.name }}-cmake diff --git a/matrix-makefile.json b/.github/workflows/matrix-makefile.json similarity index 100% rename from matrix-makefile.json rename to .github/workflows/matrix-makefile.json diff --git a/matrix.json b/.github/workflows/matrix.json similarity index 100% rename from matrix.json rename to .github/workflows/matrix.json From 94dce3f3ccb444be87527338db5323a7591520f3 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Fri, 12 Dec 2025 21:33:22 +0200 Subject: [PATCH 2/2] ci: Simplify GitHub Actions build matrices and release workflow Reduce the CMake build matrix to 4 configurations: - Ubuntu (ubuntu-latest, using gcc) - macOS (macos-latest, using clang) - Windows MSVC (windows-latest) - Windows MSYS2 (windows-latest, using gcc) Simplify the Makefile build for Ubuntu only -- no matrix needed. Streamline the release workflow to produce Windows binaries only. Downstream maintainers will build and package the builds for all other platforms. --- .github/workflows/build-makefile.yml | 50 ++--------------- .github/workflows/build.yml | 69 ++++------------------- .github/workflows/matrix-makefile.json | 12 ---- .github/workflows/matrix.json | 36 +++--------- .github/workflows/release.yml | 78 ++++++++++++-------------- 5 files changed, 58 insertions(+), 187 deletions(-) delete mode 100644 .github/workflows/matrix-makefile.json diff --git a/.github/workflows/build-makefile.yml b/.github/workflows/build-makefile.yml index 5b71c1e..48b83bf 100644 --- a/.github/workflows/build-makefile.yml +++ b/.github/workflows/build-makefile.yml @@ -9,63 +9,23 @@ concurrency: cancel-in-progress: true jobs: - load-matrix: - name: Load Build Matrix - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set matrix outputs - id: set-matrix - run: | - echo "matrix=$(jq -c '.' .github/workflows/matrix-makefile.json)" >> $GITHUB_OUTPUT - build-makefile: - name: ${{ matrix.name }}-makefile - runs-on: ${{ matrix.runner }} - needs: load-matrix - - strategy: - fail-fast: false - matrix: - include: ${{ fromJson(needs.load-matrix.outputs.matrix) }} + name: ubuntu-makefile + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - # Ubuntu dependencies - - name: Install dependencies (Ubuntu) + - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y build-essential zlib1g-dev - # Makefile builds - - name: Build with Makefile (Ubuntu) + - name: Build with Makefile run: | make - - name: Test Makefile build (Ubuntu) + - name: Test Makefile build run: | ./pngcheck -h - - # - name: Prepare artifacts (Ubuntu) - # run: | - # mkdir -p artifacts - # cp pngcheck artifacts/pngcheck-${{ matrix.name }}-makefile - # cd artifacts - # if command -v sha256sum >/dev/null 2>&1; then - # sha256sum * > checksums.txt - # elif command -v shasum >/dev/null 2>&1; then - # shasum -a 256 * > checksums.txt - # fi - - # - name: Upload artifacts - # uses: actions/upload-artifact@v4 - # with: - # name: pngcheck-${{ matrix.name }}-makefile - # path: artifacts/ - # retention-days: 30 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a87fe6..96ef0ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,47 +37,39 @@ jobs: - name: Checkout uses: actions/checkout@v4 - # MSYS2 setup - - name: Setup MSYS2 + - name: Setup MSYS2 (Windows GCC) if: matrix.os == 'windows-msys2' uses: msys2/setup-msys2@v2 with: - msystem: ${{ matrix.msys }} + msystem: mingw64 path-type: minimal update: true - install: >- - git - make + install: make pacboy: >- toolchain:p zlib:p cmake:p - # Ubuntu dependencies - name: Install dependencies (Ubuntu) if: matrix.os == 'ubuntu' run: | sudo apt-get update sudo apt-get install -y cmake build-essential zlib1g-dev - # macOS dependencies - name: Install dependencies (macOS) if: matrix.os == 'macos' run: | brew list zlib || brew install zlib - # Windows dependencies - name: Setup MSVC (Windows) if: matrix.os == 'windows' uses: microsoft/setup-msbuild@v2 - - name: Install vcpkg dependencies (Windows) + - name: Install vcpkg dependencies (Windows MSVC) if: matrix.os == 'windows' run: | - $arch = if ("${{ matrix.runner }}" -eq "windows-11-arm") { "arm64" } else { "x64" } - vcpkg install zlib:$arch-windows + vcpkg install zlib:x64-windows - # CMake builds - name: Build with CMake (Ubuntu/macOS) if: matrix.os == 'ubuntu' || matrix.os == 'macos' run: | @@ -89,11 +81,10 @@ jobs: - name: Build with CMake (Windows MSVC) if: matrix.os == 'windows' run: | - $arch = if ("${{ matrix.runner }}" -eq "windows-11-arm") { "ARM64" } else { "x64" } - cmake -B build-cmake -A $arch -DCMAKE_BUILD_TYPE=Release -DPNGCHECK_USE_SYSTEM_ZLIB=ON -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake -B build-cmake -A x64 -DCMAKE_BUILD_TYPE=Release -DPNGCHECK_USE_SYSTEM_ZLIB=ON -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake cmake --build build-cmake --config Release - - name: Build with CMake (Windows MSYS2) + - name: Build with CMake (Windows GCC) if: matrix.os == 'windows-msys2' shell: msys2 {0} run: | @@ -103,56 +94,18 @@ jobs: -DPNGCHECK_USE_SYSTEM_ZLIB=ON cmake --build build-cmake --config Release - # Testing CMake builds - - name: Test CMake build (MSYS2) - if: matrix.os == 'windows-msys2' - shell: msys2 {0} - run: | - build-cmake/pngcheck.exe -h - - name: Test CMake build (Windows MSVC) if: matrix.os == 'windows' run: | build-cmake/Release/pngcheck.exe -h - - name: Test CMake build (Unix/macOS) - if: matrix.os == 'ubuntu' || matrix.os == 'macos' - run: | - ./build-cmake/pngcheck -h - - # Artifacts - - name: Prepare artifacts (MSYS2) + - name: Test CMake build (Windows GCC) if: matrix.os == 'windows-msys2' shell: msys2 {0} run: | - mkdir -p artifacts - cp build-cmake/pngcheck.exe artifacts/pngcheck-${{ matrix.name }}-cmake.exe - cd artifacts - sha256sum * > checksums.txt - - - name: Prepare artifacts (Windows MSVC) - if: matrix.os == 'windows' - run: | - mkdir -p artifacts - cp build-cmake/Release/pngcheck.exe artifacts/pngcheck-${{ matrix.name }}-cmake.exe - cd artifacts - Get-FileHash -Algorithm SHA256 *.exe | ForEach-Object { "$($_.Hash.ToLower()) $($_.Path | Split-Path -Leaf)" } > checksums.txt + build-cmake/pngcheck.exe -h - - name: Prepare artifacts (Unix/macOS) + - name: Test CMake build (Ubuntu/macOS) if: matrix.os == 'ubuntu' || matrix.os == 'macos' run: | - mkdir -p artifacts - cp build-cmake/pngcheck artifacts/pngcheck-${{ matrix.name }}-cmake - cd artifacts - if command -v sha256sum >/dev/null 2>&1; then - sha256sum * > checksums.txt - elif command -v shasum >/dev/null 2>&1; then - shasum -a 256 * > checksums.txt - fi - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: pngcheck-${{ matrix.name }}-cmake - path: artifacts/ - retention-days: 30 + ./build-cmake/pngcheck -h diff --git a/.github/workflows/matrix-makefile.json b/.github/workflows/matrix-makefile.json deleted file mode 100644 index 1e40298..0000000 --- a/.github/workflows/matrix-makefile.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "runner": "ubuntu-24.04", - "os": "ubuntu", - "name": "ubuntu-24.04" - }, - { - "runner": "ubuntu-24.04-arm", - "os": "ubuntu", - "name": "ubuntu-24.04-arm" - } -] diff --git a/.github/workflows/matrix.json b/.github/workflows/matrix.json index b5ccd61..9c34a16 100644 --- a/.github/workflows/matrix.json +++ b/.github/workflows/matrix.json @@ -1,44 +1,22 @@ [ { - "runner": "ubuntu-24.04", + "runner": "ubuntu-latest", "os": "ubuntu", - "name": "ubuntu-24.04" + "name": "ubuntu" }, { - "runner": "ubuntu-24.04-arm", - "os": "ubuntu", - "name": "ubuntu-24.04-arm" - }, - { - "runner": "macos-13", + "runner": "macos-latest", "os": "macos", - "name": "macos-13" - }, - { - "runner": "macos-15", - "os": "macos", - "name": "macos-15" - }, - { - "runner": "windows-2022", - "os": "windows", - "name": "windows-2022" - }, - { - "runner": "windows-11-arm", - "os": "windows", - "name": "windows-11-arm" + "name": "macos" }, { "runner": "windows-latest", - "os": "windows-msys2", - "msys": "mingw32", - "name": "mingw32" + "os": "windows", + "name": "windows-msvc" }, { "runner": "windows-latest", "os": "windows-msys2", - "msys": "mingw64", - "name": "mingw64" + "name": "windows-gcc" } ] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3c7b37..b2ef6cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,4 @@ name: release - on: push: tags: @@ -7,66 +6,63 @@ on: workflow_dispatch: jobs: - build: - name: Build Release Artifacts - runs-on: ${{ matrix.runner }} + build-windows: + name: Build Windows ${{ matrix.arch }} + runs-on: windows-latest strategy: fail-fast: false matrix: include: - # Ubuntu 22.04 builds only, compatibile with 22+ later versions - - runner: ubuntu-22.04 - os: ubuntu - arch: x64 - - runner: ubuntu-22.04-arm - os: ubuntu - arch: arm64 + - arch: Win32 + vcpkg_triplet: x86-windows + artifact_name: pngcheck-windows-x86.exe + - arch: x64 + vcpkg_triplet: x64-windows + artifact_name: pngcheck-windows-x64.exe + - arch: ARM64 + vcpkg_triplet: arm64-windows + artifact_name: pngcheck-windows-arm64.exe steps: - name: Checkout uses: actions/checkout@v4 - - name: Install dependencies + - name: Setup MSVC + uses: microsoft/setup-msbuild@v2 + + - name: Install vcpkg dependencies run: | - sudo apt-get update - sudo apt-get install -y zlib1g-dev cmake build-essential + vcpkg install zlib:${{ matrix.vcpkg_triplet }} - name: Configure CMake run: | - cmake -B build \ - -DCMAKE_BUILD_TYPE=Release \ - -DPNGCHECK_USE_SYSTEM_ZLIB=ON + cmake -B build -A ${{ matrix.arch }} -DCMAKE_BUILD_TYPE=Release -DPNGCHECK_USE_SYSTEM_ZLIB=ON -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build run: cmake --build build --config Release - name: Prepare release artifacts run: | - mkdir -p release-artifacts - cp build/pngcheck release-artifacts/pngcheck-${{ matrix.runner }}-${{ matrix.arch }} - - # Generate checksums + mkdir release-artifacts + cp build/Release/pngcheck.exe release-artifacts/${{ matrix.artifact_name }} cd release-artifacts - sha256sum * > checksums-${{ matrix.runner }}-${{ matrix.arch }}.txt + Get-FileHash -Algorithm SHA256 *.exe | ForEach-Object { "$($_.Hash.ToLower()) $($_.Path | Split-Path -Leaf)" } > checksums-${{ matrix.arch }}.txt - name: Upload release artifacts uses: actions/upload-artifact@v4 with: - name: pngcheck-${{ matrix.runner }}-${{ matrix.arch }} + name: pngcheck-windows-${{ matrix.arch }} path: release-artifacts/ retention-days: 90 release: name: Create GitHub Release runs-on: ubuntu-latest - needs: build + needs: build-windows if: startsWith(github.ref, 'refs/tags/') steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Download all artifacts uses: actions/download-artifact@v4 with: @@ -75,32 +71,28 @@ jobs: - name: Prepare release assets run: | mkdir -p release-assets - - # Flatten artifact structure and rename files - find all-artifacts -type f -name "pngcheck*" -exec cp {} release-assets/ \; - find all-artifacts -type f -name "checksums*" -exec cp {} release-assets/ \; - - # Create a combined checksums file + find all-artifacts -type f \( -name "*.exe" -o -name "checksums-*.txt" \) -exec cp {} release-assets/ \; cd release-assets - cat checksums-*.txt > combined-checksums.txt - - # List all files for verification + cat checksums-*.txt > checksums.txt + rm checksums-*.txt ls -la - name: Create Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: - name: Release ${{ github.ref_name }} + name: pngcheck ${{ github.ref_name }} body: | ## pngcheck ${{ github.ref_name }} - Compiled binaries for Ubuntu 22.04: + ### Windows Binaries - ### Ubuntu 22.04 - - `pngcheck-ubuntu-22.04-x64` - Ubuntu 22.04 (x64) - - `pngcheck-ubuntu-22.04-arm-arm64` - Ubuntu 22.04 (ARM64) + | File | Architecture | + |------|--------------| + | `pngcheck-windows-x86.exe` | Windows 32-bit (x86) | + | `pngcheck-windows-x64.exe` | Windows 64-bit (x64) | + | `pngcheck-windows-arm64.exe` | Windows ARM64 | - All binaries are built with CMake and system zlib, and include SHA256 checksums for verification. + Built with MSVC and zlib. SHA256 checksums included. files: release-assets/* draft: false prerelease: false