diff --git a/.github/workflows/build-amd64.yml b/.github/workflows/build-amd64.yml deleted file mode 100644 index ecd65e6..0000000 --- a/.github/workflows/build-amd64.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Build Example Applications (AMD64) - -on: - push: - tags: - - 'v*' - pull_request: - workflow_dispatch: - -jobs: - build-and-package: - name: Build and Package (AMD64) - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Verify Tag Matches CMake Version - if: startsWith(github.ref, 'refs/tags/v') - run: | - PROJECT_VERSION=$(grep -oP 'project\([^ ]+ VERSION \K[0-9.]+' CMakeLists.txt) - TAG_VERSION=${GITHUB_REF#refs/tags/v} - TAG_BASE_VERSION=$(echo "$TAG_VERSION" | cut -d'-' -f1) - if [ "$PROJECT_VERSION" != "$TAG_BASE_VERSION" ]; then - echo "::error::CMake project version ($PROJECT_VERSION) does not match Git tag version ($TAG_BASE_VERSION)!" - exit 1 - fi - echo "Version match verified: $PROJECT_VERSION" - - - name: Install Build Dependencies - run: | - sudo apt-get update - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ - build-essential cmake git pkg-config \ - libeigen3-dev libboost-all-dev libasound2-dev \ - libprotobuf-dev protobuf-compiler libimlib2-dev - - - name: Build and Install matrixserver from submodule - run: | - cmake -S "$GITHUB_WORKSPACE/matrixserver" \ - -B "$GITHUB_WORKSPACE/matrixserver/build" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/matrixserver/install" - cmake --build "$GITHUB_WORKSPACE/matrixserver/build" -- -j$(nproc) - cmake --install "$GITHUB_WORKSPACE/matrixserver/build" - - - name: Build Example Applications - run: | - cmake -S "$GITHUB_WORKSPACE" \ - -B "$GITHUB_WORKSPACE/build" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/matrixserver/install" - cmake --build "$GITHUB_WORKSPACE/build" -- -j$(nproc) - - - name: Create Debian Package Workspace - run: | - PROJECT_VERSION=$(grep -oP 'project\([^ ]+ VERSION \K[0-9.]+' CMakeLists.txt) - if [ -z "$PROJECT_VERSION" ]; then echo "Failed to extract version"; exit 1; fi - - mkdir -p deb-workspace/opt/cube/bin - cp bin/cubetestapp deb-workspace/opt/cube/bin/ - cp bin/Genetic deb-workspace/opt/cube/bin/ - cp bin/Breakout3D deb-workspace/opt/cube/bin/ - cp bin/Blackout3D deb-workspace/opt/cube/bin/ - cp bin/PixelFlow3 deb-workspace/opt/cube/bin/ - cp bin/MatrixRain deb-workspace/opt/cube/bin/ - cp bin/Snake deb-workspace/opt/cube/bin/ - cp bin/Picture deb-workspace/opt/cube/bin/ - cp bin/imutestapp deb-workspace/opt/cube/bin/ - cp bin/PixelFlow deb-workspace/opt/cube/bin/ - cp bin/PixelFlow2 deb-workspace/opt/cube/bin/ - cp bin/Rainbow deb-workspace/opt/cube/bin/ - - mkdir -p deb-workspace/DEBIAN - cat < deb-workspace/DEBIAN/control - Package: led-cube-exampleapplications - Version: ${PROJECT_VERSION} - Section: base - Priority: optional - Architecture: amd64 - Maintainer: Bjoern Hauffe - Description: LEDCube matrixserver example applications (AMD64/Simulator) - Depends: matrixserver-simulator - EOF - - - name: Build Debian Package - run: | - PROJECT_VERSION=$(grep -oP 'project\([^ ]+ VERSION \K[0-9.]+' CMakeLists.txt) - dpkg-deb --build deb-workspace "led-cube-exampleapplications_${PROJECT_VERSION}_amd64.deb" - - - name: Upload Debian Package Artifact - if: github.event_name != 'pull_request' - uses: actions/upload-artifact@v4 - with: - name: led-cube-exampleapplications-amd64 - path: led-cube-exampleapplications_*_amd64.deb diff --git a/.github/workflows/build-arm64.yml b/.github/workflows/build-arm64.yml deleted file mode 100644 index 89cdb81..0000000 --- a/.github/workflows/build-arm64.yml +++ /dev/null @@ -1,108 +0,0 @@ -name: Build Example Applications Pi (ARM64) - -on: - workflow_run: - workflows: ["Build Example Applications (AMD64)"] - types: [completed] - workflow_dispatch: - -jobs: - build-and-package-pi: - name: Build and Package Pi (ARM64) - if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'pull_request') }} - runs-on: [self-hosted, linux, ARM64] - permissions: - contents: read - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install Build Dependencies - run: | - sudo apt-get update - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ - build-essential cmake git pkg-config \ - libeigen3-dev libboost-thread-dev libboost-log-dev \ - libboost-system-dev libboost-regex-dev libboost-chrono-dev \ - libboost-date-time-dev libboost-filesystem-dev libboost-atomic-dev \ - libboost-program-options-dev libasound2-dev libprotobuf-dev \ - protobuf-compiler libimlib2-dev libftdi1-dev - - - name: Build and install wiringPi natively - run: | - git clone https://github.com/WiringPi/WiringPi.git - cd WiringPi && sudo ./build && cd .. && rm -rf WiringPi - - - name: Mock Raspberry Pi detection for CMake - run: sudo mkdir -p /boot && sudo touch /boot/LICENCE.broadcom - - - name: Build and Install matrixserver from submodule (all hardware backends) - run: | - make -C "$GITHUB_WORKSPACE/matrixserver/renderer/RGBMatrixRenderer/rpi-rgb-led-matrix/lib" clean || true - rm -rf "$GITHUB_WORKSPACE/matrixserver/build" - mkdir "$GITHUB_WORKSPACE/matrixserver/build" - cmake -S "$GITHUB_WORKSPACE/matrixserver" \ - -B "$GITHUB_WORKSPACE/matrixserver/build" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/matrixserver/install" \ - -DENABLE_FPGA_FTDI=ON \ - -DENABLE_FPGA_RPISPI=ON \ - -DENABLE_RGB_MATRIX=ON - cmake --build "$GITHUB_WORKSPACE/matrixserver/build" -- -j$(nproc) - cmake --install "$GITHUB_WORKSPACE/matrixserver/build" - - - name: Build Example Applications - run: | - rm -rf "$GITHUB_WORKSPACE/build" - mkdir "$GITHUB_WORKSPACE/build" - cmake -S "$GITHUB_WORKSPACE" \ - -B "$GITHUB_WORKSPACE/build" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/matrixserver/install" - cmake --build "$GITHUB_WORKSPACE/build" -- -j$(nproc) - - - name: Create Debian Package Workspace - run: | - PROJECT_VERSION=$(grep -oP 'project\([^ ]+ VERSION \K[0-9.]+' CMakeLists.txt) - if [ -z "$PROJECT_VERSION" ]; then echo "Failed to extract version"; exit 1; fi - - mkdir -p deb-workspace/opt/cube/bin - cp bin/cubetestapp deb-workspace/opt/cube/bin/ - cp bin/Genetic deb-workspace/opt/cube/bin/ - cp bin/Breakout3D deb-workspace/opt/cube/bin/ - cp bin/Blackout3D deb-workspace/opt/cube/bin/ - cp bin/PixelFlow3 deb-workspace/opt/cube/bin/ - cp bin/MatrixRain deb-workspace/opt/cube/bin/ - cp bin/Snake deb-workspace/opt/cube/bin/ - cp bin/Picture deb-workspace/opt/cube/bin/ - cp bin/imutestapp deb-workspace/opt/cube/bin/ - cp bin/PixelFlow deb-workspace/opt/cube/bin/ - cp bin/PixelFlow2 deb-workspace/opt/cube/bin/ - cp bin/Rainbow deb-workspace/opt/cube/bin/ - - mkdir -p deb-workspace/DEBIAN - cat < deb-workspace/DEBIAN/control - Package: led-cube-exampleapplications - Version: ${PROJECT_VERSION} - Section: base - Priority: optional - Architecture: arm64 - Maintainer: Bjoern Hauffe - Description: LEDCube matrixserver example applications for Raspberry Pi - Depends: matrixserver-pi - EOF - - - - name: Build Debian Package - run: | - PROJECT_VERSION=$(grep -oP 'project\([^ ]+ VERSION \K[0-9.]+' CMakeLists.txt) - dpkg-deb --build deb-workspace "led-cube-exampleapplications_${PROJECT_VERSION}_arm64.deb" - - - name: Upload Debian Package Artifact - uses: actions/upload-artifact@v4 - with: - name: led-cube-exampleapplications-arm64 - path: led-cube-exampleapplications_*_arm64.deb diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml deleted file mode 100644 index 209da83..0000000 --- a/.github/workflows/create-release.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: Create Pre-Release - -on: - workflow_run: - workflows: ["Build Example Applications Pi (ARM64)"] - types: [completed] - workflow_dispatch: - inputs: - tag: - description: 'Release tag name (e.g. v0.4.8)' - required: true - sha: - description: 'Commit SHA that both build workflows ran against' - required: true - -jobs: - release: - if: > - github.event_name == 'workflow_dispatch' || - (github.event.workflow_run.conclusion == 'success' && - startsWith(github.event.workflow_run.head_branch, 'v')) - runs-on: ubuntu-latest - permissions: - contents: write - actions: read - - steps: - - name: Download ARM64 .deb artifact - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ github.repository }} - run: | - mkdir -p debs - - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - HEAD_SHA=$(gh api "repos/$REPO/commits/${{ inputs.sha }}" --jq '.sha') - WF_ID=$(gh api "repos/$REPO/actions/workflows" \ - --jq '.workflows[] | select(.name == "Build Example Applications Pi (ARM64)") | .id') - RUN_ID=$(gh api "repos/$REPO/actions/workflows/$WF_ID/runs?head_sha=$HEAD_SHA&per_page=10" \ - --jq '.workflow_runs[0].id') - else - RUN_ID="${{ github.event.workflow_run.id }}" - fi - - gh run download "$RUN_ID" --repo "$REPO" \ - --name led-cube-exampleapplications-arm64 \ - --dir debs/ - - - name: Download AMD64 .deb artifact - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ github.repository }} - HEAD_SHA: ${{ inputs.sha || github.event.workflow_run.head_sha }} - run: | - HEAD_SHA=$(gh api "repos/$REPO/commits/$HEAD_SHA" --jq '.sha') - - WF_ID=$(gh api "repos/$REPO/actions/workflows" \ - --jq '.workflows[] | select(.name == "Build Example Applications (AMD64)") | .id') - - RUN_ID=$(gh api "repos/$REPO/actions/workflows/$WF_ID/runs?head_sha=$HEAD_SHA&per_page=10" \ - --jq '.workflow_runs[0].id') - - gh run download "$RUN_ID" --repo "$REPO" \ - --name led-cube-exampleapplications-amd64 \ - --dir debs/ - - echo "Downloaded packages:" - find debs/ -name "*.deb" | sort - - - name: Stage .deb files for upload - run: mv debs/*.deb . - - - name: Upload to APT Repository - uses: appleboy/scp-action@master - with: - host: ${{ vars.UPLOAD_HOST }} - username: ${{ vars.UPLOAD_USER }} - key: ${{ secrets.UPLOAD_SSH_KEY }} - source: "*.deb" - target: "/docker/apt-repo/data/incoming/" - - - name: Create GitHub pre-release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG: ${{ inputs.tag || github.event.workflow_run.head_branch }} - run: | - DEB_FILES=$(find debs/ -name "*.deb" | tr '\n' ' ') - - LATEST_RELEASE=$(gh release view --repo "${{ github.repository }}" \ - --json tagName -q .tagName 2>/dev/null || echo "") - - NOTES_FLAG="" - if [ -n "$LATEST_RELEASE" ]; then - NOTES_FLAG="--notes-start-tag $LATEST_RELEASE" - fi - - gh release create "$TAG" $DEB_FILES \ - --repo "${{ github.repository }}" \ - --prerelease \ - --generate-notes \ - $NOTES_FLAG \ - --title "Release $TAG" || \ - gh release upload "$TAG" $DEB_FILES \ - --repo "${{ github.repository }}" --clobber diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d097b14 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,251 @@ +name: Release + +on: + push: + tags: ['v*'] + pull_request: + workflow_dispatch: + +jobs: + build-amd64: + name: Build & package (AMD64) + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Verify tag matches CMake version + if: startsWith(github.ref, 'refs/tags/v') + run: | + PROJECT_VERSION=$(grep -oP 'project\([^ ]+ VERSION \K[0-9.]+' CMakeLists.txt) + TAG_VERSION=${GITHUB_REF#refs/tags/v} + TAG_BASE_VERSION=$(echo "$TAG_VERSION" | cut -d'-' -f1) + if [ "$PROJECT_VERSION" != "$TAG_BASE_VERSION" ]; then + echo "::error::CMake project version ($PROJECT_VERSION) does not match Git tag version ($TAG_BASE_VERSION)!" + exit 1 + fi + echo "Version match verified: $PROJECT_VERSION" + + - name: Install build dependencies + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential cmake git pkg-config ccache \ + libeigen3-dev libboost-all-dev libasound2-dev \ + libprotobuf-dev protobuf-compiler libimlib2-dev + + - name: Restore ccache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.ccache + key: ccache-amd64-${{ github.sha }} + restore-keys: | + ccache-amd64- + + - name: Build matrixserver from submodule + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + run: | + cmake -S "$GITHUB_WORKSPACE/matrixserver" \ + -B "$GITHUB_WORKSPACE/matrixserver/build" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/matrixserver/install" \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake --build "$GITHUB_WORKSPACE/matrixserver/build" -- -j$(nproc) + cmake --install "$GITHUB_WORKSPACE/matrixserver/build" + + - name: Build example applications + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + run: | + cmake -S "$GITHUB_WORKSPACE" \ + -B "$GITHUB_WORKSPACE/build" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/matrixserver/install" \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake --build "$GITHUB_WORKSPACE/build" -- -j$(nproc) + ccache -s + + - name: Build .deb + run: | + PROJECT_VERSION=$(grep -oP 'project\([^ ]+ VERSION \K[0-9.]+' CMakeLists.txt) + mkdir -p deb-workspace/opt/cube/bin deb-workspace/DEBIAN + for app in cubetestapp Genetic Breakout3D Blackout3D PixelFlow3 \ + MatrixRain Snake Picture imutestapp PixelFlow PixelFlow2 Rainbow; do + cp "bin/$app" deb-workspace/opt/cube/bin/ + done + cat < deb-workspace/DEBIAN/control + Package: led-cube-exampleapplications + Version: ${PROJECT_VERSION} + Section: base + Priority: optional + Architecture: amd64 + Maintainer: Bjoern Hauffe + Description: LEDCube matrixserver example applications (AMD64/Simulator) + Depends: matrixserver-simulator + EOF + dpkg-deb --build deb-workspace "led-cube-exampleapplications_${PROJECT_VERSION}_amd64.deb" + + - name: Upload .deb artifact + if: github.event_name != 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: led-cube-exampleapplications-amd64 + path: led-cube-exampleapplications_*_amd64.deb + + build-arm64: + name: Build & package (ARM64) + needs: build-amd64 + if: github.event_name != 'pull_request' + runs-on: [self-hosted, linux, ARM64] + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install build dependencies + run: | + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential cmake git pkg-config ccache \ + libeigen3-dev libboost-thread-dev libboost-log-dev \ + libboost-system-dev libboost-regex-dev libboost-chrono-dev \ + libboost-date-time-dev libboost-filesystem-dev libboost-atomic-dev \ + libboost-program-options-dev libasound2-dev libprotobuf-dev \ + protobuf-compiler libimlib2-dev libftdi1-dev + + - name: Build and install wiringPi (skip if present) + run: | + if [ ! -f /usr/local/lib/libwiringPi.so ] && [ ! -f /usr/lib/libwiringPi.so ]; then + git clone --depth 1 https://github.com/WiringPi/WiringPi.git /tmp/WiringPi + cd /tmp/WiringPi && sudo ./build && cd / && rm -rf /tmp/WiringPi + else + echo "wiringPi already installed, skipping" + fi + + - name: Mock Raspberry Pi detection for CMake + run: sudo mkdir -p /boot && sudo touch /boot/LICENCE.broadcom + + - name: Restore ccache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.ccache + key: ccache-arm64-${{ github.sha }} + restore-keys: | + ccache-arm64- + + - name: Build matrixserver from submodule (all hardware backends) + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + run: | + make -C "$GITHUB_WORKSPACE/matrixserver/renderer/RGBMatrixRenderer/rpi-rgb-led-matrix/lib" clean || true + rm -rf "$GITHUB_WORKSPACE/matrixserver/build" + cmake -S "$GITHUB_WORKSPACE/matrixserver" \ + -B "$GITHUB_WORKSPACE/matrixserver/build" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/matrixserver/install" \ + -DENABLE_FPGA_FTDI=ON \ + -DENABLE_FPGA_RPISPI=ON \ + -DENABLE_RGB_MATRIX=ON \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake --build "$GITHUB_WORKSPACE/matrixserver/build" -- -j$(nproc) + cmake --install "$GITHUB_WORKSPACE/matrixserver/build" + + - name: Build example applications + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + run: | + rm -rf "$GITHUB_WORKSPACE/build" + cmake -S "$GITHUB_WORKSPACE" \ + -B "$GITHUB_WORKSPACE/build" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/matrixserver/install" \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake --build "$GITHUB_WORKSPACE/build" -- -j$(nproc) + ccache -s + + - name: Build .deb + run: | + PROJECT_VERSION=$(grep -oP 'project\([^ ]+ VERSION \K[0-9.]+' CMakeLists.txt) + mkdir -p deb-workspace/opt/cube/bin deb-workspace/DEBIAN + for app in cubetestapp Genetic Breakout3D Blackout3D PixelFlow3 \ + MatrixRain Snake Picture imutestapp PixelFlow PixelFlow2 Rainbow; do + cp "bin/$app" deb-workspace/opt/cube/bin/ + done + cat < deb-workspace/DEBIAN/control + Package: led-cube-exampleapplications + Version: ${PROJECT_VERSION} + Section: base + Priority: optional + Architecture: arm64 + Maintainer: Bjoern Hauffe + Description: LEDCube matrixserver example applications for Raspberry Pi + Depends: matrixserver-pi + EOF + dpkg-deb --build deb-workspace "led-cube-exampleapplications_${PROJECT_VERSION}_arm64.deb" + + - name: Upload .deb artifact + uses: actions/upload-artifact@v4 + with: + name: led-cube-exampleapplications-arm64 + path: led-cube-exampleapplications_*_arm64.deb + + release: + name: Create pre-release & upload to APT + needs: [build-amd64, build-arm64] + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download all .deb artifacts + uses: actions/download-artifact@v4 + with: + path: debs + pattern: led-cube-exampleapplications-* + merge-multiple: true + + - name: List downloaded packages + run: find debs -name "*.deb" | sort + + - name: Upload to APT repository (sftp) + env: + UPLOAD_HOST: ${{ vars.UPLOAD_HOST }} + UPLOAD_USER: ${{ vars.UPLOAD_USER }} + UPLOAD_SSH_KEY: ${{ secrets.UPLOAD_SSH_KEY }} + run: | + set -euo pipefail + mkdir -p ~/.ssh + umask 077 + printf '%s\n' "$UPLOAD_SSH_KEY" > ~/.ssh/id_upload + ssh-keyscan -p 22322 -t ed25519,rsa "$UPLOAD_HOST" >> ~/.ssh/known_hosts 2>/dev/null + sftp -P 22322 -i ~/.ssh/id_upload -o StrictHostKeyChecking=yes \ + -b - "$UPLOAD_USER@$UPLOAD_HOST" </dev/null || true) + NOTES_FLAG="" + [ -n "$LATEST" ] && NOTES_FLAG="--notes-start-tag $LATEST" + gh release create "$TAG" debs/*.deb \ + --prerelease --generate-notes $NOTES_FLAG \ + --title "Release $TAG" \ + || gh release upload "$TAG" debs/*.deb --clobber