From bcdadb104deab427a21a757a5219d9cc49dee1e5 Mon Sep 17 00:00:00 2001 From: Benji Date: Thu, 19 Nov 2026 23:52:27 +0000 Subject: [PATCH] Add workflow to build binary :) --- .gitea/workflows/build.yml | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .gitea/workflows/build.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000000..d479d9443c --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,58 @@ +name: Build firmware + +on: + push: + branches: [main] + workflow_dispatch: + +env: + KEYBOARD: preonic/rev3 + KEYMAP: mindfulminun + QMK_HOME: /root/qmk_firmware + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install toolchain and QMK CLI + run: | + apt-get update + apt-get install -y --no-install-recommends git make curl jq python3-pip pipx \ + gcc-arm-none-eabi binutils-arm-none-eabi libnewlib-arm-none-eabi + pipx install qmk + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + + - name: Clone QMK firmware + run: | + git clone --depth 1 --recurse-submodules --shallow-submodules -j8 \ + https://github.com/qmk/qmk_firmware.git "$QMK_HOME" + + - name: Compile + run: | + rm -f "$GITHUB_WORKSPACE"/*.bin + qmk config user.qmk_home="$QMK_HOME" user.overlay_dir="$GITHUB_WORKSPACE" + qmk compile -kb "$KEYBOARD" -km "$KEYMAP" + BIN=$(find "$QMK_HOME" "$GITHUB_WORKSPACE" -maxdepth 1 -name '*_mindfulminun.bin' | head -n1) + test -n "$BIN" + cp "$BIN" "$RUNNER_TEMP/firmware.bin" + echo "BIN_NAME=$(basename "$BIN")" >> "$GITHUB_ENV" + + - name: Publish rolling "latest" release + run: | + set -euo pipefail + API="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}" + AUTH="Authorization: token ${{ gitea.token }}" + + OLD=$(curl -sS -H "$AUTH" "$API/releases/tags/latest" | jq -r '.id // empty') + if [ -n "$OLD" ]; then curl -sS -X DELETE -H "$AUTH" "$API/releases/$OLD"; fi + curl -sS -X DELETE -H "$AUTH" "$API/tags/latest" || true + + ID=$(curl -sSf -X POST -H "$AUTH" -H "Content-Type: application/json" "$API/releases" \ + -d "$(jq -n --arg sha "${{ gitea.sha }}" \ + '{tag_name:"latest", target_commitish:$sha, name:"Latest firmware", body:("Built from " + $sha)}')" \ + | jq -r .id) + + curl -sSf -H "$AUTH" -F "attachment=@$RUNNER_TEMP/firmware.bin" \ + "$API/releases/$ID/assets?name=$BIN_NAME" \ No newline at end of file