forked from poulainpi/oryx-with-custom-qmk
-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (153 loc) · 7.14 KB
/
Copy pathfetch-and-build-layout.yml
File metadata and controls
184 lines (153 loc) · 7.14 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Fetch and build layout
on:
workflow_dispatch:
inputs:
layout_id:
description: "Layout id available in URL https://configure.zsa.io/voyager/layouts/[ID_IS_HERE]/latest"
required: true
default: "emVdK"
layout_geometry:
description: "Keyboard type"
type: choice
options:
- voyager
- moonlander/reva
- moonlander/revb
- ergodox_ez
- ergodox_ez/m32u4/glow
- ergodox_ez/m32u4/shine
- ergodox_ez/stm32
- ergodox_ez/stm32/glow
- ergodox_ez/stm32/shine
- planck_ez
- planck_ez/glow
default: voyager
env:
QMK_OPENRGB_REF: module_revD
permissions:
contents: write
jobs:
fetch-and-build-layout:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v5
with:
ref: oryx
- name: Download the full history for the merge to work correctly
run: git pull --unshallow
- name: Download layout source
id: download-layout-source
run: |
response=$(curl --location 'https://oryx.zsa.io/graphql' \
--header 'Content-Type: application/json' \
--data '{"query":"query getLayout($hashId: String!, $revisionId: String!, $geometry: String) {layout(hashId: $hashId, geometry: $geometry, revisionId: $revisionId) { revision { hashId, qmkVersion, title }}}","variables":{"hashId":"${{ github.event.inputs.layout_id }}","geometry":"${{ github.event.inputs.layout_geometry }}","revisionId":"latest"}}' \
| jq '.data.layout.revision | [.hashId, .qmkVersion, .title]')
hash_id=$(echo "${response}" | jq -r '.[0]')
firmware_version=$(printf "%.0f" $(echo "${response}" | jq -r '.[1]'))
change_description=$(echo "${response}" | jq -r '.[2]')
if [[ -z "${change_description}" ]]; then
change_description="latest layout modification made with Oryx"
fi
curl -L "https://oryx.zsa.io/source/${hash_id}" -o source.zip
echo firmware_version=${firmware_version} >> "$GITHUB_OUTPUT"
echo change_description=${change_description} >> "$GITHUB_OUTPUT"
- name: Unzip the source file
run: |
unzip -oj source.zip '*_source/*' -d ${{ github.event.inputs.layout_id }}
rm source.zip
- name: Commit and Push changes
env:
CHANGE_DESCRIPTION: ${{ steps.download-layout-source.outputs.change_description }}
run: |
git config --local user.name "github-actions"
git config --local user.email "github-actions@github.com"
git add .
printf "✨(oryx): %s\n" "$CHANGE_DESCRIPTION" | git commit -F - || echo "No layout change"
git push
- name: Merge Oryx with custom QMK
run: |
git fetch origin main
git checkout -B main origin/main
git merge -Xignore-all-space oryx
git push
- name: Update QMK firmware submodule to latest version (${{ steps.download-layout-source.outputs.firmware_version }})
run: |
git submodule update --init --remote --depth=1 --no-single-branch
cd qmk_firmware
git checkout -B firmware${{ steps.download-layout-source.outputs.firmware_version }} \
origin/firmware${{ steps.download-layout-source.outputs.firmware_version }}
git submodule update --init --recursive
cd ..
git add qmk_firmware
git commit -m "✨(qmk): Update firmware" || echo "No QMK change"
git push
- name: Install QMK-OpenRGB module
if: ${{ github.event.inputs.layout_geometry == 'voyager' }}
run: |
rm -rf qmk_firmware/modules/openrgb
git clone \
--depth 1 \
--branch "${QMK_OPENRGB_REF}" \
https://gitlab.com/OpenRGBDevelopers/QMK-OpenRGB.git \
qmk_firmware/modules/openrgb
echo "QMK-OpenRGB commit: $(git -C qmk_firmware/modules/openrgb rev-parse HEAD)"
- name: Apply Voyager dual-HID patch
if: ${{ github.event.inputs.layout_geometry == 'voyager' }}
run: |
python3 scripts/patch-voyager-dual-hid.py qmk_firmware
- name: Validate Voyager OpenRGB and Oryx integration
if: ${{ github.event.inputs.layout_geometry == 'voyager' }}
run: |
# Stock OpenRGB remains on QMK Raw HID / interface 1.
grep -q 'void raw_hid_receive(uint8_t \*data, uint8_t length)' \
qmk_firmware/modules/openrgb/openrgb.c
# ZSA Oryx gets its own 32-byte interface and transport.
grep -q 'ORYX_INTERFACE' qmk_firmware/tmk_core/protocol/usb_descriptor.h
grep -q 'USB_ENDPOINT_IN_ORYX' qmk_firmware/tmk_core/protocol/chibios/usb_endpoints.c
grep -q 'oryx_hid_task' qmk_firmware/tmk_core/protocol/chibios/usb_main.c
grep -q 'void oryx_hid_receive(uint8_t \*data, uint8_t length)' \
qmk_firmware/modules/zsa/oryx/oryx.c
# The generated/custom layout must still opt into QMK-OpenRGB.
grep -q '"openrgb"' ${{ github.event.inputs.layout_id }}/keymap.json
- name: Build qmk docker image
run: docker build -t qmk .
- name: Build the layout
id: build-layout
run: |
# Set keyboard directory and make prefix based on firmware version
if [ "${{ steps.download-layout-source.outputs.firmware_version }}" -ge 24 ]; then
keyboard_directory="qmk_firmware/keyboards/zsa"
make_prefix="zsa/"
else
keyboard_directory="qmk_firmware/keyboards"
make_prefix=""
fi
# Copy layout files to the qmk folder
rm -rf ${keyboard_directory}/${{ github.event.inputs.layout_geometry }}/keymaps/${{ github.event.inputs.layout_id }}
mkdir -p ${keyboard_directory}/${{ github.event.inputs.layout_geometry }}/keymaps
cp -r ${{ github.event.inputs.layout_id }} \
${keyboard_directory}/${{ github.event.inputs.layout_geometry }}/keymaps/
# Build the layout
docker run \
-v ./qmk_firmware:/root \
--rm \
qmk \
/bin/sh -c "
qmk setup zsa/qmk_firmware \
-b firmware${{ steps.download-layout-source.outputs.firmware_version }} \
-y
make ${make_prefix}${{ github.event.inputs.layout_geometry }}:${{ github.event.inputs.layout_id }}
"
# Find and export built layout
normalized_layout_geometry="$(echo "${{ github.event.inputs.layout_geometry }}" | sed 's/\//_/g')"
echo built_layout_file=$(find ./qmk_firmware \
-maxdepth 1 \
-type f \
-regex ".*${normalized_layout_geometry}.*\.\(bin\|hex\)$") >> "$GITHUB_OUTPUT"
echo normalized_layout_geometry=${normalized_layout_geometry} >> "$GITHUB_OUTPUT"
- name: Upload layout
uses: actions/upload-artifact@v7
with:
name: ${{ steps.build-layout.outputs.normalized_layout_geometry }}_${{ github.event.inputs.layout_id }}
path: ${{ steps.build-layout.outputs.built_layout_file }}