Skip to content

Commit f8dfb2b

Browse files
authored
Attach binary to crate (#20)
* Consolidate workflow scripts and streamline CI/CD setup * Add 'feature/bundle-bin' branch to CD workflow trigger * Add version bump workflow; refactor and simplify CD workflow * Update Git setup with custom user config in workflow * Update 'bump.yml' to include '--build' in cargo bump command * Remove duplicate cargo bump patch command * Remove unnecessary permissions in workflows * 0.2.7 * Expand deployment events in CD workflow * Add TMPDIR to .cargo/config.toml, update Cargo.lock version * Fix TMPDIR value by adding missing quotes * 0.2.8 * Remove redundant event trigger wildcard in CD workflow * Update git-ai to version 0.2.8 and GH release action to v2 * 0.2.9 * Add concurrency setting to GitHub Actions CD workflow * Update git-ai version to 0.2.9 in Cargo.lock * 0.2.10 * Amend bump commit to include additional changes * 0.2.11 * Update bump.yml workflow file * Enable workflow on all branches and update tag_name variable * Update git-ai to version 0.2.11 and remove version extraction step * Fix incorrect file paths in CD workflow configuration * 0.2.12 * Refactor artifacts generation in CD workflow * Upgrade git-ai to version 0.2.12 and fix tag_name usage in cd.yml * 0.2.13 * Fix variable reference in GitHub Actions workflow * Remove unused draft and prerelease settings * Update git-ai version and add stash step in workflow * 0.2.14 * Update workflows to trigger on 'main' and add concurrency settings --------- Co-authored-by: Linus Oleander <[email protected]>
1 parent a6f1faa commit f8dfb2b

File tree

9 files changed

+193
-201
lines changed

9 files changed

+193
-201
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[env]
2+
3+
TMPDIR = "/tmp"

.github/workflows/bump.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bump Version
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
bump:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Setup Git
25+
run: |
26+
git config user.name "Linus Oleander"
27+
git config user.email "[email protected]"
28+
29+
- name: Install cargo-bump
30+
run: cargo install cargo-bump --force
31+
32+
- name: Bump version
33+
run: |
34+
git stash || echo "No changes to stash"
35+
cargo bump patch --git-tag
36+
git commit -a --amend --no-edit
37+
38+
- name: Push to GitHub
39+
run: git push origin HEAD --tags

.github/workflows/cd.yml

Lines changed: 55 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,79 @@
11
name: CD
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened]
4+
push:
5+
tags:
6+
- "**"
7+
branches:
8+
- "main"
69

710
concurrency:
811
group: ${{ github.workflow }}-${{ github.ref }}
912
cancel-in-progress: true
1013

14+
permissions:
15+
contents: write
16+
1117
env:
1218
CARGO_TERM_COLOR: always
1319

1420
jobs:
15-
lint:
21+
build-x86:
1622
runs-on: ubuntu-latest
1723
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2025

21-
- name: Setup nightly toolchain
22-
uses: actions-rs/toolchain@v1
23-
with:
24-
components: rustfmt, clippy
25-
toolchain: nightly
26+
- name: Add target
27+
run: rustup target add x86_64-unknown-linux-gnu
2628

27-
- uses: actions/cache@v3
28-
with:
29-
path: |
30-
~/.cargo/bin/
31-
~/.cargo/registry/index/
32-
~/.cargo/registry/cache/
33-
~/.cargo/git/db/
34-
target/
35-
key: ${{ runner.os }}-nightly-${{ hashFiles('**/Cargo.lock') }}
36-
37-
- name: Run clippy
38-
uses: actions-rs/cargo@v1
39-
with:
40-
command: clippy
41-
args: -- -D warnings
29+
- name: Build for x86_64-unknown-linux-gnu
30+
run: cargo build --release --target x86_64-unknown-linux-gnu
4231

