From 2610f2d7d6191efc58e08dfa8cf22ebf078caaf1 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Mon, 6 Apr 2026 07:04:37 +0200 Subject: [PATCH] feat(ci): inline the workflow --- .gitea/workflows/build.yml | 105 ++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 92415e4..53e534a 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,5 +1,108 @@ on: [push, pull_request, workflow_dispatch] jobs: + matrix: + runs-on: ubuntu-latest + name: Fetch Build Keyboards + outputs: + build_matrix: ${{ env.build_matrix }} + has_valid_build_matrix: ${{ steps.fetch.outputs.has_valid_build_matrix }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install yq + run: | + sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 + sudo chmod +x /usr/local/bin/yq + + - name: Fetch Build Matrix + id: fetch + run: | + matrix_content=$(yq -oj -I0 build.yaml) + if [ -z "$matrix_content" ] || [ "$matrix_content" = "null" ]; then + echo "has_valid_build_matrix=false" >> $GITHUB_OUTPUT + else + echo "build_matrix=$matrix_content" >> $GITHUB_ENV + echo "has_valid_build_matrix=true" >> $GITHUB_OUTPUT + fi + build: - uses: https://github.com/zmkfirmware/zmk/.github/workflows/build-user-config.yml@main + runs-on: ubuntu-latest + if: needs.matrix.outputs.has_valid_build_matrix == 'true' + 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: Create build directory + run: | + echo "build_dir=$(mktemp -d)" >> $GITHUB_ENV + + - name: Prepare variables + shell: bash -x {0} + env: + board: ${{ matrix.board }} + shield: ${{ matrix.shield }} + artifact_name: ${{ matrix.artifact-name }} + snippet: ${{ matrix.snippet }} + run: | + if [ -e zephyr/module.yml ]; then + export zmk_load_arg=" -DZMK_EXTRA_MODULES='${GITHUB_WORKSPACE}'" + new_tmp_dir="${TMPDIR:-/tmp}/zmk-config" + mkdir -p "${new_tmp_dir}" + echo "base_dir=${new_tmp_dir}" >> $GITHUB_ENV + else + echo "base_dir=${GITHUB_WORKSPACE}" >> $GITHUB_ENV + fi + + if [ -n "${snippet}" ]; then + extra_west_args="-S \"${snippet}\"" + fi + + echo "zephyr_version=${ZEPHYR_VERSION}" >> $GITHUB_ENV + echo "extra_west_args=${extra_west_args}" >> $GITHUB_ENV + echo "extra_cmake_args=${shield:+-DSHIELD=\"$shield\"}${zmk_load_arg}" >> $GITHUB_ENV + echo "display_name=${shield:+$shield - }${board}" >> $GITHUB_ENV + echo "artifact_name=${artifact_name:-${shield:+$shield-}${board//\//_}-zmk}" >> $GITHUB_ENV + + - name: West Init + working-directory: ${{ env.base_dir }} + run: west init -l "${{ env.base_dir }}/config" + + - name: West Update + working-directory: ${{ env.base_dir }} + run: west update --fetch-opt=--filter=tree:0 + + - name: West Zephyr export + working-directory: ${{ env.base_dir }} + run: west zephyr-export + + - name: West Build (${{ env.display_name }}) + working-directory: ${{ env.base_dir }} + shell: sh -x {0} + run: west build -s zmk/app -d "${{ env.build_dir }}" -b "${{ matrix.board }}" ${{ env.extra_west_args }} -- -DZMK_CONFIG=${{ env.base_dir }}/config ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }} + + - name: Rename artifacts + shell: sh -x {0} + run: | + mkdir "${{ 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: ${{ env.artifact_name }} + path: ${{ env.build_dir }}/artifacts