From 893dcf48872a15e89f0403ec5d4dccea294226ae Mon Sep 17 00:00:00 2001 From: Dinko Korunic Date: Mon, 26 Sep 2022 17:49:01 +0200 Subject: [PATCH] Build related updates --- .github/workflows/release.yml | 135 ++++++++++++++++------------------ Cargo.toml | 1 + 2 files changed, 66 insertions(+), 70 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de9e767..f47c6ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: release on: push: tags: - - "[0-9]+.[0-9]+.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+" jobs: create-release: name: create-release @@ -28,7 +28,7 @@ jobs: build-release: name: build-release - needs: ['create-release'] + needs: ["create-release"] runs-on: ${{ matrix.os }} env: CARGO: cargo @@ -37,80 +37,75 @@ jobs: RUST_BACKTRACE: 1 strategy: matrix: - build: [linux, linux-arm, macos] + build: [linux, linux-arm, linux-arm64, macos, macos-m1] include: - - build: linux - os: ubuntu-latest - rust: stable - target: x86_64-unknown-linux-musl - - build: linux-arm - os: ubuntu-latest - rust: stable - target: arm-unknown-linux-gnueabihf - - build: macos - os: macos-latest - rust: stable - target: x86_64-apple-darwin + - build: linux + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-musl + - build: linux-arm + os: ubuntu-latest + rust: stable + target: arm-unknown-linux-gnueabihf + - build: linux-arm64 + os: ubuntu-latest + rust: stable + target: aarch64-unknown-linux-gnu + - build: macos + os: macos-latest + rust: stable + target: x86_64-apple-darwin + - build: macos-m1 + os: macos-latest + rust: stable + target: aarch64-apple-darwin steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.rust }} - target: ${{ matrix.target }} - - - name: Use Cross - shell: bash - run: | - cargo install cross - echo "CARGO=cross" >> $GITHUB_ENV - echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV - echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 1 - - name: Show command used for Cargo - run: | - echo "cargo command is: ${{ env.CARGO }}" - echo "target flag is: ${{ env.TARGET_FLAGS }}" - echo "target dir is: ${{ env.TARGET_DIR }}" + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + target: ${{ matrix.target }} - - name: Build release binary - run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }} + - name: Use Cross + shell: bash + run: | + cargo install cross + echo "CARGO=cross" >> $GITHUB_ENV + echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV + echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV - - name: Strip release binary (linux and macos) - if: matrix.build == 'linux' || matrix.build == 'macos' - run: strip "target/${{ matrix.target }}/release/findlargedir" + - name: Show command used for Cargo + run: | + echo "cargo command is: ${{ env.CARGO }}" + echo "target flag is: ${{ env.TARGET_FLAGS }}" + echo "target dir is: ${{ env.TARGET_DIR }}" - - name: Strip release binary (arm) - if: matrix.build == 'linux-arm' - run: | - docker run --rm -v \ - "$PWD/target:/target:Z" \ - rustembedded/cross:arm-unknown-linux-gnueabihf \ - arm-linux-gnueabihf-strip \ - /target/arm-unknown-linux-gnueabihf/release/findlargedir + - name: Build release binary + run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }} - - name: Build archive - shell: bash - run: | - outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")" - staging="findlargedir-${{ needs.create-release.outputs.fl_version }}-${{ matrix.target }}" - mkdir -p "$staging" - cp {README.md,LICENSE} "$staging" - cp "target/${{ matrix.target }}/release/findlargedir" "$staging" - tar -cJf "$staging.tar.xz" "$staging" - echo "ASSET=$staging.tar.xz" >> $GITHUB_ENV + - name: Build archive + shell: bash + run: | + outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")" + staging="findlargedir-${{ needs.create-release.outputs.fl_version }}-${{ matrix.target }}" + mkdir -p "$staging" + cp {README.md,LICENSE} "$staging" + cp "target/${{ matrix.target }}/release/findlargedir" "$staging" + tar -cJf "$staging.tar.xz" "$staging" + echo "ASSET=$staging.tar.xz" >> $GITHUB_ENV - - name: Upload release archive - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: ${{ env.ASSET }} - asset_name: ${{ env.ASSET }} - asset_content_type: application/octet-stream + - name: Upload release archive + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: ${{ env.ASSET }} + asset_name: ${{ env.ASSET }} + asset_content_type: application/octet-stream diff --git a/Cargo.toml b/Cargo.toml index 27b94a2..44e7a48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,3 +29,4 @@ fs-err = "2.8.1" [profile.release] lto = true +strip = true