|
| 1 | +name: Dispatchable build |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + firmware_type: |
| 6 | + description: 'Firmware Type' |
| 7 | + default: 'esp32-fota-http' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + manifest_url: |
| 11 | + description: 'Complete URL (where the JSON Manifest will be hosted)' |
| 12 | + required: true |
| 13 | + default: 'https://github.com/[user]/[repo]/raw/[branch]/[path to manifest]/firmware.json' |
| 14 | + type: string |
| 15 | + manifest_host: |
| 16 | + description: 'Hostname (where the binaries will be hosted)' |
| 17 | + required: true |
| 18 | + default: 'github.com' |
| 19 | + type: string |
| 20 | + manifest_port: |
| 21 | + description: 'Port (e.g 80 or 443)' |
| 22 | + required: true |
| 23 | + default: '443' |
| 24 | + type: string |
| 25 | + manifest_bin_path: |
| 26 | + description: 'Path (no trailing slash)' |
| 27 | + required: true |
| 28 | + default: '/[user]/[repo]/blob/[branch]/[path to binaries]' |
| 29 | + type: string |
| 30 | + board_fqbn: |
| 31 | + description: 'Board FQBN (for arduino-cli)' |
| 32 | + required: true |
| 33 | + default: 'esp32:esp32:esp32' |
| 34 | + type: string |
| 35 | + partition_scheme: |
| 36 | + description: 'Partition scheme' |
| 37 | + required: true |
| 38 | + type: choice |
| 39 | + options: |
| 40 | + - default |
| 41 | + - min_spiffs |
| 42 | + - large_spiffs |
| 43 | + default: 'default' |
| 44 | + |
| 45 | +jobs: |
| 46 | + |
| 47 | + matrix_build: |
| 48 | + |
| 49 | + name: ${{ matrix.sketch }} |
| 50 | + runs-on: ubuntu-latest |
| 51 | + |
| 52 | + strategy: |
| 53 | + matrix: |
| 54 | + |
| 55 | + sketch: |
| 56 | + - 1.nosecurity.ino |
| 57 | + - 2.cert-in-spiffs.ino |
| 58 | + - 3.cert-in-progmem.ino |
| 59 | + - 4.cert-in-littlefs.ino |
| 60 | + - 5.final-stage.ino |
| 61 | + |
| 62 | + steps: |
| 63 | + |
| 64 | + - name: Checkout |
| 65 | + uses: actions/checkout@v2 |
| 66 | + with: |
| 67 | + ref: ${{ github.event.pull_request.head.sha }} |
| 68 | + |
| 69 | + - name: Inject Manifest URL |
| 70 | + run: | |
| 71 | + full_ino_path=`find /home/runner/work/ | grep "${{ matrix.sketch }}"` |
| 72 | + echo -e "#define FOTA_URL \"${{ inputs.manifest_url }}\"\n$(cat $full_ino_path)" > $full_ino_path |
| 73 | +
|
| 74 | +
|
| 75 | + - name: Inject TLS Cert if applicable |
| 76 | + if: (inputs.manifest_port == '443' || inputs.manifest_port == '4433') |
| 77 | + run: | |
| 78 | + full_rootca_path=`find /home/runner/work/ | grep "progmem/root_ca.h"` |
| 79 | + ssl_host="${{ inputs.manifest_host }}" |
| 80 | + prefix="const char* root_ca =\\" |
| 81 | + suffix="\"\";" |
| 82 | + echo $prefix > $full_rootca_path |
| 83 | + openssl s_client -showcerts -connect $ssl_host:${{ inputs.manifest_port }} </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | awk '{print "\"" $0 "\\n\"\\"}' >> $full_rootca_path |
| 84 | + echo $suffix >> $full_rootca_path |
| 85 | + cat $full_rootca_path |
| 86 | +
|
| 87 | +
|
| 88 | + - name: ${{ matrix.sketch }} |
| 89 | + uses: ArminJo/arduino-test-compile@v3 |
| 90 | + with: |
| 91 | + platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json |
| 92 | + arduino-board-fqbn: ${{ inputs.board_fqbn }}:PartitionScheme=${{inputs.partition_scheme}} |
| 93 | + required-libraries: ArduinoJson |
| 94 | + extra-arduino-lib-install-args: --no-deps |
| 95 | + extra-arduino-cli-args: "--warnings default " # see https://github.com/ArminJo/arduino-test-compile/issues/28 |
| 96 | + sketch-names: ${{ matrix.sketch }} |
| 97 | + set-build-path: true |
| 98 | + # build-properties: ${{ toJson(matrix.build-properties) }} |
| 99 | + # arduino-platform: esp32:esp32@${{ matrix.sdk-version }} |
| 100 | + # extra-arduino-cli-args: ${{ matrix.extra-arduino-cli-args }} |
| 101 | + # debug-install: true |
| 102 | + |
| 103 | + - name: Save compiled binaries |
| 104 | + run: | |
| 105 | + mkdir -p /home/runner/builds |
| 106 | + ls /home/runner/builds -la |
| 107 | + cd /home/runner/work/ |
| 108 | + full_ino_bin_path=`find . | grep "build/${{ matrix.sketch }}.bin"` |
| 109 | + echo "Bin path: $full_ino_bin_path" |
| 110 | + cp "$full_ino_bin_path" /home/runner/builds/${{ matrix.sketch }}.bin |
| 111 | +
|
| 112 | + - name: Prepare data folder if applicable |
| 113 | + if: (inputs.manifest_port == '443' || inputs.manifest_port == '4433') |
| 114 | + run: | |
| 115 | + full_rootca_path=`find /home/runner/work/ | grep "anyFS/data/root_ca.pem"` |
| 116 | + ssl_host="${{ inputs.manifest_host }}" |
| 117 | + openssl s_client -showcerts -connect $ssl_host:${{ inputs.manifest_port }} </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $full_rootca_path |
| 118 | + cat $full_rootca_path |
| 119 | +
|
| 120 | + - name: Create filesystem images |
| 121 | + run: | |
| 122 | + # ooh that's dirty :-) |
| 123 | + default_size=0x170000 |
| 124 | + large_spiffs_size=0x6F0000 |
| 125 | + min_spiffs_size=0x30000 |
| 126 | +
|
| 127 | + mkspiffs_esp32=~/.arduino15/packages/esp32*/tools/mkspiffs/*/mkspiffs |
| 128 | + mklittlefs_esp32=~/.arduino15/packages/esp32*/tools/mklittlefs/*/mklittlefs |
| 129 | + echo "mkspiffs path: $mkspiffs_esp32" |
| 130 | + echo "mklittlefs path: $mklittlefs_esp32" |
| 131 | + $mkspiffs_esp32 -c examples/anyFS/data/ -p 256 -b 4096 -s $${{inputs.partition_scheme}}_size /home/runner/builds/2.cert-in-spiffs.spiffs.bin |
| 132 | + $mklittlefs_esp32 -c examples/anyFS/data/ -p 256 -b 4096 -s $${{inputs.partition_scheme}}_size /home/runner/builds/4.cert-in-littlefs.littlefs.bin |
| 133 | + ls /home/runner/builds -la |
| 134 | +
|
| 135 | + - name: Upload artifact for Stage ${{ matrix.test-stage }} |
| 136 | + uses: actions/upload-artifact@v2 |
| 137 | + with: |
| 138 | + name: TestSuite |
| 139 | + path: | |
| 140 | + /home/runner/builds/** |
| 141 | +
|
| 142 | +
|
| 143 | + post_build: |
| 144 | + name: Gather Artefacts |
| 145 | + runs-on: ubuntu-latest |
| 146 | + # wait until matrix jobs are all finished |
| 147 | + needs: matrix_build |
| 148 | + steps: |
| 149 | + |
| 150 | + - name: Checkout |
| 151 | + uses: actions/checkout@v2 |
| 152 | + |
| 153 | + - name: Create artifacts dir |
| 154 | + run: mkdir -p /home/runner/builds |
| 155 | + |
| 156 | + #- name: Download artifacts |
| 157 | + #uses: actions/download-artifact@v2 |
| 158 | + #with: |
| 159 | + #path: /home/runner/builds |
| 160 | + |
| 161 | + - name: Polulate JSON Manifest |
| 162 | + run: | |
| 163 | + firmware_json_path=/home/runner/builds/firmware.json |
| 164 | + cp .github/templates/firmware.test-suite.json $firmware_json_path |
| 165 | + sed -i -e 's/FIRMWARE_TYPE/${{ inputs.firmware_type }}/g' $firmware_json_path |
| 166 | + sed -i -e 's/FIRMWARE_HOST/${{ inputs.manifest_host }}/g' $firmware_json_path |
| 167 | + sed -i -e 's/FIRMWARE_PORT/${{ inputs.manifest_port }}/g' $firmware_json_path |
| 168 | + sed -i -e 's~FIRMWARE_PATH~${{ inputs.manifest_bin_path }}~g' $firmware_json_path |
| 169 | + cat $firmware_json_path |
| 170 | +
|
| 171 | + - name: Update artifacts with new JSON Manifest |
| 172 | + uses: actions/upload-artifact@v2 |
| 173 | + with: |
| 174 | + name: TestSuite |
| 175 | + path: | |
| 176 | + /home/runner/builds/** |
| 177 | +
|
| 178 | +
|
| 179 | + - name: Release check |
| 180 | + uses: softprops/action-gh-release@v1 |
| 181 | + if: startsWith(github.ref, 'refs/tags/') |
| 182 | + with: |
| 183 | + files: | |
| 184 | + /home/runner/builds/** |
| 185 | +
|
| 186 | +
|
0 commit comments