feat(workflow): 收敛刷写工具流程并完善 CH592 电量上报 #48
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: Firmware CI | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - "firmware/**" | |
| - "config/**" | |
| - "tools/studio/**" | |
| - "tools/scripts/**" | |
| - ".github/workflows/firmware-build.yml" | |
| - ".github/workflows/release.yml" | |
| - ".github/release.yml" | |
| concurrency: | |
| group: firmware-ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-ch592f: | |
| name: Build CH592F (${{ matrix.keyboard }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| keyboard: | |
| - 5KEY | |
| - KNOB | |
| container: | |
| image: ghcr.io/meowkj/binarykeyboard-builder:latest | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Install Python | |
| run: | | |
| apt-get update -q | |
| apt-get install -y --no-install-recommends python3 | |
| - name: Fix git ownership | |
| run: git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| - name: Build (JumpIAP + app + IAP) | |
| run: python3 tools/scripts/ch592f.py build-full --keyboard ${{ matrix.keyboard }} --profile release | |
| - name: Resolve artifacts | |
| id: artifacts | |
| run: | | |
| echo "bin=$(python3 tools/scripts/ch592f.py artifact --keyboard ${{ matrix.keyboard }} --profile release --type bin)" >> "$GITHUB_OUTPUT" | |
| echo "full_hex=$(python3 tools/scripts/ch592f.py artifact --keyboard ${{ matrix.keyboard }} --profile release --type full_hex)" >> "$GITHUB_OUTPUT" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: firmware-ch592f-${{ matrix.keyboard }}-${{ github.sha }} | |
| path: | | |
| ${{ steps.artifacts.outputs.bin }} | |
| ${{ steps.artifacts.outputs.full_hex }} | |
| retention-days: 7 | |
| build-ch552g: | |
| name: Build CH552G (${{ matrix.keyboard }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| keyboard: | |
| - BASIC | |
| - KNOB | |
| - 5KEY | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Install SDCC 4.5.0 | |
| run: | | |
| SDCC_VER="4.5.0" | |
| wget -q "https://sourceforge.net/projects/sdcc/files/sdcc-linux-amd64/${SDCC_VER}/sdcc-${SDCC_VER}-amd64-unknown-linux2.5.tar.bz2/download" -O sdcc.tar.bz2 | |
| tar xjf sdcc.tar.bz2 | |
| echo "${PWD}/sdcc-${SDCC_VER}/bin" >> "$GITHUB_PATH" | |
| sudo apt-get update -q | |
| sudo apt-get install -y ninja-build | |
| - name: Build | |
| run: python3 tools/scripts/ch552g.py build --keyboard ${{ matrix.keyboard }} | |
| - name: Resolve artifacts | |
| id: artifacts | |
| run: | | |
| echo "bin=$(python3 tools/scripts/ch552g.py artifact --keyboard ${{ matrix.keyboard }} --type bin)" >> "$GITHUB_OUTPUT" | |
| echo "hex=$(python3 tools/scripts/ch552g.py artifact --keyboard ${{ matrix.keyboard }} --type hex)" >> "$GITHUB_OUTPUT" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: firmware-ch552g-${{ matrix.keyboard }}-${{ github.sha }} | |
| path: | | |
| ${{ steps.artifacts.outputs.bin }} | |
| ${{ steps.artifacts.outputs.hex }} | |
| retention-days: 7 | |
| build-studio: | |
| name: Build Studio | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.15.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" | |
| cache-dependency-path: tools/studio/pnpm-lock.yaml | |
| - name: Install dependencies | |
| working-directory: tools/studio | |
| run: pnpm install --frozen-lockfile | |
| - name: Build | |
| run: pnpm --dir tools/studio run build |