mirror of
https://github.com/ClaytonWWilson/miryoku_zmk.git
synced 2025-12-13 17:58:47 +00:00
273 lines
10 KiB
YAML
273 lines
10 KiB
YAML
# Copyright 2021 Manna Harbour
|
|
# https://github.com/manna-harbour/miryoku
|
|
|
|
name: 'Main'
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
board:
|
|
type: string
|
|
default: '["default"]'
|
|
shield:
|
|
type: string
|
|
default: '["default"]'
|
|
alphas:
|
|
type: string
|
|
default: '["default"]'
|
|
nav:
|
|
type: string
|
|
default: '["default"]'
|
|
clipboard:
|
|
type: string
|
|
default: '["default"]'
|
|
layers:
|
|
type: string
|
|
default: '["default"]'
|
|
mapping:
|
|
type: string
|
|
default: '["default"]'
|
|
config:
|
|
type: string
|
|
default: '["default"]'
|
|
kconfig:
|
|
type: string
|
|
default: '["default"]'
|
|
merge:
|
|
type: string
|
|
default: '["default"]'
|
|
|
|
jobs:
|
|
main:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: zmkfirmware/zmk-build-arm:stable
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
board: ${{ fromJSON(inputs.board) }}
|
|
shield: ${{ fromJSON(inputs.shield) }}
|
|
alphas: ${{ fromJSON(inputs.alphas) }}
|
|
nav: ${{ fromJSON(inputs.nav) }}
|
|
clipboard: ${{ fromJSON(inputs.clipboard) }}
|
|
layers: ${{ fromJSON(inputs.layers) }}
|
|
mapping: ${{ fromJSON(inputs.mapping) }}
|
|
config: ${{ fromJSON(inputs.config) }}
|
|
kconfig: ${{ fromJSON(inputs.kconfig) }}
|
|
merge: ${{ fromJSON(inputs.merge) }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Process variables
|
|
id: variables
|
|
run: |
|
|
if [ -n "${{ matrix.shield }}" -a "${{ matrix.shield }}" != "default" ]
|
|
then
|
|
SHIELD_ARG="-DSHIELD=${{ matrix.shield }}"
|
|
keyboard=${{ matrix.shield }}
|
|
shield=${{ matrix.shield }}
|
|
else
|
|
keyboard=${{ matrix.board }}
|
|
shield=""
|
|
fi
|
|
echo "::set-output name=shield-arg::${SHIELD_ARG}"
|
|
keyboard_split="$keyboard"
|
|
keyboard_base=`echo "$keyboard" | sed 's/_\(left\|right\)//'`
|
|
|
|
configfile="${GITHUB_WORKSPACE}/miryoku/custom_config.h"
|
|
echo "::set-output name=configfile::$configfile"
|
|
|
|
artifact_build_name="miryoku_zmk $shield ${{ matrix.board }}"
|
|
|
|
if [ -n "${{ matrix.config }}" -a "${{ matrix.config }}" != 'default' ]
|
|
then
|
|
echo "${{ matrix.config }}" >> "$configfile"
|
|
artifact_build_name="$artifact_build_name config_"`echo "${{ matrix.config }}" | md5sum | cut -d ' ' -f 1`
|
|
fi
|
|
|
|
for option in "alphas_${{ matrix.alphas }}" "nav_${{ matrix.nav }}" "clipboard_${{ matrix.clipboard }}" "layers_${{ matrix.layers }}" "mapping_${{ matrix.mapping }}"
|
|
do
|
|
case "$option" in
|
|
*_ ) ;;
|
|
*_default ) ;;
|
|
* )
|
|
artifact_build_name="$artifact_build_name $option"
|
|
echo "#define MIRYOKU_"`echo "$option" | tr 'a-z' 'A-Z'` >> "$configfile"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
artifacts_dir="artifacts"
|
|
echo "::set-output name=artifact-dir::$artifacts_dir"
|
|
mkdir "$artifacts_dir"
|
|
|
|
cp "$configfile" "$artifacts_dir"
|
|
cat "$configfile"
|
|
|
|
if [ -n "${{ matrix.kconfig }}" -a "${{ matrix.kconfig }}" != 'default' ]
|
|
then
|
|
kconfig_file="config/$keyboard_split.conf"
|
|
echo "${{ matrix.kconfig }}" >> "$kconfig_file"
|
|
cp "$kconfig_file" "$artifacts_dir"
|
|
cat "$kconfig_file"
|
|
artifact_build_name="$artifact_build_name kconfig_"`echo "${{ matrix.kconfig }}" | md5sum | cut -d ' ' -f 1`
|
|
fi
|
|
|
|
if [ -n "${{ matrix.merge }}" -a "${{ matrix.merge }}" != 'default' ]
|
|
then
|
|
artifact_build_name="$artifact_build_name merge_"`echo "${{ matrix.merge }}" | md5sum | cut -d ' ' -f 1`
|
|
for branch in ${{ matrix.merge }}
|
|
do
|
|
if [ `echo "$branch" | cut -c1` = '=' ]
|
|
then
|
|
zmk=`echo "$branch" | cut -c2-`
|
|
else
|
|
merge="$merge $branch"
|
|
fi
|
|
done
|
|
fi
|
|
echo "::set-output name=merge::$merge"
|
|
echo "::set-output name=zmk::$zmk"
|
|
|
|
outboard_dir=".github/workflows/outboards"
|
|
if [ -n "$shield" ]
|
|
then
|
|
outboard_file="$outboard_dir/$keyboard_base.shield.outboard"
|
|
else
|
|
outboard_file="$outboard_dir/$keyboard_base.board.outboard"
|
|
fi
|
|
if [ ! -f "$outboard_file" ]
|
|
then
|
|
outboard_file="$outboard_dir/$keyboard_base.outboard"
|
|
fi
|
|
if [ -f "$outboard_file" ]
|
|
then
|
|
grep -v '^#' "$outboard_file" >> $GITHUB_ENV
|
|
cat "$outboard_file"
|
|
cp "$outboard_file" "$artifacts_dir"
|
|
fi
|
|
echo "::set-output name=outboard_chekout_dir::outboard"
|
|
|
|
artifact_build_name=`echo $artifact_build_name | tr ' ' '-'`
|
|
echo "::set-output name=artifact-build-name::$artifact_build_name"
|
|
echo "::set-output name=artifact-generic-name::"`echo "$artifact_build_name" | sed 's/_\(left\|right\)//'`
|
|
|
|
- name: Checkout outboard
|
|
if: ${{ env.outboard_repository != '' && env.outboard_ref != '' }}
|
|
uses: actions/checkout@v2
|
|
with:
|
|
repository: ${{ env.outboard_repository }}
|
|
ref: ${{ env.outboard_ref }}
|
|
path: ${{ steps.variables.outputs.outboard_chekout_dir }}
|
|
- name: Link outboard
|
|
if: ${{ env.outboard_from != '' && env.outboard_to != '' }}
|
|
run: |
|
|
mkdir -p `dirname "config/${{ env.outboard_to }}"`
|
|
ln -sr ${{ steps.variables.outputs.outboard_chekout_dir }}/${{ env.outboard_from }} config/${{ env.outboard_to }}
|
|
- name: Generate manifest from outboard
|
|
if: ${{ env.outboard_url_base != '' && env.outboard_revision != '' }}
|
|
run: |
|
|
echo "manifest:\n remotes:\n - name: outboard\n url-base: ${{ env.outboard_url_base }}\n projects:\n - name: zmk\n remote: outboard\n revision: ${{ env.outboard_revision }}\n import: app/west.yml\n self:\n path: config" > config/west.yml
|
|
cat config/west.yml
|
|
- name: Copy manifest from outboard
|
|
if: ${{ env.outboard_manifest != '' }}
|
|
run: |
|
|
cp ${{ steps.variables.outputs.outboard_chekout_dir }}/${{ env.outboard_manifest }} config/west.yml
|
|
cat config/west.yml
|
|
- name: Generate manifest from merge field
|
|
if: ${{ steps.variables.outputs.zmk != '' }}
|
|
run: |
|
|
user=`echo ${{ steps.variables.outputs.zmk }} | cut -f 1 -d '/'`
|
|
repo=`echo ${{ steps.variables.outputs.zmk }} | cut -f 2 -d '/'`
|
|
branch=`echo ${{ steps.variables.outputs.zmk }} | cut -f 3- -d '/'`
|
|
remote="$user-$repo"
|
|
echo "manifest:\n remotes:\n - name: $remote\n url-base: https://github.com/$user\n projects:\n - name: zmk\n remote: $remote\n repo-path: $repo\n revision: $branch\n import: app/west.yml\n self:\n path: config" > config/west.yml
|
|
cat config/west.yml
|
|
- name: Cache zmk
|
|
if: true
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
zmk/
|
|
key: zmk ${{ hashFiles('config/west.yml') }} ${{ matrix.merge }}
|
|
timeout-minutes: 2
|
|
continue-on-error: true
|
|
- name: West init
|
|
run: west init -l config
|
|
- name: West update zmk
|
|
run: west update zmk
|
|
- name: Merge branches
|
|
if: ${{ steps.variables.outputs.merge != '' }}
|
|
run: |
|
|
cd zmk
|
|
git config user.name "${GITHUB_ACTOR}"
|
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
|
for merge in ${{ steps.variables.outputs.merge }}
|
|
do
|
|
user=`echo "$merge" | cut -f 1 -d '/'`
|
|
repo=`echo "$merge" | cut -f 2 -d '/'`
|
|
branch=`echo "$merge" | cut -f 3- -d '/'`
|
|
remote="$user-$repo"
|
|
git remote add "$remote" "https://github.com/$user/$repo.git"
|
|
git fetch "$remote" "$branch"
|
|
git merge "$remote/$branch"
|
|
git remote remove "$remote"
|
|
git status
|
|
done
|
|
cd ..
|
|
cp -a zmk zmk.merged
|
|
- name: Cache zephyr
|
|
if: true
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
modules/
|
|
tools/
|
|
zephyr/
|
|
key: zephyr ${{ runner.os }} ${{ hashFiles('zmk/app/west.yml') }}
|
|
timeout-minutes: 2
|
|
continue-on-error: true
|
|
- name: West update
|
|
run: west update
|
|
- name: Restore merge
|
|
if: ${{ steps.variables.outputs.merge != '' }}
|
|
run: |
|
|
mv zmk zmk.default
|
|
mv zmk.merged zmk
|
|
- name: Export Zephyr CMake package
|
|
run: west zephyr-export
|
|
- name: Build
|
|
run: west build -s zmk/app -b ${{ matrix.board }} -- ${{ steps.variables.outputs.shield-arg }} -DZMK_CONFIG="${GITHUB_WORKSPACE}/config"
|
|
- name: Show dts.pre.tmp
|
|
if: ${{ failure() }}
|
|
run: |
|
|
dts="build/zephyr/${{ matrix.board }}.dts.pre.tmp"
|
|
if [ -f "$dts" ]
|
|
then
|
|
cat -n "$dts"
|
|
fi
|
|
- name: Convert seeeduino_xiao bin to uf2
|
|
if: ${{ matrix.board == 'seeeduino_xiao' }}
|
|
run: |
|
|
bin='build/zephyr/zmk.bin'
|
|
uf2='build/zephyr/zmk.uf2'
|
|
if [ -f "$bin" -a ! -f "$uf2" ]
|
|
then
|
|
python3 ./tools/uf2/utils/uf2conv.py -c -f SAMD21 -o "$uf2" "$bin"
|
|
fi
|
|
- name: Prepare firmware artifacts
|
|
run: |
|
|
for extension in "hex" "uf2"
|
|
do
|
|
file="build/zephyr/zmk.$extension"
|
|
if [ -f "$file" ]
|
|
then
|
|
cp "$file" "${{ steps.variables.outputs.artifact-dir }}/${{ steps.variables.outputs.artifact-build-name }}.$extension"
|
|
fi
|
|
done
|
|
- name: Archive artifacts
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: ${{ steps.variables.outputs.artifact-generic-name }}
|
|
path: ${{ steps.variables.outputs.artifact-dir }}
|
|
continue-on-error: true
|