From 648e1a10700128dfc380e8a702cbab88482b66c8 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Wed, 26 Jun 2024 22:49:54 -0700 Subject: [PATCH] Add CI/CD Signed-off-by: Alex Saveau --- .github/FUNDING.yml | 1 + .github/workflows/cid.yml | 123 ++++++++++++++++++++++++++++++++++++++ rust-toolchain | 1 + 3 files changed, 125 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/cid.yml create mode 100644 rust-toolchain diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..94d6771 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: SUPERCILEX diff --git a/.github/workflows/cid.yml b/.github/workflows/cid.yml new file mode 100644 index 0000000..960150c --- /dev/null +++ b/.github/workflows/cid.yml @@ -0,0 +1,123 @@ +name: CI/CD + +on: [ push, pull_request ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cargo Cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + - name: Build project + run: cargo build --workspace --release + + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Rust + run: rustup component add rustfmt clippy + - name: Cargo Cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + - name: Run tests + run: cargo test --workspace + + deploy_release: + needs: [ build, test ] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Publish release + run: | + cargo publish --package clipboard-history-core + cargo publish --package clipboard-history-client-sdk + cargo publish --package clipboard-history-server + cargo publish --package clipboard-history + cargo publish --package clipboard-history-x11 + cargo publish --package clipboard-history-egui + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + attach_binaries: + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + tool: cargo + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + tool: cargo + - target: aarch64-unknown-linux-gnu + os: ubuntu-latest + tool: RUSTFLAGS="-Ctarget-feature=-outline-atomics" cross + - target: riscv64gc-unknown-linux-gnu + os: ubuntu-latest + tool: cross + needs: [ build, test ] + runs-on: ${{ matrix.os }} + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Rust + run: | + rustup target add ${{ matrix.target }} + rustup component add rust-src + - name: Install cross + if: contains(matrix.tool, 'cross') + run: cargo install cross + - name: Build binary + run: ${{ matrix.tool }} build --workspace --release --locked --target=${{ matrix.target }} -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort + - name: Upload binary + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/${{ matrix.target }}/release/ringboard-server + asset_name: ringboard-server-${{ matrix.target }} + tag: ${{ github.ref }} + - name: Upload binary + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/${{ matrix.target }}/release/ringboard + asset_name: ringboard-${{ matrix.target }} + tag: ${{ github.ref }} + - name: Upload binary + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/${{ matrix.target }}/release/ringboard-x11 + asset_name: ringboard-x11-${{ matrix.target }} + tag: ${{ github.ref }} + - name: Upload binary + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/${{ matrix.target }}/release/ringboard-egui + asset_name: ringboard-egui-${{ matrix.target }} + tag: ${{ github.ref }} diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..bf867e0 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly