From 733dad3fae4ce6dd9d4f696db73042407bade9b0 Mon Sep 17 00:00:00 2001 From: awalol Date: Wed, 29 Apr 2026 19:17:17 +0800 Subject: [PATCH] add github ci --- .github/workflows/build.yml | 71 +++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 75 +++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7e2d801 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,71 @@ +name: Build firmware + +on: + push: + workflow_dispatch: + +env: + PICO_SDK_REF: 2.2.0 + TINYUSB_REF: 0.20.0 + PICO_SDK_PATH: ${{ github.workspace }}/pico-sdk + +jobs: + build: + name: Build UF2 artifacts + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install build dependencies + run: | + sudo apt update + sudo apt install -y cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib ninja-build + + - name: Cache Pico SDK + uses: actions/cache@v4 + with: + path: ${{ env.PICO_SDK_PATH }} + key: pico-sdk-${{ runner.os }}-${{ env.PICO_SDK_REF }}-tinyusb-${{ env.TINYUSB_REF }} + + - name: Prepare Pico SDK + run: | + if [ ! -d "$PICO_SDK_PATH/.git" ]; then + git clone --depth 1 --branch "$PICO_SDK_REF" https://github.com/raspberrypi/pico-sdk.git "$PICO_SDK_PATH" + fi + git -C "$PICO_SDK_PATH" submodule update --init --recursive + + - name: Switch TinyUSB to configured tag + run: | + if ! git -C "$PICO_SDK_PATH/lib/tinyusb" rev-parse -q --verify "refs/tags/$TINYUSB_REF" >/dev/null; then + git -C "$PICO_SDK_PATH/lib/tinyusb" fetch --depth 1 origin "refs/tags/$TINYUSB_REF:refs/tags/$TINYUSB_REF" + fi + git -C "$PICO_SDK_PATH/lib/tinyusb" checkout --detach "$TINYUSB_REF" + + - name: Build standard firmware + run: | + cmake -S . -B build/standard -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DPICO_SDK_PATH="$PICO_SDK_PATH" + cmake --build build/standard --target ds5-bridge + mkdir -p artifacts + cp build/standard/ds5-bridge.uf2 artifacts/ds5-bridge.uf2 + + - name: Build DSE firmware + run: | + cmake -S . -B build/dse -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DPICO_SDK_PATH="$PICO_SDK_PATH" \ + -DENABLE_DSE=ON + cmake --build build/dse --target ds5-bridge + cp build/dse/ds5-bridge.uf2 artifacts/ds5-bridge-dse.uf2 + + - name: Upload UF2 artifacts + uses: actions/upload-artifact@v4 + with: + name: ds5-bridge-uf2 + path: artifacts/*.uf2 + if-no-files-found: error diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..27ac9dc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,75 @@ +name: Build release firmware + +on: + release: + types: + - published + +env: + PICO_SDK_REF: 2.2.0 + TINYUSB_REF: 0.20.0 + PICO_SDK_PATH: ${{ github.workspace }}/pico-sdk + +permissions: + contents: write + +jobs: + build: + name: Build and upload release UF2 + runs-on: ubuntu-latest + + steps: + - name: Checkout release ref + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name }} + submodules: recursive + + - name: Install build dependencies + run: | + sudo apt update + sudo apt install -y cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib ninja-build + + - name: Cache Pico SDK + uses: actions/cache@v4 + with: + path: ${{ env.PICO_SDK_PATH }} + key: pico-sdk-${{ runner.os }}-${{ env.PICO_SDK_REF }}-tinyusb-${{ env.TINYUSB_REF }} + + - name: Prepare Pico SDK + run: | + if [ ! -d "$PICO_SDK_PATH/.git" ]; then + git clone --depth 1 --branch "$PICO_SDK_REF" https://github.com/raspberrypi/pico-sdk.git "$PICO_SDK_PATH" + fi + git -C "$PICO_SDK_PATH" submodule update --init --recursive + + - name: Switch TinyUSB to configured tag + run: | + if ! git -C "$PICO_SDK_PATH/lib/tinyusb" rev-parse -q --verify "refs/tags/$TINYUSB_REF" >/dev/null; then + git -C "$PICO_SDK_PATH/lib/tinyusb" fetch --depth 1 origin "refs/tags/$TINYUSB_REF:refs/tags/$TINYUSB_REF" + fi + git -C "$PICO_SDK_PATH/lib/tinyusb" checkout --detach "$TINYUSB_REF" + + - name: Build standard firmware + run: | + cmake -S . -B build/standard -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DPICO_SDK_PATH="$PICO_SDK_PATH" + cmake --build build/standard --target ds5-bridge + mkdir -p artifacts + cp build/standard/ds5-bridge.uf2 artifacts/ds5-bridge.uf2 + + - name: Build DSE firmware + run: | + cmake -S . -B build/dse -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DPICO_SDK_PATH="$PICO_SDK_PATH" \ + -DENABLE_DSE=ON + cmake --build build/dse --target ds5-bridge + cp build/dse/ds5-bridge.uf2 artifacts/ds5-bridge-dse.uf2 + + - name: Upload UF2 files to release + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release upload "${{ github.event.release.tag_name }}" artifacts/*.uf2 --clobber