From c6145204052a0ede75c57ac7e6f704e28fbdc5db Mon Sep 17 00:00:00 2001 From: Patrick Dung <38665827+patrickdung@users.noreply.github.com> Date: Sun, 10 Oct 2021 02:21:30 +0800 Subject: [PATCH 1/7] Cross build with action-rs --- .github/workflows/publish-crossbuild.yml | 111 +++++++++++++++++++++++ Cross.toml | 7 ++ 2 files changed, 118 insertions(+) create mode 100644 .github/workflows/publish-crossbuild.yml create mode 100644 Cross.toml diff --git a/.github/workflows/publish-crossbuild.yml b/.github/workflows/publish-crossbuild.yml new file mode 100644 index 000000000..09dba44a7 --- /dev/null +++ b/.github/workflows/publish-crossbuild.yml @@ -0,0 +1,111 @@ +name: Release using cross build + +on: + release: + types: [published] + +env: + CARGO_TERM_COLOR: always + +jobs: + publish-to-github: + name: Publish to Github + runs-on: ${{ matrix.os }} + continue-on-error: false + strategy: + fail-fast: false + matrix: + include: + - build: aarch64 + os: ubuntu-18.04 + target: aarch64-unknown-linux-gnu + linker: gcc-aarch64-linux-gnu + use-cross: true + asset_name: meilisearch-linux-aarch64 + - build: aarch64 + os: ubuntu-latest + target: aarch64-unknown-linux-musl + linker: gcc-aarch64-linux-gnu + use-cross: true + asset_name: meilisearch-linux-aarch64-musl + - build: linux + os: ubuntu-latest + target: x86_64-unknown-linux-musl + use-cross: true + asset_name: meilisearch-linux-amd64-musl + steps: + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Installing Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + target: ${{ matrix.target }} + override: true + + - name: APT update + run: | + sudo apt update + + - name: Install target specific tools + if: matrix.use-cross + run: | + sudo apt-get install -y ${{ matrix.linker }} + + - name: Configure target aarch64 GNU + if: matrix.target == 'aarch64-unknown-linux-gnu' + # LD gold won't work with MUSL + env: + JEMALLOC_SYS_WITH_LG_PAGE: 16 + RUSTFLAGS: '-Clink-arg=-fuse-ld=gold' + run: | + echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config + echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config + + - name: Configure target aarch64 MUSL + if: matrix.target == 'aarch64-unknown-linux-musl' + env: + JEMALLOC_SYS_WITH_LG_PAGE: 16 + run: | + sudo apt-get install -y musl-tools + + - name: Configure target x86_64 MUSL + if: matrix.target == 'x86_64-unknown-linux-musl' + run: | + sudo apt-get install -y musl-tools + + - name: Cargo build + uses: actions-rs/cargo@v1 + with: + command: build + use-cross: ${{ matrix.use-cross }} + args: --release --target ${{ matrix.target }} + + # Strip debuginfo for target aarch64 GNU + # MUSL binary are static linked + - name: Strip debuginfo for target aarch64 GNU + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + /usr/bin/aarch64-linux-gnu-strip --strip-debug --target=elf64-littleaarch64 target/${{ matrix.target }}/release/meilisearch -o target/${{ matrix.target }}/release/meilisearch-stripped + + - name: List target output files + run: ls -lR ./target + + - name: Upload the binary to release + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.PUBLISH_TOKEN }} + file: target/${{ matrix.target }}/release/meilisearch + asset_name: ${{ matrix.asset_name }} + tag: ${{ github.ref }} + - name: Upload stripped binary to release (aarch64 GNU only) + if: matrix.target == 'aarch64-unknown-linux-gnu' + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.PUBLISH_TOKEN }} + file: target/${{ matrix.target }}/release/meilisearch-stripped + asset_name: ${{ matrix.asset_name }}-stripped + tag: ${{ github.ref }} diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 000000000..cd4309d8a --- /dev/null +++ b/Cross.toml @@ -0,0 +1,7 @@ +[build.env] +passthrough = [ + "RUST_BACKTRACE", + "CARGO_TERM_COLOR", + "RUSTFLAGS", + "JEMALLOC_SYS_WITH_LG_PAGE" +] From 87115b02d92bb00f0f02506800a22658d6ef0e55 Mon Sep 17 00:00:00 2001 From: Patrick Dung <38665827+patrickdung@users.noreply.github.com> Date: Sun, 10 Oct 2021 03:27:51 +0800 Subject: [PATCH 2/7] Fixing the passing of environment variables --- .github/workflows/publish-crossbuild.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-crossbuild.yml b/.github/workflows/publish-crossbuild.yml index 09dba44a7..a7f5141be 100644 --- a/.github/workflows/publish-crossbuild.yml +++ b/.github/workflows/publish-crossbuild.yml @@ -57,20 +57,24 @@ jobs: - name: Configure target aarch64 GNU if: matrix.target == 'aarch64-unknown-linux-gnu' - # LD gold won't work with MUSL - env: - JEMALLOC_SYS_WITH_LG_PAGE: 16 - RUSTFLAGS: '-Clink-arg=-fuse-ld=gold' + ## Environment variable is not passed using env: + ## LD gold won't work with MUSL + # env: + # JEMALLOC_SYS_WITH_LG_PAGE: 16 + # RUSTFLAGS: '-Clink-arg=-fuse-ld=gold' run: | echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config + echo 'JEMALLOC_SYS_WITH_LG_PAGE=16' >> $GITHUB_ENV + echo RUSTFLAGS="-Clink-arg=-fuse-ld=gold" >> $GITHUB_ENV - name: Configure target aarch64 MUSL if: matrix.target == 'aarch64-unknown-linux-musl' - env: - JEMALLOC_SYS_WITH_LG_PAGE: 16 + # env: + # JEMALLOC_SYS_WITH_LG_PAGE: 16 run: | sudo apt-get install -y musl-tools + echo 'JEMALLOC_SYS_WITH_LG_PAGE=16' >> $GITHUB_ENV - name: Configure target x86_64 MUSL if: matrix.target == 'x86_64-unknown-linux-musl' From ef7e7a8f11f348548646c076afb0447151fbc4a2 Mon Sep 17 00:00:00 2001 From: Patrick Dung <38665827+patrickdung@users.noreply.github.com> Date: Thu, 21 Oct 2021 00:40:46 +0800 Subject: [PATCH 3/7] Only generate aarch64 binary with action-rs --- .github/workflows/publish-crossbuild.yml | 39 ------------------------ 1 file changed, 39 deletions(-) diff --git a/.github/workflows/publish-crossbuild.yml b/.github/workflows/publish-crossbuild.yml index a7f5141be..01381a8ca 100644 --- a/.github/workflows/publish-crossbuild.yml +++ b/.github/workflows/publish-crossbuild.yml @@ -22,17 +22,6 @@ jobs: linker: gcc-aarch64-linux-gnu use-cross: true asset_name: meilisearch-linux-aarch64 - - build: aarch64 - os: ubuntu-latest - target: aarch64-unknown-linux-musl - linker: gcc-aarch64-linux-gnu - use-cross: true - asset_name: meilisearch-linux-aarch64-musl - - build: linux - os: ubuntu-latest - target: x86_64-unknown-linux-musl - use-cross: true - asset_name: meilisearch-linux-amd64-musl steps: - name: Checkout repository @@ -68,19 +57,6 @@ jobs: echo 'JEMALLOC_SYS_WITH_LG_PAGE=16' >> $GITHUB_ENV echo RUSTFLAGS="-Clink-arg=-fuse-ld=gold" >> $GITHUB_ENV - - name: Configure target aarch64 MUSL - if: matrix.target == 'aarch64-unknown-linux-musl' - # env: - # JEMALLOC_SYS_WITH_LG_PAGE: 16 - run: | - sudo apt-get install -y musl-tools - echo 'JEMALLOC_SYS_WITH_LG_PAGE=16' >> $GITHUB_ENV - - - name: Configure target x86_64 MUSL - if: matrix.target == 'x86_64-unknown-linux-musl' - run: | - sudo apt-get install -y musl-tools - - name: Cargo build uses: actions-rs/cargo@v1 with: @@ -88,13 +64,6 @@ jobs: use-cross: ${{ matrix.use-cross }} args: --release --target ${{ matrix.target }} - # Strip debuginfo for target aarch64 GNU - # MUSL binary are static linked - - name: Strip debuginfo for target aarch64 GNU - if: matrix.target == 'aarch64-unknown-linux-gnu' - run: | - /usr/bin/aarch64-linux-gnu-strip --strip-debug --target=elf64-littleaarch64 target/${{ matrix.target }}/release/meilisearch -o target/${{ matrix.target }}/release/meilisearch-stripped - - name: List target output files run: ls -lR ./target @@ -105,11 +74,3 @@ jobs: file: target/${{ matrix.target }}/release/meilisearch asset_name: ${{ matrix.asset_name }} tag: ${{ github.ref }} - - name: Upload stripped binary to release (aarch64 GNU only) - if: matrix.target == 'aarch64-unknown-linux-gnu' - uses: svenstaro/upload-release-action@v1-release - with: - repo_token: ${{ secrets.PUBLISH_TOKEN }} - file: target/${{ matrix.target }}/release/meilisearch-stripped - asset_name: ${{ matrix.asset_name }}-stripped - tag: ${{ github.ref }} From 5585020753b7ce24a33a1ed89c275681a45c6c80 Mon Sep 17 00:00:00 2001 From: Patrick Dung <38665827+patrickdung@users.noreply.github.com> Date: Thu, 21 Oct 2021 17:02:00 +0000 Subject: [PATCH 4/7] Update .github/workflows/publish-crossbuild.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit better spacing Co-authored-by: Clémentine Urquizar --- .github/workflows/publish-crossbuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-crossbuild.yml b/.github/workflows/publish-crossbuild.yml index 01381a8ca..830f70a83 100644 --- a/.github/workflows/publish-crossbuild.yml +++ b/.github/workflows/publish-crossbuild.yml @@ -22,8 +22,8 @@ jobs: linker: gcc-aarch64-linux-gnu use-cross: true asset_name: meilisearch-linux-aarch64 - steps: + steps: - name: Checkout repository uses: actions/checkout@v2 From 19eebc0b0a47c2a25bbd98c1a8615d756fb74dd2 Mon Sep 17 00:00:00 2001 From: Patrick Dung <38665827+patrickdung@users.noreply.github.com> Date: Thu, 21 Oct 2021 17:02:16 +0000 Subject: [PATCH 5/7] Update .github/workflows/publish-crossbuild.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit better naming Co-authored-by: Clémentine Urquizar --- .github/workflows/publish-crossbuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-crossbuild.yml b/.github/workflows/publish-crossbuild.yml index 830f70a83..dabe9d153 100644 --- a/.github/workflows/publish-crossbuild.yml +++ b/.github/workflows/publish-crossbuild.yml @@ -8,7 +8,7 @@ env: CARGO_TERM_COLOR: always jobs: - publish-to-github: + publish-aarch64: name: Publish to Github runs-on: ${{ matrix.os }} continue-on-error: false From d519e1036f6792fc49dfc6877755d718c66c4769 Mon Sep 17 00:00:00 2001 From: Patrick Dung <38665827+patrickdung@users.noreply.github.com> Date: Thu, 21 Oct 2021 17:02:28 +0000 Subject: [PATCH 6/7] Update .github/workflows/publish-crossbuild.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit better naming Co-authored-by: Clémentine Urquizar --- .github/workflows/publish-crossbuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-crossbuild.yml b/.github/workflows/publish-crossbuild.yml index dabe9d153..26691e2d8 100644 --- a/.github/workflows/publish-crossbuild.yml +++ b/.github/workflows/publish-crossbuild.yml @@ -1,4 +1,4 @@ -name: Release using cross build +Publish aarch64 binary on: release: From 5caa79df6725ccfc74f0ba69834e7656f9396110 Mon Sep 17 00:00:00 2001 From: Patrick Dung <38665827+patrickdung@users.noreply.github.com> Date: Sun, 24 Oct 2021 11:31:04 +0000 Subject: [PATCH 7/7] Update .github/workflows/publish-crossbuild.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update to use the correct syntax Co-authored-by: Clémentine Urquizar --- .github/workflows/publish-crossbuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-crossbuild.yml b/.github/workflows/publish-crossbuild.yml index 26691e2d8..4e1e7a9c8 100644 --- a/.github/workflows/publish-crossbuild.yml +++ b/.github/workflows/publish-crossbuild.yml @@ -1,4 +1,4 @@ -Publish aarch64 binary +name: Publish aarch64 binary on: release: