From c71c95feb0942abd07fb5d5893125dae80f7aabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Wed, 2 Feb 2022 19:25:28 +0100 Subject: [PATCH 1/7] Refactor CIs to publish aaarch64 binary --- .github/workflows/publish-binaries.yml | 77 ++++++++++++++++++------ .github/workflows/publish-crossbuild.yml | 76 ----------------------- 2 files changed, 59 insertions(+), 94 deletions(-) delete mode 100644 .github/workflows/publish-crossbuild.yml diff --git a/.github/workflows/publish-binaries.yml b/.github/workflows/publish-binaries.yml index c7744e35e..9893b79a8 100644 --- a/.github/workflows/publish-binaries.yml +++ b/.github/workflows/publish-binaries.yml @@ -38,28 +38,69 @@ jobs: asset_name: ${{ matrix.asset_name }} tag: ${{ github.ref }} - publish-armv8: - name: Publish for ARMv8 - runs-on: ubuntu-18.04 + publish-aarch64: + 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 + steps: - - uses: actions/checkout@v2 - - uses: uraimo/run-on-arch-action@v2.1.1 - id: runcmd + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Installing Rust toolchain + uses: actions-rs/toolchain@v1 with: - arch: aarch64 # aka ARMv8 - distro: ubuntu18.04 - env: | - JEMALLOC_SYS_WITH_LG_PAGE: 16 - run: | - apt update - apt install -y curl gcc make - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable - source $HOME/.cargo/env - cargo build --release --locked + 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' + ## 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: Cargo build + uses: actions-rs/cargo@v1 + with: + command: build + use-cross: ${{ matrix.use-cross }} + args: --release --target ${{ matrix.target }} + + - 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/release/meilisearch - asset_name: meilisearch-linux-armv8 + file: target/${{ matrix.target }}/release/meilisearch + asset_name: ${{ matrix.asset_name }} tag: ${{ github.ref }} diff --git a/.github/workflows/publish-crossbuild.yml b/.github/workflows/publish-crossbuild.yml deleted file mode 100644 index 4e1e7a9c8..000000000 --- a/.github/workflows/publish-crossbuild.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Publish aarch64 binary - -on: - release: - types: [published] - -env: - CARGO_TERM_COLOR: always - -jobs: - publish-aarch64: - 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 - - 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' - ## 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: Cargo build - uses: actions-rs/cargo@v1 - with: - command: build - use-cross: ${{ matrix.use-cross }} - args: --release --target ${{ matrix.target }} - - - 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 }} From 1da72778176a07488b1efcb8c386655a05e8d7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Wed, 2 Feb 2022 19:25:52 +0100 Subject: [PATCH 2/7] Fix dowload-latest.sh according to the new name of the binary --- download-latest.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/download-latest.sh b/download-latest.sh index 4e88c1828..be0ff15e1 100644 --- a/download-latest.sh +++ b/download-latest.sh @@ -148,11 +148,18 @@ get_os() { get_archi() { architecture=$(uname -m) case "$architecture" in - 'x86_64' | 'amd64' | 'arm64') + 'x86_64' | 'amd64' ) archi='amd64' ;; + 'arm64') + if [ $os -eq 'macos' ]; then # MacOS M1 + archi='amd64' + else + archi='aarch64' + fi + ;; 'aarch64') - archi='armv8' + archi='aarch64' ;; *) return 1 From 78cf8f1f9f29c684db0359a7a66c61837ee2842e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Wed, 2 Feb 2022 19:29:07 +0100 Subject: [PATCH 3/7] Fix typo --- .github/is-latest-release.sh | 2 +- .github/workflows/publish-binaries.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/is-latest-release.sh b/.github/is-latest-release.sh index 77e3ad9a0..0c1db61c2 100644 --- a/.github/is-latest-release.sh +++ b/.github/is-latest-release.sh @@ -74,7 +74,7 @@ semverLT() { # Returns the tag of the latest stable release (in terms of semver and not of release date) get_latest() { temp_file='temp_file' # temp_file needed because the grep would start before the download is over - curl -s 'https://api.github.com/repos/meilisearch/meiliSearch/releases' > "$temp_file" + curl -s 'https://api.github.com/repos/meilisearch/meilisearch/releases' > "$temp_file" releases=$(cat "$temp_file" | \ grep -E "tag_name|draft|prerelease" \ | tr -d ',"' | cut -d ':' -f2 | tr -d ' ') diff --git a/.github/workflows/publish-binaries.yml b/.github/workflows/publish-binaries.yml index 9893b79a8..64af0e2c0 100644 --- a/.github/workflows/publish-binaries.yml +++ b/.github/workflows/publish-binaries.yml @@ -39,7 +39,7 @@ jobs: tag: ${{ github.ref }} publish-aarch64: - name: Publish to Github + name: Publish to GitHub runs-on: ${{ matrix.os }} continue-on-error: false strategy: From f7e4a0177d34da3a61c80af131f7420490d96535 Mon Sep 17 00:00:00 2001 From: meili-bot <74670311+meili-bot@users.noreply.github.com> Date: Mon, 7 Feb 2022 13:53:30 +0100 Subject: [PATCH 4/7] Update download-latest.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Renault --- download-latest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download-latest.sh b/download-latest.sh index be0ff15e1..943b29143 100644 --- a/download-latest.sh +++ b/download-latest.sh @@ -152,7 +152,7 @@ get_archi() { archi='amd64' ;; 'arm64') - if [ $os -eq 'macos' ]; then # MacOS M1 + if [ $os = 'macos' ]; then # MacOS M1 archi='amd64' else archi='aarch64' From c4a2d70d19d48e95eae4c4fbc78c796f393e5abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Mon, 7 Feb 2022 16:00:50 +0100 Subject: [PATCH 5/7] Fix error handler for curl command in script --- download-latest.sh | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/download-latest.sh b/download-latest.sh index 943b29143..4288fae53 100644 --- a/download-latest.sh +++ b/download-latest.sh @@ -73,7 +73,7 @@ semverLT() { get_latest() { temp_file='temp_file' # temp_file needed because the grep would start before the download is over - if [ -z "$GITHUB_PAT" ]; then + if [ -z "$GITHUB_PAT" ]; then curl -s 'https://api.github.com/repos/meilisearch/meilisearch/releases' > "$temp_file" || return 1 else curl -H "Authorization: token $GITHUB_PAT" -s 'https://api.github.com/repos/meilisearch/meilisearch/releases' > "$temp_file" || return 1 @@ -120,7 +120,7 @@ get_latest() { done rm -f "$temp_file" - echo $latest + return 0 } # Gets the OS by setting the $os variable @@ -176,30 +176,41 @@ success_usage() { echo ' $ ./meilisearch --help' } -failure_usage() { +not_available_failure_usage() { printf "$RED%s\n$DEFAULT" 'ERROR: Meilisearch binary is not available for your OS distribution or your architecture yet.' echo '' echo 'However, you can easily compile the binary from the source files.' echo 'Follow the steps at the page ("Source" tab): https://docs.meilisearch.com/learn/getting_started/installation.html' } +fetch_release_failure_usage() { + echo '' + printf "$RED%s\n$DEFAULT" 'ERROR: Impossible to get the latest stable version of Meilisearch.' + echo 'Please let us know about this issue: https://github.com/meilisearch/meilisearch/issues/new/choose' +} + # MAIN -latest="$(get_latest)" + +# Fill $latest variable +if ! get_latest; then + fetch_release_failure_usage # TO CHANGE + exit 1 +fi if [ "$latest" = '' ]; then - echo '' - echo 'Impossible to get the latest stable version of Meilisearch.' - echo 'Please let us know about this issue: https://github.com/meilisearch/meilisearch/issues/new/choose' + fetch_release_failure_usage exit 1 fi +# Fill $os variable if ! get_os; then - failure_usage + not_available_failure_usage exit 1 fi +# Fill $archi variable if ! get_archi; then - failure_usage + not_available_failure_usage exit 1 fi @@ -207,16 +218,23 @@ echo "Downloading Meilisearch binary $latest for $os, architecture $archi..." case "$os" in 'windows') release_file="meilisearch-$os-$archi.exe" - binary_name='meilisearch.exe' + binary_name='meilisearch.exe' ;; - *) - release_file="meilisearch-$os-$archi" - binary_name='meilisearch' + *) + release_file="meilisearch-$os-$archi" + binary_name='meilisearch' esac + +# Fetch the Meilisearch binary link="https://github.com/meilisearch/meilisearch/releases/download/$latest/$release_file" curl -OL "$link" +if [ $? -ne 0 ] + fetch_release_failure_usage + exit 1 +fi + mv "$release_file" "$binary_name" chmod 744 "$binary_name" success_usage From 2a90e805a202b6733d22918ac6b4dabb1eb3f0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Mon, 7 Feb 2022 16:05:48 +0100 Subject: [PATCH 6/7] Fix script --- download-latest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download-latest.sh b/download-latest.sh index 4288fae53..e869bf53d 100644 --- a/download-latest.sh +++ b/download-latest.sh @@ -230,7 +230,7 @@ esac # Fetch the Meilisearch binary link="https://github.com/meilisearch/meilisearch/releases/download/$latest/$release_file" curl -OL "$link" -if [ $? -ne 0 ] +if [ $? -ne 0 ]; then fetch_release_failure_usage exit 1 fi From ccaca33446d46d0b0ef4c1f3566aace95c029499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Mon, 7 Feb 2022 16:16:49 +0100 Subject: [PATCH 7/7] Add --fail-with-body flag to curl in script --- download-latest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download-latest.sh b/download-latest.sh index e869bf53d..490039249 100644 --- a/download-latest.sh +++ b/download-latest.sh @@ -229,7 +229,7 @@ esac # Fetch the Meilisearch binary link="https://github.com/meilisearch/meilisearch/releases/download/$latest/$release_file" -curl -OL "$link" +curl --fail-with-body -OL "$link" if [ $? -ne 0 ]; then fetch_release_failure_usage exit 1