make packages too I guess

23c3f77 · gmorell · 2025-12-26 03:15

3 files +212 -0

Files changed

added .github/workflows/rust-ci.yml
+212 −0
@@ -0,0 +1,212 @@
1 +name: Rust CI and Docker Build
2 +
3 +on:
4 + push:
5 + branches: [ master ]
6 + tags: [ 'v*' ]
7 + pull_request:
8 + branches: [ master ]
9 +
10 +env:
11 + CARGO_TERM_COLOR: always
12 + REGISTRY: ghcr.io
13 + IMAGE_NAME: ${{ github.repository }}
14 +
15 +jobs:
16 + build:
17 + strategy:
18 + matrix:
19 + include:
20 + - runner: ubuntu-latest
21 + arch: x86_64
22 + - runner: [self-hosted, runner-aarch64]
23 + arch: aarch64
24 + runs-on: ${{ matrix.runner }}
25 + permissions:
26 + contents: read
27 + packages: write
28 +
29 + steps:
30 + - uses: actions/checkout@v4
31 +
32 + - name: Install system dependencies (Linux)
33 + if: runner.os == 'Linux'
34 + run: |
35 + if command -v apt-get &> /dev/null; then
36 + sudo apt-get update
37 + sudo apt-get install -y pkg-config libssl-dev libgtk-3-dev libgdk-pixbuf2.0-dev libpango1.0-dev
38 + elif command -v yum &> /dev/null; then
39 + sudo yum install -y pkgconfig openssl-devel gtk3-devel gdk-pixbuf-devel pango-devel
40 + elif command -v dnf &> /dev/null; then
41 + sudo dnf install -y pkgconfig openssl-devel
42 + elif command -v pacman &> /dev/null; then
43 + sudo pacman -Sy --noconfirm pkgconf openssl
44 + elif command -v apk &> /dev/null; then
45 + sudo apk add --no-cache pkgconfig openssl-dev
46 + else
47 + echo "Package manager not found. Please install pkg-config and openssl-dev manually."
48 + exit 1
49 + fi
50 +
51 + - name: Install Rust
52 + uses: dtolnay/rust-toolchain@stable
53 + with:
54 + toolchain: "1.86"
55 + components: rustfmt, clippy
56 +
57 + - name: Setup Rust cache
58 + uses: Swatinem/rust-cache@v2
59 +
60 + - name: Build
61 + run: cargo build --verbose
62 +
63 + - name: Run tests
64 + run: cargo test --verbose
65 +
66 + - name: Check formatting
67 + run: cargo fmt -- --check
68 +
69 + - name: Run clippy
70 + run: cargo clippy -- -D warnings
71 +
72 + - name: Check
73 + run: cargo check
74 +
75 +
76 + release:
77 + name: Release
78 + if: startsWith(github.ref, 'refs/tags/v')
79 + needs: build
80 + permissions:
81 + contents: write
82 + packages: write
83 + strategy:
84 + matrix:
85 + include:
86 + - os: ubuntu-latest
87 + name: koco-x86_64-linux-gnu.tar.gz
88 + archive_cmd: tar -czf
89 + binary_ext: ""
90 + rust: "1.86"
91 + - os: [self-hosted, runner-aarch64]
92 + name: koco-aarch64-linux-gnu.tar.gz
93 + archive_cmd: tar -czf
94 + binary_ext: ""
95 + rust: "1.86"
96 + - os: macos-latest
97 + name: koco-aarch64-macos.tar.gz
98 + archive_cmd: tar -czf
99 + binary_ext: ""
100 + rust: "1.86"
101 + - os: windows-latest
102 + name: koco-x86_64-windows.zip
103 + archive_cmd: 7z a
104 + binary_ext: ".exe"
105 + rust: "1.86"
106 + runs-on: ${{ matrix.os }}
107 +
108 + steps:
109 + - uses: actions/checkout@v4
110 +
111 + - name: Install system dependencies (self-hosted Linux)
112 + if: runner.os == 'Linux'
113 + run: |
114 + if command -v apt-get &> /dev/null; then
115 + sudo apt-get update
116 + sudo apt-get install -y pkg-config libssl-dev libgtk-3-dev libgdk-pixbuf2.0-dev libpango1.0-dev libglib2.0-dev
117 + elif command -v yum &> /dev/null; then
118 + sudo yum install -y pkgconfig openssl-devel gtk3-devel gdk-pixbuf-devel pango-devel
119 + elif command -v dnf &> /dev/null; then
120 + sudo dnf install -y pkgconfig openssl-devel
121 + elif command -v pacman &> /dev/null; then
122 + sudo pacman -Sy --noconfirm pkgconf openssl
123 + elif command -v apk &> /dev/null; then
124 + sudo apk add --no-cache pkgconfig openssl-dev
125 + else
126 + echo "Package manager not found. Please install pkg-config and openssl-dev manually."
127 + exit 1
128 + fi
129 +
130 + - name: Install Rust
131 + uses: dtolnay/rust-toolchain@stable
132 + with:
133 + toolchain: ${{ matrix.rust }}
134 +
135 + - name: Setup Rust cache
136 + uses: Swatinem/rust-cache@v2
137 + with:
138 + key: ${{ matrix.os }}-${{ matrix.rust }}
139 +
140 + - name: Build release binary
141 + run: cargo build --release --verbose
142 +
143 + - name: Strip binary (Unix)
144 + if: matrix.os != 'windows-latest'
145 + run: |
146 + strip target/release/koco${{ matrix.binary_ext }}
147 +
148 + - name: Create release archive (Unix)
149 + if: matrix.os != 'windows-latest'
150 + run: |
151 + cd target/release
152 + tar -czf ../../${{ matrix.name }} koco
153 + cd ../..
154 +
155 + - name: Create release archive (Windows)
156 + if: matrix.os == 'windows-latest'
157 + run: |
158 + cd target/release
159 + 7z a ../../${{ matrix.name }} koco.exe
160 + cd ../..
161 +
162 + - name: Upload release archive
163 + uses: actions/upload-artifact@v4
164 + with:
165 + name: ${{ matrix.name }}
166 + path: ${{ matrix.name }}
167 +
168 + create-release:
169 + name: Create Release
170 + runs-on: ubuntu-latest
171 + if: startsWith(github.ref, 'refs/tags/v')
172 + needs: release
173 + permissions:
174 + contents: write
175 + steps:
176 + - uses: actions/checkout@v4
177 +
178 + - name: Download all artifacts
179 + uses: actions/download-artifact@v4
180 + with:
181 + path: artifacts
182 +
183 + - name: Create release notes
184 + run: |
185 + echo "# koco Release ${GITHUB_REF_NAME}" > release_notes.md
186 + echo "" >> release_notes.md
187 + echo "## Changes in this release" >> release_notes.md
188 + echo "" >> release_notes.md
189 + echo "## Supported Platforms" >> release_notes.md
190 + echo "" >> release_notes.md
191 + echo "- Linux (x86_64)" >> release_notes.md
192 + echo "- Linux (aarch64)" >> release_notes.md
193 + echo "- Windows (x86_64)" >> release_notes.md
194 + echo "- macOS (x86_64 and Apple Silicon)" >> release_notes.md
195 + echo "" >> release_notes.md
196 + echo "## Installation" >> release_notes.md
197 + echo "" >> release_notes.md
198 + echo "1. Download the appropriate archive for your platform" >> release_notes.md
199 + echo "2. Extract the binaries" >> release_notes.md
200 + echo "3. Place them in your PATH" >> release_notes.md
201 + echo "" >> release_notes.md
202 +
203 + - name: Create GitHub Release
204 + uses: softprops/action-gh-release@v1
205 + with:
206 + files: artifacts/*/*.tar.gz,artifacts/*/*.zip
207 + body_path: release_notes.md
208 + draft: false
209 + prerelease: ${{ contains(github.ref_name, '-') }}
210 + generate_release_notes: true
211 + env:
212 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Parents: 6b17830