Skip to content

Commit 5495397

Browse files
committed
Initial commit
0 parents  commit 5495397

37 files changed

Lines changed: 9205 additions & 0 deletions

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
rustflags = ["-C", "target-cpu=native"]

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**/*
2+
!.cargo
3+
!Cargo.toml
4+
!Cargo.lock
5+
!src/
6+
!wit/

.github/workflows/dev-release.yaml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: Dev Release
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
tags-ignore:
8+
- "**"
9+
10+
env:
11+
BIN_NAME: ${{ github.event.repository.name }}
12+
REGISTRY: ghcr.io
13+
14+
permissions:
15+
contents: write
16+
packages: write
17+
18+
jobs:
19+
build-dev:
20+
name: Build ${{ matrix.target }}
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
include:
26+
- target: x86_64-unknown-linux-musl
27+
os: ubuntu-latest
28+
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
29+
cpu: x86-64-v3
30+
- target: x86_64-unknown-linux-gnu
31+
os: ubuntu-latest
32+
install_deps: "false"
33+
cpu: x86-64-v3
34+
- target: aarch64-unknown-linux-musl
35+
os: ubuntu-24.04-arm
36+
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
37+
cpu: neoverse-n1
38+
- target: aarch64-unknown-linux-gnu
39+
os: ubuntu-24.04-arm
40+
install_deps: "false"
41+
cpu: neoverse-n1
42+
- target: x86_64-apple-darwin
43+
os: macos-15-intel
44+
install_deps: "false"
45+
cpu: x86-64-v3
46+
- target: aarch64-apple-darwin
47+
os: macos-latest
48+
install_deps: "false"
49+
cpu: apple-m1
50+
- target: x86_64-pc-windows-msvc
51+
os: windows-latest
52+
install_deps: "false"
53+
cpu: x86-64-v3
54+
- target: aarch64-pc-windows-msvc
55+
os: windows-11-arm
56+
install_deps: "false"
57+
cpu: cortex-a76
58+
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v6
62+
63+
- name: Install System Dependencies
64+
if: matrix.install_deps != 'false'
65+
run: ${{ matrix.install_deps }}
66+
67+
- name: Install Rust Toolchain
68+
uses: dtolnay/rust-toolchain@master
69+
with:
70+
toolchain: stable
71+
targets: ${{ matrix.target }}
72+
73+
- name: Rust Cache
74+
uses: swatinem/rust-cache@v2
75+
with:
76+
key: ${{ matrix.target }}
77+
78+
- name: Set Dev Version
79+
shell: bash
80+
run: |
81+
BASE_VERSION=$(grep -m1 'version = "' Cargo.toml | cut -d '"' -f 2)
82+
SHORT_SHA=$(git rev-parse --short HEAD)
83+
NEW_VERSION="${BASE_VERSION}-dev.${SHORT_SHA}"
84+
85+
sed -i.bak "s/^version = .*/version = \"$NEW_VERSION\"/" Cargo.toml
86+
87+
- name: Build Binary
88+
env:
89+
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
90+
run: |
91+
rm -f .cargo/config.toml # RUSTFLAGS="-C target_cpu=native" and apple-m1 CPUs cause brittle behavior
92+
cargo build --release --target ${{ matrix.target }}
93+
94+
- name: Package Binary
95+
shell: bash
96+
run: |
97+
mkdir dist
98+
cp LICENSE dist/
99+
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
100+
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" dist/
101+
cd dist
102+
7z a "../${{ env.BIN_NAME }}-${{ matrix.target }}.zip" "${{ env.BIN_NAME }}.exe" LICENSE
103+
else
104+
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" dist/
105+
cd dist
106+
tar -czf "../${{ env.BIN_NAME }}-${{ matrix.target }}.tar.gz" "${{ env.BIN_NAME }}" LICENSE
107+
fi
108+
109+
- name: Upload Artifact
110+
uses: actions/upload-artifact@v6
111+
with:
112+
name: binary-${{ matrix.target }}
113+
path: ${{ env.BIN_NAME }}-${{ matrix.target }}*
114+
retention-days: 1
115+
116+
release-dev:
117+
name: Update Dev Release
118+
needs: build-dev
119+
continue-on-error: true
120+
runs-on: ubuntu-latest
121+
steps:
122+
- name: Download Artifacts
123+
uses: actions/download-artifact@v6
124+
with:
125+
path: artifacts
126+
merge-multiple: true
127+
128+
- name: Update Pre-Release
129+
uses: softprops/action-gh-release@v2
130+
with:
131+
tag_name: dev
132+
name: Development Build
133+
body: "Latest development build from master. Commit: ${{ github.sha }}"
134+
prerelease: true
135+
files: artifacts/*
136+
make_latest: false
137+
138+
docker-dev:
139+
name: Push Dev Docker
140+
runs-on: ubuntu-latest
141+
steps:
142+
- name: Checkout
143+
uses: actions/checkout@v6
144+
145+
- name: Set Dev Version
146+
shell: bash
147+
run: |
148+
BASE_VERSION=$(grep -m1 'version = "' Cargo.toml | cut -d '"' -f 2)
149+
SHORT_SHA=$(git rev-parse --short HEAD)
150+
NEW_VERSION="${BASE_VERSION}-dev.${SHORT_SHA}"
151+
152+
sed -i.bak "s/^version = .*/version = \"$NEW_VERSION\"/" Cargo.toml
153+
154+
- name: Set up QEMU
155+
uses: docker/setup-qemu-action@v3
156+
157+
- name: Set up Docker Buildx
158+
uses: docker/setup-buildx-action@v3
159+
160+
- name: Log in to GHCR
161+
uses: docker/login-action@v3
162+
with:
163+
registry: ${{ env.REGISTRY }}
164+
username: ${{ github.repository_owner }}
165+
password: ${{ secrets.GITHUB_TOKEN }}
166+
167+
- name: Build and push
168+
uses: docker/build-push-action@v6
169+
with:
170+
context: .
171+
build-args: |
172+
LOCK_FLAG=
173+
platforms: linux/amd64,linux/arm64
174+
push: true
175+
tags: |
176+
${{ env.REGISTRY }}/${{ github.repository }}:dev
177+
cache-from: type=gha
178+
cache-to: type=gha,mode=max
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: Stable Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
BIN_NAME: ${{ github.event.repository.name }}
10+
REGISTRY: ghcr.io
11+
12+
permissions:
13+
contents: write
14+
packages: write
15+
16+
jobs:
17+
build-stable:
18+
name: Build ${{ matrix.target }}
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
- target: x86_64-unknown-linux-musl
25+
os: ubuntu-latest
26+
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
27+
cpu: x86-64-v3
28+
- target: x86_64-unknown-linux-gnu
29+
os: ubuntu-latest
30+
install_deps: "false"
31+
cpu: x86-64-v3
32+
- target: aarch64-unknown-linux-musl
33+
os: ubuntu-24.04-arm
34+
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
35+
cpu: neoverse-n1
36+
- target: aarch64-unknown-linux-gnu
37+
os: ubuntu-24.04-arm
38+
install_deps: "false"
39+
cpu: neoverse-n1
40+
- target: x86_64-apple-darwin
41+
os: macos-15-intel
42+
install_deps: "false"
43+
cpu: x86-64-v3
44+
- target: aarch64-apple-darwin
45+
os: macos-latest
46+
install_deps: "false"
47+
cpu: apple-m1
48+
- target: x86_64-pc-windows-msvc
49+
os: windows-latest
50+
install_deps: "false"
51+
cpu: x86-64-v3
52+
- target: aarch64-pc-windows-msvc
53+
os: windows-11-arm
54+
install_deps: "false"
55+
cpu: cortex-a76
56+
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v6
60+
61+
- name: Install System Dependencies
62+
if: matrix.install_deps != 'false'
63+
run: ${{ matrix.install_deps }}
64+
65+
- name: Install Rust Toolchain
66+
uses: dtolnay/rust-toolchain@master
67+
with:
68+
toolchain: stable
69+
targets: ${{ matrix.target }}
70+
71+
- name: Rust Cache
72+
uses: swatinem/rust-cache@v2
73+
with:
74+
key: ${{ matrix.target }}
75+
76+
- name: Build Binary
77+
env:
78+
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
79+
run: |
80+
rm -f .cargo/config.toml # RUSTFLAGS="-C target_cpu=native" and apple-m1 CPUs cause brittle behavior
81+
cargo build --release --target ${{ matrix.target }}
82+
83+
- name: Package Binary
84+
shell: bash
85+
run: |
86+
mkdir dist
87+
cp LICENSE dist/
88+
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
89+
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" dist/
90+
cd dist
91+
7z a "../${{ env.BIN_NAME }}-${{ matrix.target }}.zip" "${{ env.BIN_NAME }}.exe" LICENSE
92+
else
93+
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" dist/
94+
cd dist
95+
tar -czf "../${{ env.BIN_NAME }}-${{ matrix.target }}.tar.gz" "${{ env.BIN_NAME }}" LICENSE
96+
fi
97+
98+
- name: Upload Artifact
99+
uses: actions/upload-artifact@v6
100+
with:
101+
name: binary-${{ matrix.target }}
102+
path: ${{ env.BIN_NAME }}-${{ matrix.target }}*
103+
retention-days: 1
104+
105+
release-stable:
106+
name: Create Official Release
107+
needs: build-stable
108+
runs-on: ubuntu-latest
109+
steps:
110+
- name: Download Artifacts
111+
uses: actions/download-artifact@v6
112+
with:
113+
path: artifacts
114+
merge-multiple: true
115+
116+
- name: Create Release
117+
uses: softprops/action-gh-release@v2
118+
with:
119+
files: artifacts/*
120+
generate_release_notes: true
121+
make_latest: true
122+
123+
docker-stable:
124+
name: Push Stable Docker
125+
runs-on: ubuntu-latest
126+
steps:
127+
- name: Checkout
128+
uses: actions/checkout@v6
129+
130+
- name: Set up QEMU
131+
uses: docker/setup-qemu-action@v3
132+
133+
- name: Set up Docker Buildx
134+
uses: docker/setup-buildx-action@v3
135+
136+
- name: Log in to GHCR
137+
uses: docker/login-action@v3
138+
with:
139+
registry: ${{ env.REGISTRY }}
140+
username: ${{ github.repository_owner }}
141+
password: ${{ secrets.GITHUB_TOKEN }}
142+
143+
- name: Extract metadata
144+
id: meta
145+
uses: docker/metadata-action@v5
146+
with:
147+
images: ${{ env.REGISTRY }}/${{ github.repository }}
148+
tags: |
149+
type=semver,pattern={{version}}
150+
type=raw,value=latest
151+
152+
- name: Build and push
153+
uses: docker/build-push-action@v6
154+
with:
155+
context: .
156+
platforms: linux/amd64,linux/arm64
157+
push: true
158+
tags: ${{ steps.meta.outputs.tags }}
159+
labels: ${{ steps.meta.outputs.labels }}
160+
cache-from: type=gha
161+
cache-to: type=gha,mode=max

.github/workflows/test.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
concurrency:
8+
group: ${{ github.ref }}-${{ github.workflow }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Branch
16+
uses: actions/checkout@v6
17+
- name: Run Cargo Clippy
18+
run: cargo clippy -- -W clippy::pedantic -D warnings

0 commit comments

Comments
 (0)