From 26b3428919f61afd20331ff98dcc70ed69d3e135 Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 16 Nov 2024 15:35:16 +0100 Subject: [PATCH] Add `rust-build` action to dependencies and update metadata in `Cargo.toml` * Add `rust-build` action to `[dependencies]` section with version `1.4.5` * Update metadata to follow the format specified in the cargo-binstall documentation Include `rust-build` action in GitHub Actions workflow * Include `rust-build` action in `build-x86` job for x86_64-unknown-linux-gnu target * Include `rust-build` action in `build-arm` job for aarch64-apple-darwin target * Ensure `rust-build` action is specified with the correct version `rust-build/rust-build.action@v1.4.5` * Ensure the names of the binary or the upload files follow the specified format --- .github/workflows/cd.yml | 52 ++++++++++++++++++++-------------------- Cargo.toml | 9 +++++++ 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ed197d0..d5f2fd9 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -24,20 +24,20 @@ jobs: - name: Add target run: rustup target add x86_64-unknown-linux-gnu - - name: Build for x86_64-unknown-linux-gnu - run: cargo build --release --target x86_64-unknown-linux-gnu - - - name: Package Binary - run: tar czf git-ai.tar.gz -C target/*/release git-ai git-ai-hook + - name: Compile + id: compile-x86 + uses: rust-build/rust-build.action@v1.4.5 + with: + RUSTTARGET: x86_64-unknown-linux-gnu + UPLOAD_MODE: none - - name: Upload Binary - uses: actions/upload-artifact@v4 + - name: Upload artifact + uses: actions/upload-artifact@v3 with: - name: git-ai-x86_64-unknown-linux-gnu.tar.gz - if-no-files-found: error - compression-level: 9 - overwrite: true - path: git-ai.tar.gz + name: Binary-x86 + path: | + ${{ steps.compile-x86.outputs.BUILT_ARCHIVE }} + ${{ steps.compile-x86.outputs.BUILT_CHECKSUM }} build-arm: runs-on: macos-latest @@ -47,20 +47,20 @@ jobs: - name: Add target run: rustup target add aarch64-apple-darwin - - name: Build for aarch64-apple-darwin - run: cargo build --release --target aarch64-apple-darwin - - - name: Package Binary - run: tar czf git-ai.tar.gz -C target/*/release git-ai git-ai-hook + - name: Compile + id: compile-arm + uses: rust-build/rust-build.action@v1.4.5 + with: + RUSTTARGET: aarch64-apple-darwin + UPLOAD_MODE: none - - name: Upload Binary - uses: actions/upload-artifact@v4 + - name: Upload artifact + uses: actions/upload-artifact@v3 with: - name: git-ai-aarch64-apple-darwin.tar.gz - if-no-files-found: error - overwrite: true - compression-level: 9 - path: git-ai.tar.gz + name: Binary-arm + path: | + ${{ steps.compile-arm.outputs.BUILT_ARCHIVE }} + ${{ steps.compile-arm.outputs.BUILT_CHECKSUM }} release: needs: [build-x86, build-arm] @@ -94,8 +94,8 @@ jobs: with: tag_name: "0.2.26" files: | - git-ai-x86_64-unknown-linux-gnu.tar.gz/git-ai.tar.gz - git-ai-aarch64-apple-darwin.tar.gz/git-ai.tar.gz + Binary-x86 + Binary-arm - name: Publish to crates.io run: cargo publish --allow-dirty diff --git a/Cargo.toml b/Cargo.toml index 05a29bb..ce2c486 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,7 @@ structopt = "0.3.26" thiserror = "1.0.61" tokio = { version = "1.38.0", features = ["rt-multi-thread"] } tiktoken-rs = { version = "0.5.9" } +rust-build = "0.1.0" [dev-dependencies] tempfile = "3.10.1" @@ -57,3 +58,11 @@ lto = true [profile.release.package."*"] codegen-units = 1 opt-level = 3 + +[package.metadata.binstall] +name = "git-ai" +default-target = "x86_64-unknown-linux-gnu" +targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin"] + +[dependencies] +rust-build = { version = "1.4.5" }