|
| 1 | +name: rpi |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + runs_on: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + target: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + arch: |
| 13 | + default: "" |
| 14 | + type: string |
| 15 | + |
| 16 | +env: |
| 17 | + CARGO_TERM_COLOR: always |
| 18 | + PKG_CONFIG_ALLOW_SYSTEM_LIBS: 0 |
| 19 | + # Enable cross compilation for `pkg_config`. |
| 20 | + PKG_CONFIG_DIR: /opt/ |
| 21 | + PKG_CONFIG_LIBDIR: /opt/usr/lib/pkgconfig:/opt/usr/share/pkgconfig |
| 22 | + PKG_CONFIG_ALLOW_CROSS: 1 |
| 23 | + |
| 24 | +jobs: |
| 25 | + build: |
| 26 | + name: Build static binaries |
| 27 | + runs-on: ${{ inputs.runs_on }} |
| 28 | + |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v2 |
| 31 | + |
| 32 | + - uses: actions-rs/toolchain@v1 |
| 33 | + with: |
| 34 | + toolchain: stable |
| 35 | + target: ${{ inputs.target }} |
| 36 | + override: true |
| 37 | + |
| 38 | + - name: Replace target string |
| 39 | + uses: mad9000/actions-find-and-replace-string@1 |
| 40 | + id: findandreplace |
| 41 | + with: |
| 42 | + source: ${{ inputs.target }} |
| 43 | + find: 'unknown-' |
| 44 | + replace: '' |
| 45 | + |
| 46 | + - name: build dependencies |
| 47 | + if: ${{ inputs.runs_on == 'ubuntu-latest' }} |
| 48 | + run: | |
| 49 | + sudo sed -i 's/azure\.//' /etc/apt/sources.list |
| 50 | + sudo apt-get update |
| 51 | + echo "deb [arch=${{ inputs.arch }}] http://ports.ubuntu.com/ubuntu-ports focal main universe" | sudo tee -a /etc/apt/sources.list |
| 52 | + echo "deb [arch=${{ inputs.arch }}] http://ports.ubuntu.com/ubuntu-ports focal-updates main universe" | sudo tee -a /etc/apt/sources.list |
| 53 | + sudo apt update |
| 54 | + sudo dpkg --add-architecture ${{ inputs.arch }} |
| 55 | + sudo apt-get install -y curl git libudev-dev musl-tools pkg-config "libudev1:${{ inputs.arch }}" "libgcc-s1:${{ inputs.arch }}" "libc6:${{ inputs.arch }}" "libudev-dev:${{ inputs.arch }}" gcc-arm-linux-gnueabihf pkg-config-arm-linux-gnueabihf gcc-aarch64-linux-gnu pkg-config-aarch64-linux-gnu |
| 56 | +
|
| 57 | + - name: Is armv8? |
| 58 | + if: ${{ inputs.arch == 'arm64' }} |
| 59 | + run: | |
| 60 | + echo "PKG_CONFIG_PATH=/usr/lib/${{ steps.findandreplace.outputs.value }}/pkgconfig" >> $GITHUB_ENV |
| 61 | + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${{ steps.findandreplace.outputs.value }}-gcc" >> $GITHUB_ENV |
| 62 | +
|
| 63 | + - name: Is armv7? |
| 64 | + if: ${{ inputs.arch == 'armhf' }} |
| 65 | + run: | |
| 66 | + echo "PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV |
| 67 | + echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV |
| 68 | +
|
| 69 | + - name: Build binary |
| 70 | + run: cargo build --release --all --target=${{ inputs.target }} |
| 71 | + |
| 72 | + - uses: papeloto/action-zip@v1 |
| 73 | + with: |
| 74 | + files: target/${{ inputs.target }}/release/espflash${{ inputs.extension }} |
| 75 | + recursive: true |
| 76 | + dest: espflash-${{ inputs.target }}.zip |
| 77 | + |
| 78 | + - uses: papeloto/action-zip@v1 |
| 79 | + with: |
| 80 | + files: target/${{ inputs.target }}/release/cargo-espflash${{ inputs.extension }} |
| 81 | + recursive: true |
| 82 | + dest: cargo-espflash-${{ inputs.target }}.zip |
| 83 | + |
| 84 | + - uses: svenstaro/upload-release-action@v2 |
| 85 | + with: |
| 86 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + file: espflash-${{ inputs.target }}.zip |
| 88 | + tag: ${{ github.ref }} |
| 89 | + |
| 90 | + - uses: svenstaro/upload-release-action@v2 |
| 91 | + with: |
| 92 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + file: cargo-espflash-${{ inputs.target }}.zip |
| 94 | + tag: ${{ github.ref }} |
0 commit comments