diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..8d1e389 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[env] + +TMPDIR = "/tmp" diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml new file mode 100644 index 0000000..c24bd27 --- /dev/null +++ b/.github/workflows/bump.yml @@ -0,0 +1,39 @@ +name: Bump Version + +on: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + +jobs: + bump: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Git + run: | + git config user.name "Linus Oleander" + git config user.email "oleander@users.noreply.github.com" + + - name: Install cargo-bump + run: cargo install cargo-bump --force + + - name: Bump version + run: | + git stash || echo "No changes to stash" + cargo bump patch --git-tag + git commit -a --amend --no-edit + + - name: Push to GitHub + run: git push origin HEAD --tags diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index e97ce96..ccaa7b6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,93 +1,79 @@ name: CD on: - pull_request: - types: [opened, synchronize, reopened] + push: + tags: + - "**" + branches: + - "main" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +permissions: + contents: write + env: CARGO_TERM_COLOR: always jobs: - lint: + build-x86: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Setup nightly toolchain - uses: actions-rs/toolchain@v1 - with: - components: rustfmt, clippy - toolchain: nightly + - name: Add target + run: rustup target add x86_64-unknown-linux-gnu - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-nightly-${{ hashFiles('**/Cargo.lock') }} - - - name: Run clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings + - name: Build for x86_64-unknown-linux-gnu + run: cargo build --release --target x86_64-unknown-linux-gnu - - name: Run cargo fmt - uses: actions-rs/cargo@v1 + - name: Package Binary + run: tar czf target/*/release/git-ai-*.tar.gz git-* + + - name: Upload Binary + uses: actions/upload-artifact@v4 with: - command: fmt - args: -- --check - test: - needs: lint - strategy: - fail-fast: true - matrix: - os: [macos-latest, ubuntu-latest] - rust: [nightly, stable] - runs-on: ${{ matrix.os }} - continue-on-error: false + name: git-ai-x86_64-unknown-linux-gnu.tar.gz + path: git-ai-*.tar.gz + + build-arm: + runs-on: macos-latest steps: - - name: Checkout code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + + - name: Add target + run: rustup target add aarch64-apple-darwin - - name: Set up Rust - uses: actions-rs/toolchain@v1 + - name: Build for aarch64-apple-darwin + run: cargo build --release --target aarch64-apple-darwin + + - name: Package Binary + run: tar czf target/*/release/git-ai-*.tar.gz git-* + + - name: Upload Binary + uses: actions/upload-artifact@v4 with: - toolchain: ${{ matrix.rust }} - override: true - profile: minimal + name: git-ai-aarch64-apple-darwin.tar.gz + path: git-ai-*.tar.gz - - uses: actions/cache@v4 + release: + needs: [build-x86, build-arm] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + + - name: Create Release + uses: softprops/action-gh-release@v2 with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-${{ matrix.rust }}- - - - name: Install fish on linux - if: startsWith(matrix.os, 'ubuntu') - run: sudo apt-get install fish - - - name: Install fish on macos - if: startsWith(matrix.os, 'macos') - run: brew install fish - - - name: Run integration tests - run: | - ./scripts/integration-tests - cargo build --release - cargo test --release + files: git-ai-*.tar.gz + tag_name: ${{ github.ref_name }} + + - name: Publish to crates.io + run: cargo publish env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..944b5da --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,93 @@ +name: CI + +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup nightly toolchain + uses: actions-rs/toolchain@v1 + with: + components: rustfmt, clippy + toolchain: nightly + + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-nightly-${{ hashFiles('**/Cargo.lock') }} + + - name: Run clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: -- --check + test: + needs: lint + strategy: + fail-fast: true + matrix: + os: [macos-latest, ubuntu-latest] + rust: [nightly, stable] + runs-on: ${{ matrix.os }} + continue-on-error: false + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + profile: minimal + + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-${{ matrix.rust }}- + + - name: Install fish on linux + if: startsWith(matrix.os, 'ubuntu') + run: sudo apt-get install fish + + - name: Install fish on macos + if: startsWith(matrix.os, 'macos') + run: brew install fish + + - name: Run integration tests + run: | + ./scripts/integration-tests + cargo build --release + cargo test --release + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} diff --git a/.github/workflows/crate.yaml b/.github/workflows/crate.yaml deleted file mode 100644 index f7993ec..0000000 --- a/.github/workflows/crate.yaml +++ /dev/null @@ -1,65 +0,0 @@ -name: Crate - -on: - push: - branches: - - main - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - contents: write - -env: - CARGO_TERM_COLOR: always - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - components: rust-std - profile: minimal - - - name: Cache Cargo registry - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-crate-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-crate- - - - name: Setup environment - run: | - git config user.name "Linus Oleander" - git config user.email "oleander@users.noreply.github.com" - cargo install cargo-bump --force - - - name: Bump version - run: cargo bump patch --git-tag - - - name: Release to crates.io (dry-run) - if: github.ref != 'refs/heads/main' - run: cargo publish --dry-run - - - name: Release to crates.io - if: github.ref == 'refs/heads/main' - run: cargo publish - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - - name: Release to GitHub - if: github.ref == 'refs/heads/main' - run: git push origin HEAD --tags diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 3eee264..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Build and Precompile Binaries - -on: - push: - branches: - - main - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build-x86: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - components: rustfmt, clippy - - - name: Build for x86_64-unknown-linux-gnu - run: | - rustup target add x86_64-unknown-linux-gnu - cargo build --release --target x86_64-unknown-linux-gnu - - - name: Install cargo-binstall - run: cargo install cargo-binstall - - - name: Upload binaries - uses: actions/upload-artifact@v4 - with: - name: binaries-x86_64 - path: target/x86_64-unknown-linux-gnu/release/ - - build-arm: - runs-on: macos-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - components: rustfmt, clippy - - - name: Build for aarch64-apple-darwin - run: | - rustup target add aarch64-apple-darwin - cargo build --release --target aarch64-apple-darwin - - - name: Install cargo-binstall - run: cargo install cargo-binstall - - - name: Upload binaries - uses: actions/upload-artifact@v4 - with: - name: binaries-arm - path: target/aarch64-apple-darwin/release/ diff --git a/.gitignore b/.gitignore index 099c98c..8418c9f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ http-cacache/* .secrets .env.local +${env:TMPDIR} diff --git a/Cargo.lock b/Cargo.lock index 249ab08..8c24c4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -588,7 +588,7 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "git-ai" -version = "0.2.6" +version = "0.2.13" dependencies = [ "anyhow", "async-openai", diff --git a/Cargo.toml b/Cargo.toml index 7199cc3..603b163 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git-ai" -version = "0.2.6" +version = "0.2.14" edition = "2021" description = "Git AI: Automates commit messages using ChatGPT. Stage your files, and Git AI generates the messages." license = "MIT"