-
-
Notifications
You must be signed in to change notification settings - Fork 106
134 lines (133 loc) · 4.83 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Copyright 2022 Manna Harbour
# https://github.com/manna-harbour/miryoku
name: 'Main'
on:
workflow_call:
inputs:
mode:
type: string
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"]'
kmonad_os:
type: string
default: '["default"]'
rules:
type: string
default: '["default"]'
custom_config:
type: string
default: '["default"]'
jobs:
main:
runs-on: ubuntu-latest
strategy:
matrix:
mode: ${{ fromJSON(inputs.mode) }}
alphas: ${{ fromJSON(inputs.alphas) }}
nav: ${{ fromJSON(inputs.nav) }}
clipboard: ${{ fromJSON(inputs.clipboard) }}
layers: ${{ fromJSON(inputs.layers) }}
mapping: ${{ fromJSON(inputs.mapping) }}
kmonad_os: ${{ fromJSON(inputs.kmonad_os) }}
rules: ${{ fromJSON(inputs.rules) }}
custom_config: ${{ fromJSON(inputs.custom_config) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Process inputs
id: inputs
run: |
artifacts_dir="artifacts"
mkdir "$artifacts_dir"
src='src'
build="$src/build"
rules="$src/custom_rules.mk"
config="$src/custom_config.h"
artifact_build_name='miryoku_kmonad'
for option in "alphas=${{ matrix.alphas }}" "nav=${{ matrix.nav }}" "clipboard=${{ matrix.clipboard }}" "layers=${{ matrix.layers }}" "mapping=${{ matrix.mapping }}" "kmonad_os=${{ matrix.kmonad_os }}"
do
if ! expr "$option" : '.*=default$'
then
artifact_build_name="$artifact_build_name "`echo "$option" | tr '=' '_'`
option=`echo "MIRYOKU_$option" | tr 'a-z' 'A-Z'`
echo "$option" >> "$rules"
fi
done
if [ -n "${{ matrix.rules }}" -a "${{ matrix.rules }}" != 'default' ]
then
artifact_build_name="$artifact_build_name rules_"`echo "${{ matrix.rules }}" | md5sum | cut -d ' ' -f 1`
echo "${{ matrix.rules }}" >> "$rules"
fi
if [ -n "${{ matrix.custom_config }}" -a "${{ matrix.custom_config }}" != 'default' ]
then
artifact_build_name="$artifact_build_name config_"`echo "${{ matrix.custom_config }}" | md5sum | cut -d ' ' -f 1`
echo "${{ matrix.custom_config }}" >> "$config"
fi
cp "$rules" "$config" "$artifacts_dir"
artifact_build_name=`echo $artifact_build_name | tr ' ' '-'`
echo "artifact_dir=$artifacts_dir" >> $GITHUB_OUTPUT
echo "artifact_build_name=$artifact_build_name" >> $GITHUB_OUTPUT
echo "src=src" >> $GITHUB_OUTPUT
echo "build=$build" >> $GITHUB_OUTPUT
echo "kmonad_file_pattern=kmonad-*-linux" >> $GITHUB_OUTPUT
echo "kmonad_dir=.github/workflows/bin" >> $GITHUB_OUTPUT
- name: Remove Build
if: ${{ matrix.mode == 'test' }}
run: |
rm -r "${{ steps.inputs.outputs.build }}"
mkdir "${{ steps.inputs.outputs.build }}"
git status -s "${{ steps.inputs.outputs.build }}"
- name: Build
run: cd "${{ steps.inputs.outputs.src }}" && make
- name: Copy config
if: ${{ matrix.mode == 'build' }}
run: |
for file in "${{ steps.inputs.outputs.build }}"/*
do
if [ -f "$file" ]
then
cp "$file" "${{ steps.inputs.outputs.artifact_dir }}"
fi
done
- name: Diff
if: ${{ matrix.mode == 'test' }}
run: |
git status -s "${{ steps.inputs.outputs.build }}"
git diff --exit-code "${{ steps.inputs.outputs.build }}"
- name: Download kmonad release
if: ${{ matrix.mode == 'test' }}
uses: robinraju/[email protected]
with:
repository: "kmonad/kmonad"
# latest: true
tag: "0.4.1"
fileName: "${{ steps.inputs.outputs.kmonad_file_pattern }}"
out-file-path: "${{ steps.inputs.outputs.kmonad_dir }}"
- name: Dry run
if: ${{ matrix.mode == 'test' }}
run: |
kmonad=`echo ${{ steps.inputs.outputs.kmonad_dir }}/${{ steps.inputs.outputs.kmonad_file_pattern }}`
chmod u+x "$kmonad"
for f in "${{ steps.inputs.outputs.build }}"/*.kbd
do
"$kmonad" -d "$f"
done
- name: Archive Artifacts
if: ${{ matrix.mode == 'build' }}
uses: actions/upload-artifact@v3
with:
name: ${{ steps.inputs.outputs.artifact_build_name }}
path: ${{ steps.inputs.outputs.artifact_dir }}