diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1468145c..93decedc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,20 @@ name: Release jobs: # Linux + armv7-unknown-linux-gnueabihf: + uses: ./.github/workflows/rpi.yml + with: + runs_on: ubuntu-latest + target: armv7-unknown-linux-gnueabihf + arch: armhf + + aarch64-unknown-linux-gnu: + uses: ./.github/workflows/rpi.yml + with: + runs_on: ubuntu-latest + target: aarch64-unknown-linux-gnu + arch: arm64 + x86_64-unknown-linux-gnu: uses: ./.github/workflows/package.yml with: diff --git a/.github/workflows/rpi.yml b/.github/workflows/rpi.yml new file mode 100644 index 00000000..824a149b --- /dev/null +++ b/.github/workflows/rpi.yml @@ -0,0 +1,94 @@ +name: rpi + +on: + workflow_call: + inputs: + runs_on: + required: true + type: string + target: + required: true + type: string + arch: + default: "" + type: string + +env: + CARGO_TERM_COLOR: always + PKG_CONFIG_ALLOW_SYSTEM_LIBS: 0 + # Enable cross compilation for `pkg_config`. + PKG_CONFIG_DIR: /opt/ + PKG_CONFIG_LIBDIR: /opt/usr/lib/pkgconfig:/opt/usr/share/pkgconfig + PKG_CONFIG_ALLOW_CROSS: 1 + +jobs: + build: + name: Build static binaries + runs-on: ${{ inputs.runs_on }} + + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ inputs.target }} + override: true + + - name: Replace target string + uses: mad9000/actions-find-and-replace-string@1 + id: findandreplace + with: + source: ${{ inputs.target }} + find: 'unknown-' + replace: '' + + - name: build dependencies + if: ${{ inputs.runs_on == 'ubuntu-latest' }} + run: | + sudo sed -i 's/azure\.//' /etc/apt/sources.list + sudo apt-get update + echo "deb [arch=${{ inputs.arch }}] http://ports.ubuntu.com/ubuntu-ports focal main universe" | sudo tee -a /etc/apt/sources.list + echo "deb [arch=${{ inputs.arch }}] http://ports.ubuntu.com/ubuntu-ports focal-updates main universe" | sudo tee -a /etc/apt/sources.list + sudo apt update + sudo dpkg --add-architecture ${{ inputs.arch }} + 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 + + - name: Is armv8? + if: ${{ inputs.arch == 'arm64' }} + run: | + echo "PKG_CONFIG_PATH=/usr/lib/${{ steps.findandreplace.outputs.value }}/pkgconfig" >> $GITHUB_ENV + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${{ steps.findandreplace.outputs.value }}-gcc" >> $GITHUB_ENV + + - name: Is armv7? + if: ${{ inputs.arch == 'armhf' }} + run: | + echo "PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV + echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV + + - name: Build binary + run: cargo build --release --all --target=${{ inputs.target }} + + - uses: papeloto/action-zip@v1 + with: + files: target/${{ inputs.target }}/release/espflash${{ inputs.extension }} + recursive: true + dest: espflash-${{ inputs.target }}.zip + + - uses: papeloto/action-zip@v1 + with: + files: target/${{ inputs.target }}/release/cargo-espflash${{ inputs.extension }} + recursive: true + dest: cargo-espflash-${{ inputs.target }}.zip + + - uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: espflash-${{ inputs.target }}.zip + tag: ${{ github.ref }} + + - uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: cargo-espflash-${{ inputs.target }}.zip + tag: ${{ github.ref }}