From 1d3725d5e86a800827085c9f07b1371ee1b6a968 Mon Sep 17 00:00:00 2001 From: Sayan Nandan Date: Mon, 27 Jul 2020 13:14:42 +0530 Subject: [PATCH] Add cross-platform builds --- .github/workflows/release.yml | 192 ++++++++++++++++++++++++++++++++++ .github/workflows/rust.yml | 22 ---- .github/workflows/test.yml | 64 ++++++++++++ README.md | 8 +- 4 files changed, 262 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/rust.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..8e145fe0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,192 @@ +on: + push: + tags: + - "v*" + +name: Release + +env: + RELEASE_TDB: tdb + RELEASE_TSH: tsh + RELEASE_DIR: artifacts + GITHUB_REF: "${{ github.ref }}" + WINDOWS_TARGET: x86_64-pc-windows-msvc + MACOS_TARGET: x86_64-apple-darwin + LINUX_TARGET: x86_64-unknown-linux-gnu + +jobs: + build: + name: Build artifacts + runs-on: ${{ matrix.os }} + strategy: + matrix: + build: [linux, macos, windows] + include: + - build: linux + os: ubuntu-latest + rust: stable + - build: macos + os: macos-latest + rust: stable + - build: windows + os: windows-latest + rust: stable + + steps: + - uses: actions/checkout@v2 + + - name: Cache Cargo registry + uses: actions/cache@v1 + if: matrix.rust + with: + path: ~/.cargo/registry + key: ${{ matrix.build }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ matrix.build }}-cargo-registry- + + - name: Cache Cargo index + uses: actions/cache@v1 + if: matrix.rust + with: + path: ~/.cargo/git + key: ${{ matrix.build }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ matrix.build }}-cargo-index- + + - name: Cache Cargo build + uses: actions/cache@v1 + if: matrix.rust + with: + path: target + key: ${{ matrix.build }}-target-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ matrix.build }}-target- + + - name: Query version number + id: get_version + shell: bash + run: | + echo "using version tag ${GITHUB_REF:10}" + echo ::set-output name=version::"${GITHUB_REF:10}" + + - name: Install Rust + if: matrix.rust + run: | + rustup update ${{ matrix.rust }} --no-self-update + rustup default ${{ matrix.rust }} + + - name: Build (Linux) + if: matrix.build == 'linux' + run: | + rustup target add ${{ env.LINUX_TARGET }} + cargo build --release --target ${{ env.LINUX_TARGET }} + + - name: Build (MacOS) + if: matrix.build == 'macos' + run: cargo build --release + + - name: Build (Windows) + if: matrix.build == 'windows' + run: cargo build --release + env: + RUSTFLAGS: -Ctarget-feature=+crt-static + + - name: Create artifact directory + run: | + mkdir ${{ env.RELEASE_DIR }} + mkdir dist + + - name: Create Build (Linux) + if: matrix.build == 'linux' + run: | + mv ./target/${{ env.LINUX_TARGET }}/release/${{ env.RELEASE_TDB }} ./dist + mv ./target/${{ env.LINUX_TARGET }}/release/${{ env.RELEASE_TSH }} ./dist + zip ./${{ env.RELEASE_DIR}}/tdb-bundle-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.zip ./dist/tsh ./dist/tdb -j + + - name: Create Build (Windows) + if: matrix.build == 'windows' + shell: bash + run: | + mv ./target/release/${{ env.RELEASE_TDB }}.exe ./dist + mv ./target/release/${{ env.RELEASE_TSH }}.exe ./dist + 7z a -tzip ./${{ env.RELEASE_DIR }}/tdb-bundle-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.zip ./dist/* + + - name: Create Build (MacOS) + if: matrix.build == 'macos' + run: | + mv ./target/release/${{ env.RELEASE_TDB }} ./dist + mv ./target/release/${{ env.RELEASE_TSH }} ./dist + zip ./${{ env.RELEASE_DIR }}/tdb-bundle-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.zip ./dist/tsh ./dist/tdb -j + + - name: Upload binaries + uses: actions/upload-artifact@v1 + with: + name: ${{ matrix.build }} + path: ./${{ env.RELEASE_DIR }} + + release: + name: GitHub Release + needs: build + runs-on: ubuntu-latest + steps: + - name: Query version number + id: get_version + shell: bash + run: | + echo "using version tag ${GITHUB_REF:10}" + echo ::set-output name=version::"${GITHUB_REF:10}" + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get_version.outputs.VERSION }} + release_name: ${{ steps.get_version.outputs.VERSION }} + prerelease: true + + - name: Download Linux bundle + uses: actions/download-artifact@v1 + with: + name: linux + + - name: Download Windows bundle + uses: actions/download-artifact@v1 + with: + name: windows + + - name: Download MacOS bundle + uses: actions/download-artifact@v1 + with: + name: macos + + - name: Release Linux bundle + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./linux/tdb-bundle-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.zip + asset_content_type: application/octet-stream + asset_name: tdb-bundle-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.zip + + - name: Release Windows bundle + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./windows/tdb-bundle-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.zip + asset_content_type: application/octet-stream + asset_name: tdb-bundle-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.zip + + - name: Release MacOS bundle + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./macos/tdb-bundle-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.zip + asset_content_type: application/octet-stream + asset_name: tdb-bundle-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.zip \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index d1b7604e..00000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Rust - -on: - push: - branches: [ '*' ] - pull_request: - branches: [ '*' ] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..2a295a7c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,64 @@ +name: Tests + +on: [pull_request, push] + +jobs: + test: + name: Test + + runs-on: ${{ matrix.os }} + strategy: + matrix: + build: + [ + linux-stable, + macos-stable, + windows-stable, + ] + include: + - build: linux-stable + os: ubuntu-latest + rust: stable + - build: macos-stable + os: macos-latest + rust: stable + - build: windows-stable + os: windows-latest + rust: stable + + steps: + - uses: actions/checkout@v2 + + - name: Cache Cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ matrix.build }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ matrix.build }}-cargo-registry- + + - name: Cache Cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ matrix.build }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ matrix.build }}-cargo-index- + + - name: Cache Cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ matrix.build }}-target-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ matrix.build }}-target- + + - name: Install Rust + run: | + rustup update ${{ matrix.rust }} --no-self-update + rustup default ${{ matrix.rust }} + + - name: Run Tests + run: cargo test --verbose + env: + RUST_BACKTRACE: 1 \ No newline at end of file diff --git a/README.md b/README.md index 9882a9e3..e4d55a4b 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,15 @@ TerrabaseDB (or TDB for short) is an effort to provide the best of key/value sto As noted earlier, TerrabaseDB is pre-alpha software and the entire API is subject to major breaking changes, at the moment. +## Platforms +![Linux supported](https://img.shields.io/badge/Linux%20x86__64-supported%20✓-228B22?style=flat-square&logo=linux) ![macOS supported](https://img.shields.io/badge/macOS%20x86__64-supported%20✓-228B22?style=flat-square&logo=apple) ![Windows supported](https://img.shields.io/badge/Windows%20x86__64-supported%20✓-228B22?style=flat-square&logo=windows) + ## Getting started -We have an experimental client and server implementation for the database already. You can download a pre-built binary for `x86_64-linux` in the releases section and try it out! +We have experimnetal client and server implementations for the database already. +The releases are uploaded in bundles, for example, `tdb-bundle-v0.2.0-x86_64-unknown-linux-gnu.zip`. Each bundle contains `tdb` and `tsh`, that is, the database server and the client command-line tool. -* Download the files `tdb-x86_64*` and `tsh-x86_64*` +* Download a bundle for your platform from [releases](https://github.com/terrabasedb/terrabase/releases) * Rename the files to tdb and tsh for ease * Run `chmod +x tdb tsh` * Start the database server by running `./tdb`