From cac7355bd4fe79a1f6b75334a2dd2d12f24b5f41 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Wed, 5 Oct 2022 09:09:53 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20Split=20Raspbe?= =?UTF-8?q?rry=20CI=20files=20into=20CI=20and=20Package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/package.yml | 8 --- .github/workflows/raspberry_package.yml | 70 +++++++++++++++++++ .../{raspberry.yml => raspberry_rust.yml} | 67 +----------------- .github/workflows/release.yml | 4 +- .github/workflows/rust.yml | 5 +- 5 files changed, 77 insertions(+), 77 deletions(-) create mode 100644 .github/workflows/raspberry_package.yml rename .github/workflows/{raspberry.yml => raspberry_rust.yml} (54%) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index eb776507..5f4ace8b 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -24,38 +24,30 @@ jobs: fail-fast: false matrix: crate: ["espflash", "cargo-espflash"] - steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 with: toolchain: stable target: ${{ inputs.target }} override: true - - uses: Swatinem/rust-cache@v1 - - name: Build dependencies for other ubuntu targets if: inputs.runs_on == 'ubuntu-latest' run: | sudo sed -i 's/azure.archive.ubuntu.com/archive.ubuntu.com/' /etc/apt/sources.list sudo apt-get update sudo apt-get install musl-tools libudev-dev - - uses: actions-rs/cargo@v1 with: command: build args: --release --all --target ${{ inputs.target }} - - name: Compress (Unix) if: ${{ inputs.runs_on != 'windows-latest' }} run: zip -j ${{ matrix.crate }}-${{ inputs.target }}.zip target/${{ inputs.target }}/release/${{ matrix.crate }}${{ inputs.extension }} - - name: Compress (Windows) if: ${{ inputs.runs_on == 'windows-latest' }} run: Compress-Archive target/${{ inputs.target }}/release/${{ matrix.crate }}${{ inputs.extension }} ${{ matrix.crate }}-${{ inputs.target }}.zip - - uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/raspberry_package.yml b/.github/workflows/raspberry_package.yml new file mode 100644 index 00000000..1da02fbe --- /dev/null +++ b/.github/workflows/raspberry_package.yml @@ -0,0 +1,70 @@ +name: Rasberry Pi Package + +on: + workflow_call: + inputs: + target: + required: true + type: string + arch: + required: false + default: "" + type: string + +env: + CARGO_TERM_COLOR: always + +jobs: + publish-release: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + crate: ["espflash", "cargo-espflash"] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ inputs.target }} + override: true + - uses: Swatinem/rust-cache@v1 + - name: Replace target string + uses: mad9000/actions-find-and-replace-string@1 + id: findandreplace + with: + source: ${{ inputs.target }} + find: "unknown-" + replace: "" + - name: Build dependencies + 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 + echo "PKG_CONFIG_ALLOW_SYSTEM_LIBS=0" >> $GITHUB_ENV + echo "PKG_CONFIG_DIR=/opt/" >> $GITHUB_ENV + echo "PKG_CONFIG_LIBDIR=/opt/usr/lib/pkgconfig:/opt/usr/share/pkgconfig" >> $GITHUB_ENV + echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV + if [[ ${{ inputs.arch }} == arm64 ]]; then + 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 + fi + if [[ ${{ inputs.arch }} == armhf ]]; then + 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 + fi + - uses: actions-rs/cargo@v1 + with: + command: build + args: --release --all --target ${{ inputs.target }} --features=raspberry + - name: Compress + run: zip -j ${{ matrix.crate }}-${{ inputs.target }}.zip target/${{ inputs.target }}/release/${{ matrix.crate }}${{ inputs.extension }} + - uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ matrix.crate }}-${{ inputs.target }}.zip + tag: ${{ github.ref }} diff --git a/.github/workflows/raspberry.yml b/.github/workflows/raspberry_rust.yml similarity index 54% rename from .github/workflows/raspberry.yml rename to .github/workflows/raspberry_rust.yml index 2466684c..169b3f98 100644 --- a/.github/workflows/raspberry.yml +++ b/.github/workflows/raspberry_rust.yml @@ -1,4 +1,4 @@ -name: Rasberry Pi +name: Rasberry Pi CI on: pull_request: @@ -6,77 +6,12 @@ on: - master push: workflow_dispatch: - workflow_call: - inputs: - target: - required: true - type: string - arch: - required: false - default: "" - type: string env: CARGO_TERM_COLOR: always jobs: - publish-release: - if: github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - crate: ["espflash", "cargo-espflash"] - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: ${{ inputs.target }} - override: true - - uses: Swatinem/rust-cache@v1 - - name: Replace target string - uses: mad9000/actions-find-and-replace-string@1 - id: findandreplace - with: - source: ${{ inputs.target }} - find: "unknown-" - replace: "" - - name: Build dependencies - 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 - echo "PKG_CONFIG_ALLOW_SYSTEM_LIBS=0" >> $GITHUB_ENV - echo "PKG_CONFIG_DIR=/opt/" >> $GITHUB_ENV - echo "PKG_CONFIG_LIBDIR=/opt/usr/lib/pkgconfig:/opt/usr/share/pkgconfig" >> $GITHUB_ENV - echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV - if [[ ${{ inputs.arch }} == arm64 ]]; then - 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 - fi - if [[ ${{ inputs.arch }} == armhf ]]; then - 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 - fi - - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --all --target ${{ inputs.target }} --features=raspberry - - name: Compress - run: zip -j ${{ matrix.crate }}-${{ inputs.target }}.zip target/${{ inputs.target }}/release/${{ matrix.crate }}${{ inputs.extension }} - - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ matrix.crate }}-${{ inputs.target }}.zip - tag: ${{ github.ref }} - rust-ci: - if: github.event_name != 'workflow_dispatch' name: "Rust CI: ${{ matrix.job.name }} - ${{ matrix.board.target }}" runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ff7663c..b26202ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,13 +8,13 @@ jobs: # Linux armv7-unknown-linux-gnueabihf: - uses: ./.github/workflows/raspberry.yml + uses: ./.github/workflows/raspberry_package.yml with: target: armv7-unknown-linux-gnueabihf arch: armhf aarch64-unknown-linux-gnu: - uses: ./.github/workflows/raspberry.yml + uses: ./.github/workflows/raspberry_package.yml with: target: aarch64-unknown-linux-gnu arch: arm64 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f302c382..684d4146 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,3 +1,5 @@ +name: CI + on: pull_request: branches: @@ -5,7 +7,8 @@ on: push: workflow_dispatch: -name: CI +env: + CARGO_TERM_COLOR: always jobs: check: