Skip to content

Commit 8ce9c04

Browse files
piscisaureusclaude
andcommitted
Add GitHub Actions CI workflow
Build release binaries for linux-x86_64, linux-arm64, and macos-arm64. Run clippy, rustfmt, and tests on every push/PR. Create GitHub releases on version tags. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 30ae3b4 commit 8ce9c04

File tree

2 files changed

+98
-6
lines changed

2 files changed

+98
-6
lines changed

.github/workflows/ci.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main]
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
lint:
15+
name: Lint & Format
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: dtolnay/rust-toolchain@stable
20+
with:
21+
components: clippy, rustfmt
22+
- uses: Swatinem/rust-cache@v2
23+
- run: cargo fmt --check
24+
- run: cargo clippy -- -D warnings
25+
26+
test:
27+
name: Test
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: dtolnay/rust-toolchain@stable
32+
- uses: Swatinem/rust-cache@v2
33+
- run: cargo test
34+
35+
build:
36+
name: Build (${{ matrix.name }})
37+
needs: [lint, test]
38+
runs-on: ${{ matrix.runner }}
39+
strategy:
40+
matrix:
41+
include:
42+
- name: linux-x86_64
43+
runner: ubuntu-latest
44+
target: x86_64-unknown-linux-gnu
45+
artifact: ptywrap-linux-x86_64
46+
- name: linux-arm64
47+
runner: ubuntu-24.04-arm
48+
target: aarch64-unknown-linux-gnu
49+
artifact: ptywrap-linux-arm64
50+
- name: macos-arm64
51+
runner: macos-14
52+
target: aarch64-apple-darwin
53+
artifact: ptywrap-macos-arm64
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: dtolnay/rust-toolchain@stable
57+
- uses: Swatinem/rust-cache@v2
58+
with:
59+
key: ${{ matrix.target }}
60+
- run: cargo build --release
61+
- uses: actions/upload-artifact@v4
62+
with:
63+
name: ${{ matrix.artifact }}
64+
path: target/release/ptywrap
65+
66+
release:
67+
name: Release
68+
if: startsWith(github.ref, 'refs/tags/v')
69+
needs: [build]
70+
runs-on: ubuntu-latest
71+
permissions:
72+
contents: write
73+
steps:
74+
- uses: actions/download-artifact@v4
75+
with:
76+
path: artifacts
77+
78+
- name: Prepare release assets
79+
run: |
80+
for dir in artifacts/ptywrap-*; do
81+
name=$(basename "$dir")
82+
chmod +x "$dir/ptywrap"
83+
tar -czf "${name}.tar.gz" -C "$dir" ptywrap
84+
shasum -a 256 "${name}.tar.gz" >> checksums.txt
85+
done
86+
87+
- uses: softprops/action-gh-release@v2
88+
with:
89+
files: |
90+
ptywrap-*.tar.gz
91+
checksums.txt
92+
generate_release_notes: true

src/keys.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ pub fn key_to_bytes(name: &str) -> Option<Vec<u8>> {
9999
let stripped = lower
100100
.strip_prefix("ctrl-")
101101
.or_else(|| lower.strip_prefix("c-"));
102-
if let Some(ch) = stripped {
103-
if ch.len() == 1 {
104-
let c = ch.as_bytes()[0];
105-
if c.is_ascii_lowercase() {
106-
return Some(vec![c - b'a' + 1]);
107-
}
102+
if let Some(ch) = stripped
103+
&& ch.len() == 1
104+
{
105+
let c = ch.as_bytes()[0];
106+
if c.is_ascii_lowercase() {
107+
return Some(vec![c - b'a' + 1]);
108108
}
109109
}
110110
None

0 commit comments

Comments
 (0)