Skip to content

Commit 394bd55

Browse files
Merge pull request #1 from AaronSaikovski/develop
initial code drop
2 parents 360135e + e8d7217 commit 394bd55

File tree

7 files changed

+2530
-1
lines changed

7 files changed

+2530
-1
lines changed

.github/workflows/release.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
BIN_NAME: git-cmt-rs
13+
14+
jobs:
15+
build:
16+
name: Build and package (${{ matrix.os }} / ${{ runner.arch }})
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-latest, macos-latest, windows-latest]
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Rust toolchain (stable)
28+
uses: dtolnay/rust-toolchain@stable
29+
30+
- name: Cache cargo registry + build
31+
uses: actions/cache@v4
32+
with:
33+
path: |
34+
~/.cargo/registry
35+
~/.cargo/git
36+
target
37+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-cargo-
40+
41+
- name: Build (release)
42+
run: cargo build --release
43+
44+
- name: Prepare package
45+
shell: bash
46+
run: |
47+
set -eu
48+
VER="${GITHUB_REF_NAME}" # e.g., v1.2.3
49+
OS="${{ matrix.os }}"
50+
ARCH="${{ runner.arch }}" # X64, ARM64
51+
NAME="${{ env.BIN_NAME }}-${VER}-${OS}-${ARCH}"
52+
DIST="dist"
53+
mkdir -p "${DIST}"
54+
55+
# Resolve binary path/name
56+
BIN="target/release/${{ env.BIN_NAME }}"
57+
if [ "$OS" = "windows-latest" ]; then
58+
BIN="target/release/${{ env.BIN_NAME }}.exe"
59+
fi
60+
61+
# Create a staging dir with files we want to ship
62+
STAGE="${DIST}/${NAME}"
63+
mkdir -p "${STAGE}"
64+
cp "${BIN}" "${STAGE}/"
65+
[ -f LICENSE ] && cp LICENSE "${STAGE}/" || true
66+
[ -f README.md ] && cp README.md "${STAGE}/" || true
67+
68+
if [ "$OS" = "windows-latest" ]; then
69+
7z a "${DIST}/${NAME}.zip" "./${STAGE}/*"
70+
certutil -hashfile "${DIST}/${NAME}.zip" SHA256 | sed -n '2p' > "${DIST}/${NAME}.zip.sha256"
71+
else
72+
tar -C "${DIST}" -czf "${DIST}/${NAME}.tar.gz" "${NAME}"
73+
shasum -a 256 "${DIST}/${NAME}.tar.gz" | awk '{print $1}' > "${DIST}/${NAME}.tar.gz.sha256"
74+
fi
75+
76+
- name: Upload build artifacts
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: release-${{ matrix.os }}-${{ runner.arch }}
80+
path: dist/*
81+
if-no-files-found: error
82+
83+
release:
84+
name: Create GitHub Release
85+
runs-on: ubuntu-latest
86+
needs: [build]
87+
88+
steps:
89+
- name: Download all artifacts
90+
uses: actions/download-artifact@v4
91+
with:
92+
pattern: release-*
93+
merge-multiple: true
94+
95+
- name: List downloaded files
96+
run: ls -lah
97+
98+
- name: Create/Update GitHub Release
99+
uses: softprops/action-gh-release@v2
100+
with:
101+
tag_name: ${{ github.ref_name }}
102+
draft: false
103+
prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha') }}
104+
files: |
105+
*.tar.gz
106+
*.tar.gz.sha256
107+
*.zip
108+
*.zip.sha256
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rust-ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Rust CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build-test-lint:
14+
name: Build, Test, Lint (matrix)
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Rust toolchain (stable)
26+
uses: dtolnay/rust-toolchain@stable
27+
with:
28+
components: clippy, rustfmt
29+
30+
- name: Cache cargo registry + build
31+
uses: actions/cache@v4
32+
with:
33+
path: |
34+
~/.cargo/registry
35+
~/.cargo/git
36+
target
37+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-cargo-
40+
41+
- name: Show rustc/cargo versions
42+
run: |
43+
rustc -Vv
44+
cargo -V
45+
46+
- name: Format check
47+
run: cargo fmt --all -- --check
48+
49+
- name: Clippy (deny warnings)
50+
run: cargo clippy --all-targets --all-features -- -D warnings
51+
52+
- name: Build (release)
53+
run: cargo build --release
54+
55+
- name: Test
56+
env:
57+
# Ensure tests don't accidentally try to hit external APIs.
58+
# Add mocks in your tests; leave the key unset for CI.
59+
OPENAI_API_KEY: ""
60+
run: cargo test --all --locked --no-default-features
61+
62+
- name: Upload binary artifact
63+
if: runner.os == 'Linux' # change/remove this if you want artifacts for all OSes
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: git-cmt-rs-${{ github.sha }}-linux-amd64
67+
path: target/release/*
68+
if-no-files-found: warn
69+
70+
# Optional: security audit (cargo-audit) on Linux only
71+
audit:
72+
runs-on: ubuntu-latest
73+
permissions:
74+
contents: read
75+
steps:
76+
- uses: actions/checkout@v4
77+
- uses: dtolnay/rust-toolchain@stable
78+
- name: Install cargo-audit
79+
run: cargo install cargo-audit --locked
80+
- name: Run cargo audit
81+
run: cargo audit --deny warnings

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ target
1919
# and can be added to the global gitignore or merged into this file. For a more nuclear
2020
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
2121
#.idea/
22+
23+
24+
# Added by cargo
25+
26+
/target

0 commit comments

Comments
 (0)