mirror of
https://github.com/ClaytonWWilson/miryoku_zmk.git
synced 2025-12-13 17:58:47 +00:00
235 lines
8.2 KiB
YAML
235 lines
8.2 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"]'
|
|
cutom_config:
|
|
type: string
|
|
default: '["default"]'
|
|
kconfig:
|
|
type: string
|
|
default: '["default"]'
|
|
branches:
|
|
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) }}
|
|
cutom_config: ${{ fromJSON(inputs.cutom_config) }}
|
|
kconfig: ${{ fromJSON(inputs.kconfig) }}
|
|
branches: ${{ fromJSON(inputs.branches) }}
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
path: 'miryoku_zmk'
|
|
- name: main
|
|
id: variables
|
|
run: |
|
|
echo "::group::variables"
|
|
|
|
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_zmk/miryoku/custom_config.h"
|
|
echo "::set-output name=configfile::$configfile"
|
|
|
|
echo "#define MIRYOKU_KEYBOARD_"`echo "$keyboard_base" | tr '[a-z]' '[A-Z]'` >> "$configfile"
|
|
|
|
artifact_build_name="miryoku_zmk $shield ${{ matrix.board }}"
|
|
|
|
if [ -n "${{ matrix.cutom_config }}" -a "${{ matrix.cutom_config }}" != 'default' ]
|
|
then
|
|
echo "${{ matrix.cutom_config }}" >> "$configfile"
|
|
artifact_build_name="$artifact_build_name config_"`echo "${{ matrix.cutom_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="${GITHUB_WORKSPACE}/artifacts"
|
|
echo "::set-output name=artifact-dir::$artifacts_dir"
|
|
mkdir "$artifacts_dir"
|
|
|
|
cp "$configfile" "$artifacts_dir"
|
|
|
|
if [ -n "${{ matrix.kconfig }}" -a "${{ matrix.kconfig }}" != 'default' ]
|
|
then
|
|
kconfig_file="${GITHUB_WORKSPACE}/miryoku_zmk/config/$keyboard_split.conf"
|
|
echo "${{ matrix.kconfig }}" >> "$kconfig_file"
|
|
cp "$kconfig_file" "$artifacts_dir"
|
|
artifact_build_name="$artifact_build_name kconfig_"`echo "${{ matrix.kconfig }}" | md5sum | cut -d ' ' -f 1`
|
|
fi
|
|
|
|
. "${GITHUB_WORKSPACE}/miryoku_zmk/.github/workflows/zmk"
|
|
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::outboards"
|
|
if [ -n "$shield" ]
|
|
then
|
|
outboards="shields/$keyboard_base boards/${{ matrix.board }}"
|
|
else
|
|
outboards="boards/$keyboard_base"
|
|
fi
|
|
for outboard in $outboards
|
|
do
|
|
outboard_file="${GITHUB_WORKSPACE}/miryoku_zmk/.github/workflows/outboards/$outboard"
|
|
if [ -f "$outboard_file" ]
|
|
then
|
|
cp "$outboard_file" "$artifacts_dir"
|
|
. "$outboard_file"
|
|
outboard_dir="${GITHUB_WORKSPACE}/outboards/$outboard"
|
|
if [ -n "$outboard_repository" -a -n "$outboard_ref" ]
|
|
then
|
|
git clone -b "$outboard_ref" --depth 1 "https://github.com/$outboard_repository.git" "$outboard_dir"
|
|
if [ -n "$outboard_from" -a -n "$outboard_to" ]
|
|
then
|
|
to="${GITHUB_WORKSPACE}/miryoku_zmk/config/$outboard_to"
|
|
mkdir -p `dirname "$to"`
|
|
ln -sr "$outboard_dir/$outboard_from" "$to"
|
|
fi
|
|
fi
|
|
outboard_repository=''
|
|
outboard_ref=''
|
|
outboard_from=''
|
|
outboard_to=''
|
|
fi
|
|
done
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::zmk"
|
|
if [ -n "${{ matrix.branches }}" -a "${{ matrix.branches }}" != 'default' ]
|
|
then
|
|
artifact_build_name="$artifact_build_name branches_"`echo "${{ matrix.branches }}" | md5sum | cut -d ' ' -f 1`
|
|
zmk=`echo "${{ matrix.branches }}" | cut -d ' ' -f 1`
|
|
merges=`echo "${{ matrix.branches }}" | cut -d ' ' -f 2- -s`
|
|
fi
|
|
|
|
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\)//'`
|
|
|
|
user=`echo "$zmk" | cut -f 1 -d '/'`
|
|
repo=`echo "$zmk" | cut -f 2 -d '/'`
|
|
branch=`echo "$zmk" | cut -f 3- -d '/'`
|
|
git clone -b "$branch" --depth 1 "https://github.com/$user/$repo.git" 'zmk'
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::merge"
|
|
if [ -n "$merges" ]
|
|
then
|
|
cd "${GITHUB_WORKSPACE}/zmk"
|
|
git config user.name "${GITHUB_ACTOR}"
|
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
|
git fetch --unshallow
|
|
for merge in "$merges"
|
|
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
|
|
fi
|
|
echo "::endgroup::"
|
|
- name: cache
|
|
if: true
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
zmk/modules/
|
|
zmk/zephyr/
|
|
key: zephyr ${{ runner.os }} ${{ hashFiles('zmk/app/west.yml') }}
|
|
timeout-minutes: 2
|
|
continue-on-error: true
|
|
- name: build
|
|
run: |
|
|
echo "::group::setup"
|
|
cd "${GITHUB_WORKSPACE}/zmk"
|
|
west init -l app
|
|
west update
|
|
west zephyr-export
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::build"
|
|
cd "${GITHUB_WORKSPACE}/zmk/app"
|
|
west build -b ${{ matrix.board }} -- ${{ steps.variables.outputs.shield-arg }} -DZMK_CONFIG="${GITHUB_WORKSPACE}/miryoku_zmk/config"
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::copy"
|
|
for extension in "uf2"
|
|
do
|
|
file="${GITHUB_WORKSPACE}/zmk/app/build/zephyr/zmk.$extension"
|
|
if [ -f "$file" ]
|
|
then
|
|
cp "$file" "${{ steps.variables.outputs.artifact-dir }}/${{ steps.variables.outputs.artifact-build-name }}.$extension"
|
|
fi
|
|
done
|
|
echo "::endgroup::"
|
|
- name: upload
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ steps.variables.outputs.artifact-generic-name }}
|
|
path: ${{ steps.variables.outputs.artifact-dir }}
|
|
|