.github/workflows/build.yml #101
This file contains 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 Config | |
on: | |
workflow_dispatch: {} | |
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 -m pip install remarshal | |
- name: Fetch Build Matrix | |
run: | | |
echo "build_matrix=$(yaml2json build.yaml | jq -c .)" >> $GITHUB_ENV | |
yaml2json "build.yaml" | jq | |
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: Prepare variables | |
shell: sh -x {0} | |
env: | |
shield: ${{ matrix.shield }} | |
run: | | |
echo "zephyr_version=${ZEPHYR_VERSION}" >> $GITHUB_ENV | |
echo "extra_cmake_args=${shield:+-DSHIELD=\"$shield\"}" >> $GITHUB_ENV | |
echo "display_name=${shield:+$shield - }${{ matrix.board }}" >> $GITHUB_ENV | |
echo "artifact_name=${shield:+$shield-}${{ matrix.board }}-zmk" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cache west modules | |
uses: actions/cache@v3.3.2 | |
continue-on-error: true | |
env: | |
cache_name: cache-zephyr-${{ env.zephyr_version }}-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 "config" | |
- name: West Update | |
run: west update | |
- name: West Zephyr export | |
run: west zephyr-export | |
- name: West Build (${{ env.display_name }}) | |
shell: sh -x {0} | |
run: west build -s zmk/app -b "${{ matrix.board }}" -- -DZMK_CONFIG="${GITHUB_WORKSPACE}/config" ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }} | |
- name: ${{ env.display_name }} Kconfig file | |
run: grep -v -e "^#" -e "^$" build/zephyr/.config | sort | |
- name: Rename artifacts | |
id: rename-artifacts | |
shell: sh -x {0} | |
run: | | |
mkdir build/artifacts | |
if [ -f build/zephyr/zmk.uf2 ] | |
then | |
cp build/zephyr/zmk.uf2 "build/artifacts/${{ env.artifact_name }}.uf2" | |
cp build/zephyr/zmk.uf2 "/${{ env.artifact_name }}.uf2" | |
elif [ -f build/zephyr/zmk.bin ] | |
then | |
cp "build/zephyr/zmk.bin" "build/artifacts/${{ env.artifact_name }}.bin" | |
cp "build/zephyr/zmk.bin" "/${{ env.artifact_name }}.bin" | |
fi | |
- name: Zip Artifacts | |
run: | | |
apt-get update && apt-get install -y zip gnupg | |
[ -f "/${{ env.artifact_name }}.uf2" ] && | |
zip -r /firmware.zip "/${{ env.artifact_name }}.uf2" | |
[ -f "/${{ env.artifact_name }}.bin" ] && | |
zip -r /firmware.zip "/${{ env.artifact_name }}.bin" | |
exit 0 | |
- name: Archive Artifacts | |
if: steps.rename-artifacts.outcome == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: firmware | |
path: build/artifacts | |
- name: Checkout | |
if: steps.rename-artifacts.outcome == 'success' | |
uses: actions/checkout@v4 | |
- name: CD | |
run: cd /__w/reviung41/reviung41 | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_KEY_ID }} | |
passphrase: ${{ secrets.GPG_PASS }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Update Artifacts | |
if: steps.rename-artifacts.outcome == 'success' | |
env: | |
GITHUB_TOKEN: ${{ secrets.UPDATE_PACKAGE }} | |
run: | | |
git config --global user.name "Mikl Wolfe" | |
git config --global user.email "wolfemikl@gmail.com" | |
git config --global --add safe.directory /__w/reviung41/reviung41 | |
cp /firmware.zip firmware.zip | |
git add firmware.zip | |
git commit -S -m "chore(firmware): update" | |
git push origin main | |