From 784758ca09a6c70042c0b0c999f5f78aeaa258b6 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 4 Jan 2024 21:36:17 -0700 Subject: [PATCH] Enable CI/CD --- .gitea/build.sh | 46 +++++++++++++++++++++++++++++++++++++ .gitea/publish.sh | 26 +++++++++++++++++++++ .gitea/workflows/build.yaml | 17 ++++++++++++++ 3 files changed, 89 insertions(+) create mode 100755 .gitea/build.sh create mode 100755 .gitea/publish.sh create mode 100644 .gitea/workflows/build.yaml diff --git a/.gitea/build.sh b/.gitea/build.sh new file mode 100755 index 0000000..681def0 --- /dev/null +++ b/.gitea/build.sh @@ -0,0 +1,46 @@ +#! /bin/sh + +set -e + +log () { + echo "=== $*" +} + +# Make sure we're in the project directory +cd $(dirname $0)/.. + +mkdir -p out/ + +while read vid pid variant; do + log + log Building $vid $pid $product + log + + ## This is bananas. + rm -rf build/ + mkdir -p build/cache/ + cp -rL /usr/share/arduino /usr/share/arduino-builder build/ || true # there's a cyclic symlink that causes failure + + sed -i " + /leonardo.build.vid/ s/=.*/=$vid/ + /leonardo.build.pid/ s/=.*/=$pid/ + /leonardo.build.usb_product/ s/=.*/=\"Mockband $variant\"/ + " build/arduino/hardware/arduino/avr/boards.txt + grep 'leonardo.build' build/arduino/hardware/arduino/avr/boards.txt + + arduino-builder \ + -fqbn arduino:avr:leonardo \ + -build-path $(pwd)/build/ \ + -build-cache $(pwd)/build/cache/ \ + -hardware build/arduino/hardware \ + -tools build/arduino/tools \ + -compile MockBand.ino + + mv build/MockBand.ino.hex out/MockBand.$variant.hex + find out build/cache +done << EOD +0x1bad 0x0004 guitar +0x1bad 0x3110 drums +EOD + +ls -l out/ diff --git a/.gitea/publish.sh b/.gitea/publish.sh new file mode 100755 index 0000000..65a7556 --- /dev/null +++ b/.gitea/publish.sh @@ -0,0 +1,26 @@ +#! /bin/sh + +set -e + +PACKAGE=${GITHUB_REPOSITORY#*/} +VERSION=$GITHUB_REF_NAME + +BASE=$GITHUB_SERVER_URL/api/packages/$GITHUB_ACTOR/generic/$PACKAGE/$VERSION + +echo "=== Delete existing version: $VERSION" +curl \ + --include \ + --user "$GITHUB_ACTOR:$PACKAGE_API_TOKEN" \ + --request DELETE \ + $BASE + +for path in "$@"; do + fn=$(basename "$path") + echo "=== Upload $VERSION/$fn" + curl \ + --fail \ + --include \ + --user "$GITHUB_ACTOR:$PACKAGE_API_TOKEN" \ + --upload-file "$path" \ + $BASE/$fn +done diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..5dd1192 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,17 @@ +name: Mockband +on: [push] +jobs: + build: + runs-on: + - arduino + env: + PACKAGE_API_TOKEN: ${PACKAGE_API_TOKEN} + steps: + - name: check out repository + run: git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY . + - name: build + run: .gitea/build.sh + - name: publish + env: + PACKAGE_API_TOKEN: ${{ secrets.PACKAGE_API_TOKEN }} + run: .gitea/publish.sh out/*