43-
- name: Run cargo fmt
44-
uses: actions-rs/cargo@v1
32+
- name: Package Binary
33+
run: tar czf target/*/release/git-ai-*.tar.gz git-*
34+
35+
- name: Upload Binary
36+
uses: actions/upload-artifact@v4
4537
with:
46-
command: fmt
47-
args: -- --check
48-
test:
49-
needs: lint
50-
strategy:
51-
fail-fast: true
52-
matrix:
53-
os: [macos-latest, ubuntu-latest]
54-
rust: [nightly, stable]
55-
runs-on: ${{ matrix.os }}
56-
continue-on-error: false
38+
name: git-ai-x86_64-unknown-linux-gnu.tar.gz
39+
path: git-ai-*.tar.gz
40+
41+
build-arm:
42+
runs-on: macos-latest
5743
steps:
58-
- name: Checkout code
59-
uses: actions/checkout@v4
44+
- uses: actions/checkout@v4
45+
46+
- name: Add target
47+
run: rustup target add aarch64-apple-darwin
6048

61-
- name: Set up Rust
62-
uses: actions-rs/toolchain@v1
49+
- name: Build for aarch64-apple-darwin
50+
run: cargo build --release --target aarch64-apple-darwin
51+
52+
- name: Package Binary
53+
run: tar czf target/*/release/git-ai-*.tar.gz git-*
54+
55+
- name: Upload Binary
56+
uses: actions/upload-artifact@v4
6357
with:
64-
toolchain: ${{ matrix.rust }}
65-
override: true
66-
profile: minimal
58+
name: git-ai-aarch64-apple-darwin.tar.gz
59+
path: git-ai-*.tar.gz
6760

68-
- uses: actions/cache@v4
61+
release:
62+
needs: [build-x86, build-arm]
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
67+
- name: Download all artifacts
68+
uses: actions/download-artifact@v4
69+
70+
- name: Create Release
71+
uses: softprops/action-gh-release@v2
6972
with:
70-
path: |
71-
~/.cargo/bin/
72-
~/.cargo/registry/index/
73-
~/.cargo/registry/cache/
74-
~/.cargo/git/db/
75-
target/
76-
key: ${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
77-
restore-keys: ${{ runner.os }}-${{ matrix.rust }}-
78-
79-
- name: Install fish on linux
80-
if: startsWith(matrix.os, 'ubuntu')
81-
run: sudo apt-get install fish
82-
83-
- name: Install fish on macos
84-
if: startsWith(matrix.os, 'macos')
85-
run: brew install fish
86-
87-
- name: Run integration tests
88-
run: |
89-
./scripts/integration-tests
90-
cargo build --release
91-
cargo test --release
73+
files: git-ai-*.tar.gz
74+
tag_name: ${{ github.ref_name }}
75+
76+
- name: Publish to crates.io
77+
run: cargo publish
9278
env:
93-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
79+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/ci.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
lint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Setup nightly toolchain
22+
uses: actions-rs/toolchain@v1
23+
with:
24+
components: rustfmt, clippy
25+
toolchain: nightly
26+
27+
- uses: actions/cache@v3
28+
with:
29+
path: |
30+
~/.cargo/bin/
31+
~/.cargo/registry/index/
32+
~/.cargo/registry/cache/
33+
~/.cargo/git/db/
34+
target/
35+
key: ${{ runner.os }}-nightly-${{ hashFiles('**/Cargo.lock') }}
36+
37+
- name: Run clippy
38+
uses: actions-rs/cargo@v1
39+
with:
40+
command: clippy
41+
args: -- -D warnings
42+
43+
- name: Run cargo fmt
44+
uses: actions-rs/cargo@v1
45+
with:
46+
command: fmt
47+
args: -- --check
48+
test:
49+
needs: lint
50+
strategy:
51+
fail-fast: true
52+
matrix:
53+
os: [macos-latest, ubuntu-latest]
54+
rust: [nightly, stable]
55+
runs-on: ${{ matrix.os }}
56+
continue-on-error: false
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Set up Rust
62+
uses: actions-rs/toolchain@v1
63+
with:
64+
toolchain: ${{ matrix.rust }}
65+
override: true
66+
profile: minimal
67+
68+
- uses: actions/cache@v4
69+
with:
70+
path: |
71+
~/.cargo/bin/
72+
~/.cargo/registry/index/
73+
~/.cargo/registry/cache/
74+
~/.cargo/git/db/
75+
target/
76+
key: ${{ runner.os }}-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
77+
restore-keys: ${{ runner.os }}-${{ matrix.rust }}-
78+
79+
- name: Install fish on linux
80+
if: startsWith(matrix.os, 'ubuntu')
81+
run: sudo apt-get install fish
82+
83+
- name: Install fish on macos
84+
if: startsWith(matrix.os, 'macos')
85+
run: brew install fish
86+
87+
- name: Run integration tests
88+
run: |
89+
./scripts/integration-tests
90+
cargo build --release
91+
cargo test --release
92+
env:
93+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

.github/workflows/crate.yaml

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)