west west west #4
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 ZMK Firmware | |
| on: | |
| workflow_dispatch: | |
| push: | |
| paths: | |
| - "keyboards/corne/**" | |
| jobs: | |
| matrix: | |
| runs-on: ubuntu-latest | |
| name: Fetch Build Keyboards | |
| outputs: | |
| build_matrix: ${{ env.build_matrix }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install yaml2json | |
| run: python3 -c "import sys, yaml, json; json.dump(yaml.safe_load(sys.stdin), sys.stdout)" < /dev/null || pip install pyyaml | |
| - name: Fetch Build Matrix | |
| run: | | |
| echo "build_matrix=$(python3 -c "import sys, yaml, json; json.dump(yaml.safe_load(open('keyboards/corne/build.yaml')), sys.stdout)")" >> $GITHUB_ENV | |
| build: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: zmkfirmware/zmk-build-arm:stable | |
| needs: matrix | |
| name: Build | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.matrix.outputs.build_matrix) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Prepare variables | |
| shell: bash -x {0} | |
| env: | |
| board: ${{ matrix.board }} | |
| shield: ${{ matrix.shield }} | |
| artifact_name: ${{ matrix.artifact-name }} | |
| run: | | |
| echo "build_dir=$(mktemp -d)" >> $GITHUB_ENV | |
| echo "config_path=keyboards/corne/config" >> $GITHUB_ENV | |
| echo "extra_cmake_args=${shield:+-DSHIELD=\"$shield\"}" >> $GITHUB_ENV | |
| echo "display_name=${shield:+$shield - }${board}" >> $GITHUB_ENV | |
| echo "artifact_name=${artifact_name:-${shield:+$shield-}${board//\//_}-zmk}" >> $GITHUB_ENV | |
| - name: Cache west modules | |
| uses: actions/cache@v4 | |
| continue-on-error: true | |
| env: | |
| cache_name: cache-zephyr-modules | |
| with: | |
| path: | | |
| modules/ | |
| tools/ | |
| zephyr/ | |
| bootloader/ | |
| zmk/ | |
| key: ${{ runner.os }}-build-${{ env.cache_name }}-${{ hashFiles('**/west.yml', '**/build.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache_name }}- | |
| ${{ runner.os }}-build- | |
| ${{ runner.os }}- | |
| - name: West Init | |
| run: west init -l "${GITHUB_WORKSPACE}/${{ env.config_path }}" | |
| - name: West Update | |
| run: west update --fetch-opt=--filter=tree:0 | |
| - name: West Zephyr export | |
| run: west zephyr-export | |
| - name: West Build (${{ env.display_name }}) | |
| shell: sh -x {0} | |
| run: | | |
| west build -s zmk/app -d "${{ env.build_dir }}" -b "${{ matrix.board }}" -- \ | |
| -DZMK_CONFIG="${GITHUB_WORKSPACE}/${{ env.config_path }}" \ | |
| ${{ env.extra_cmake_args }} \ | |
| ${{ matrix.cmake-args }} | |
| - name: Rename artifacts | |
| shell: sh -x {0} | |
| run: | | |
| mkdir -p "${{ env.build_dir }}/artifacts" | |
| if [ -f "${{ env.build_dir }}/zephyr/zmk.uf2" ]; then | |
| cp "${{ env.build_dir }}/zephyr/zmk.uf2" "${{ env.build_dir }}/artifacts/${{ env.artifact_name }}.uf2" | |
| elif [ -f "${{ env.build_dir }}/zephyr/zmk.bin" ]; then | |
| cp "${{ env.build_dir }}/zephyr/zmk.bin" "${{ env.build_dir }}/artifacts/${{ env.artifact_name }}.bin" | |
| fi | |
| - name: Archive (${{ env.display_name }}) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: artifact-${{ env.artifact_name }} | |
| path: ${{ env.build_dir }}/artifacts | |
| merge: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| name: Merge Output Artifacts | |
| steps: | |
| - name: Merge Artifacts | |
| uses: actions/upload-artifact/merge@v4 | |
| with: | |
| name: firmware | |
| pattern: artifact-* | |
| delete-merged: true |