|
| 1 | +# |
| 2 | +# Copyright 2023 Fred Dushin <[email protected]> |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later |
| 5 | +# |
| 6 | + |
| 7 | +name: "Build MQTT Client" |
| 8 | + |
| 9 | +on: ["push", "pull_request"] |
| 10 | + |
| 11 | +jobs: |
| 12 | + esp32-build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + container: espressif/idf:v${{ matrix.idf-version }} |
| 15 | + |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + idf-version: ["4.4.3"] |
| 19 | + otp: ["24"] |
| 20 | + elixir_version: ["1.11"] |
| 21 | + soc: ["esp32", "esp32c3", "esp32s2", "esp32s3"] |
| 22 | + |
| 23 | + env: |
| 24 | + ImageOS: "ubuntu20" |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout repo |
| 28 | + uses: actions/checkout@v2 |
| 29 | + |
| 30 | + - uses: erlef/setup-beam@v1 |
| 31 | + with: |
| 32 | + otp-version: ${{ matrix.otp }} |
| 33 | + elixir-version: ${{ matrix.elixir_version }} |
| 34 | + |
| 35 | + - name: "APT update" |
| 36 | + run: apt update -y |
| 37 | + |
| 38 | + - name: "Install deps" |
| 39 | + run: DEBIAN_FRONTEND=noninteractive apt install -y git cmake |
| 40 | + |
| 41 | + - name: "System info" |
| 42 | + run: | |
| 43 | + echo "**uname:**" |
| 44 | + uname -a |
| 45 | + echo "**OTP version:**" |
| 46 | + cat $(dirname $(which erlc))/../releases/RELEASES || true |
| 47 | +
|
| 48 | + - name: "Check out AtomVM" |
| 49 | + run: | |
| 50 | + pwd |
| 51 | + ls -l |
| 52 | + git clone https://github.com/atomvm/AtomVM |
| 53 | + cd AtomVM |
| 54 | + git rev-parse --short HEAD |
| 55 | +
|
| 56 | + - name: "Build: run cmake" |
| 57 | + working-directory: AtomVM |
| 58 | + run: | |
| 59 | + mkdir build |
| 60 | + cd build |
| 61 | + cmake .. |
| 62 | +
|
| 63 | + - name: "Build erlang and Elixir libs" |
| 64 | + working-directory: AtomVM/build/libs |
| 65 | + run: | |
| 66 | + make |
| 67 | +
|
| 68 | + - name: "Build ${{ matrix.soc }} AtomVM with atomvm_mqtt_client" |
| 69 | + working-directory: ./AtomVM/src/platforms/esp32/ |
| 70 | + run: | |
| 71 | + cd components |
| 72 | + ln -s /__w/atomvm_mqtt_client/atomvm_mqtt_client |
| 73 | + cd .. |
| 74 | + . $IDF_PATH/export.sh |
| 75 | + idf.py set-target ${{ matrix.soc }} |
| 76 | + idf.py reconfigure |
| 77 | + idf.py build |
| 78 | +
|
| 79 | + - name: "Create a ${{ matrix.soc }} atomvm_mqtt_client image" |
| 80 | + working-directory: ./AtomVM/src/platforms/esp32/build |
| 81 | + run: | |
| 82 | + ./mkimage.sh |
| 83 | + for i in atomvm-${{ matrix.soc }}-*.img; do |
| 84 | + mv -- "${i}" "${i%.img}-atomvm_mqtt_client.img" |
| 85 | + done |
| 86 | + ls -l *.img |
| 87 | +
|
| 88 | + - name: "Upload ${{ matrix.soc }} artifacts" |
| 89 | + uses: actions/upload-artifact@v3 |
| 90 | + with: |
| 91 | + name: atomvm-${{ matrix.soc }}-atomvm_mqtt_client-image |
| 92 | + path: ./AtomVM/src/platforms/esp32/build/atomvm-${{ matrix.soc }}-*.img |
| 93 | + if-no-files-found: error |
| 94 | + |
| 95 | + avm-build: |
| 96 | + |
| 97 | + runs-on: ubuntu-latest |
| 98 | + steps: |
| 99 | + - name: Checkout repo |
| 100 | + uses: actions/checkout@v2 |
| 101 | + |
| 102 | + - uses: erlef/setup-beam@v1 |
| 103 | + with: |
| 104 | + otp-version: "24" |
| 105 | + |
| 106 | + - name: "Build rebar3" |
| 107 | + run: | |
| 108 | + cd /tmp |
| 109 | + git clone https://github.com/erlang/rebar3.git |
| 110 | + cd rebar3 |
| 111 | + ./bootstrap |
| 112 | +
|
| 113 | + - name: "Build atomvm_mqtt_client AVM" |
| 114 | + run: | |
| 115 | + REBAR="/tmp/rebar3/rebar3" |
| 116 | + ${REBAR} fmt -c |
| 117 | + ${REBAR} packbeam -f -i |
| 118 | +
|
| 119 | + - name: "Upload atomvm_mqtt_client AVM" |
| 120 | + uses: actions/upload-artifact@v3 |
| 121 | + with: |
| 122 | + name: atomvm-mqtt_client-avm |
| 123 | + path: ./_build/default/lib/mqtt_client.avm |
| 124 | + if-no-files-found: error |
| 125 | + |
| 126 | + - name: "Build Example Programs" |
| 127 | + run: | |
| 128 | + REBAR="/tmp/rebar3/rebar3" |
| 129 | + EXAMPLES="mqtt_client_example" |
| 130 | + for i in ${EXAMPLES}; do cd ./examples/$i; ${REBAR} fmt -c || exit 1; ${REBAR} packbeam -p -f -i || exit 1; cd ../..; done |
| 131 | +
|
| 132 | + release-if-master: |
| 133 | + if: github.ref_name == 'master' |
| 134 | + needs: ["esp32-build", "avm-build"] |
| 135 | + runs-on: ubuntu-latest |
| 136 | + steps: |
| 137 | + - name: "Download artifacts" |
| 138 | + uses: actions/download-artifact@v3 |
| 139 | + |
| 140 | + - name: Display structure of downloaded files |
| 141 | + run: | |
| 142 | + ls -R |
| 143 | +
|
| 144 | + - name: Upload latest release |
| 145 | + uses: pyTooling/Actions/releaser@main |
| 146 | + with: |
| 147 | + tag: latest |
| 148 | + rm: true |
| 149 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 150 | + files: | |
| 151 | + atomvm-esp32-atomvm_mqtt_client-image/*.img |
| 152 | + atomvm-esp32c3-atomvm_mqtt_client-image/*.img |
| 153 | + atomvm-esp32s2-atomvm_mqtt_client-image/*.img |
| 154 | + atomvm-esp32s3-atomvm_mqtt_client-image/*.img |
| 155 | + atomvm-mqtt_client-avm/*.avm |
0 commit comments