Skip to content

Commit d17fc93

Browse files
committed
Initial commit
0 parents  commit d17fc93

37 files changed

Lines changed: 9211 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: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
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+
# RUSTFLAGS="-C target_cpu=native" and apple-m1 CPUs cause brittle behavior
88+
- name: Delete Cargo Config
89+
shell: bash
90+
run: rm -f .cargo/config.toml
91+
92+
- name: Build Binary
93+
env:
94+
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
95+
run: cargo build --release --target ${{ matrix.target }}
96+
97+
- name: Package Binary
98+
shell: bash
99+
run: |
100+
mkdir dist
101+
cp LICENSE dist/
102+
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
103+
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" dist/
104+
cd dist
105+
7z a "../${{ env.BIN_NAME }}-${{ matrix.target }}.zip" "${{ env.BIN_NAME }}.exe" LICENSE
106+
else
107+
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" dist/
108+
cd dist
109+
tar -czf "../${{ env.BIN_NAME }}-${{ matrix.target }}.tar.gz" "${{ env.BIN_NAME }}" LICENSE
110+
fi
111+
112+
- name: Upload Artifact
113+
uses: actions/upload-artifact@v6
114+
with:
115+
name: binary-${{ matrix.target }}
116+
path: ${{ env.BIN_NAME }}-${{ matrix.target }}*
117+
retention-days: 1
118+
119+
release-dev:
120+
name: Update Dev Release
121+
needs: build-dev
122+
continue-on-error: true
123+
runs-on: ubuntu-latest
124+
steps:
125+
- name: Download Artifacts
126+
uses: actions/download-artifact@v6
127+
with:
128+
path: artifacts
129+
merge-multiple: true
130+
131+
- name: Update Pre-Release
132+
uses: softprops/action-gh-release@v2
133+
with:
134+
tag_name: dev
135+
name: Development Build
136+
body: "Latest development build from master. Commit: ${{ github.sha }}"
137+
prerelease: true
138+
files: artifacts/*
139+
make_latest: false
140+
141+
docker-dev:
142+
name: Push Dev Docker
143+
runs-on: ubuntu-latest
144+
steps:
145+
- name: Checkout
146+
uses: actions/checkout@v6
147+
148+
- name: Set Dev Version
149+
shell: bash
150+
run: |
151+
BASE_VERSION=$(grep -m1 'version = "' Cargo.toml | cut -d '"' -f 2)
152+
SHORT_SHA=$(git rev-parse --short HEAD)
153+
NEW_VERSION="${BASE_VERSION}-dev.${SHORT_SHA}"
154+
155+
sed -i.bak "s/^version = .*/version = \"$NEW_VERSION\"/" Cargo.toml
156+
157+
- name: Set up QEMU
158+
uses: docker/setup-qemu-action@v3
159+
160+
- name: Set up Docker Buildx
161+
uses: docker/setup-buildx-action@v3
162+
163+
- name: Log in to GHCR
164+
uses: docker/login-action@v3
165+
with:
166+
registry: ${{ env.REGISTRY }}
167+
username: ${{ github.repository_owner }}
168+
password: ${{ secrets.GITHUB_TOKEN }}
169+
170+
- name: Build and push
171+
uses: docker/build-push-action@v6
172+
with:
173+
context: .
174+
build-args: |
175+
LOCK_FLAG=
176+
platforms: linux/amd64,linux/arm64
177+
push: true
178+
tags: |
179+
${{ env.REGISTRY }}/${{ github.repository }}:dev
180+
cache-from: type=gha
181+
cache-to: type=gha,mode=max
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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+
# RUSTFLAGS="-C target_cpu=native" and apple-m1 CPUs cause brittle behavior
77+
- name: Delete Cargo Config
78+
shell: bash
79+
run: rm -f .cargo/config.toml
80+
81+
- name: Build Binary
82+
env:
83+
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
84+
run: cargo build --release --target ${{ matrix.target }}
85+
86+
- name: Package Binary
87+
shell: bash
88+
run: |
89+
mkdir dist
90+
cp LICENSE dist/
91+
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
92+
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" dist/
93+
cd dist
94+
7z a "../${{ env.BIN_NAME }}-${{ matrix.target }}.zip" "${{ env.BIN_NAME }}.exe" LICENSE
95+
else
96+
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" dist/
97+
cd dist
98+
tar -czf "../${{ env.BIN_NAME }}-${{ matrix.target }}.tar.gz" "${{ env.BIN_NAME }}" LICENSE
99+
fi
100+
101+
- name: Upload Artifact
102+
uses: actions/upload-artifact@v6
103+
with:
104+
name: binary-${{ matrix.target }}
105+
path: ${{ env.BIN_NAME }}-${{ matrix.target }}*
106+
retention-days: 1
107+
108+
release-stable:
109+
name: Create Official Release
110+
needs: build-stable
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: Download Artifacts
114+
uses: actions/download-artifact@v6
115+
with:
116+
path: artifacts
117+
merge-multiple: true
118+
119+
- name: Create Release
120+
uses: softprops/action-gh-release@v2
121+
with:
122+
files: artifacts/*
123+
generate_release_notes: true
124+
make_latest: true
125+
126+
docker-stable:
127+
name: Push Stable Docker
128+
runs-on: ubuntu-latest
129+
steps:
130+
- name: Checkout
131+
uses: actions/checkout@v6
132+
133+
- name: Set up QEMU
134+
uses: docker/setup-qemu-action@v3
135+
136+
- name: Set up Docker Buildx
137+
uses: docker/setup-buildx-action@v3
138+
139+
- name: Log in to GHCR
140+
uses: docker/login-action@v3
141+
with:
142+
registry: ${{ env.REGISTRY }}
143+
username: ${{ github.repository_owner }}
144+
password: ${{ secrets.GITHUB_TOKEN }}
145+
146+
- name: Extract metadata
147+
id: meta
148+
uses: docker/metadata-action@v5
149+
with:
150+
images: ${{ env.REGISTRY }}/${{ github.repository }}
151+
tags: |
152+
type=semver,pattern={{version}}
153+
type=raw,value=latest
154+
155+
- name: Build and push
156+
uses: docker/build-push-action@v6
157+
with:
158+
context: .
159+
platforms: linux/amd64,linux/arm64
160+
push: true
161+
tags: ${{ steps.meta.outputs.tags }}
162+
labels: ${{ steps.meta.outputs.labels }}
163+
cache-from: type=gha
164+
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)