Skip to content

Commit 5ac68f8

Browse files
committed
Initial commit
0 parents  commit 5ac68f8

37 files changed

Lines changed: 9511 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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
**/*
2+
3+
!Cargo.lock
4+
!Cargo.toml
5+
!LICENSE
6+
!README.md
7+
!.cargo/
8+
!src/
9+
!wit/

.github/workflows/dev-release.yaml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
name: Development 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+
cpu: x86-64-v3
29+
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
30+
- target: x86_64-unknown-linux-gnu
31+
os: ubuntu-latest
32+
cpu: x86-64-v3
33+
install_deps: "false"
34+
- target: aarch64-unknown-linux-musl
35+
os: ubuntu-24.04-arm
36+
cpu: neoverse-n1
37+
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
38+
- target: aarch64-unknown-linux-gnu
39+
os: ubuntu-24.04-arm
40+
cpu: neoverse-n1
41+
install_deps: "false"
42+
- target: x86_64-apple-darwin
43+
os: macos-15-intel
44+
cpu: x86-64-v3
45+
install_deps: "false"
46+
- target: aarch64-apple-darwin
47+
os: macos-latest
48+
cpu: apple-m1
49+
install_deps: "false"
50+
- target: x86_64-pc-windows-msvc
51+
os: windows-latest
52+
cpu: x86-64-v3
53+
install_deps: "false"
54+
- target: aarch64-pc-windows-msvc
55+
os: windows-11-arm
56+
cpu: cortex-a76
57+
install_deps: "false"
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 Development 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 README.md 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 README.md
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 README.md
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 Development 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 Release
136+
body: "Latest development build from master.\n\nCommit: ${{ github.sha }}."
137+
files: artifacts/*
138+
prerelease: true
139+
make_latest: false
140+
141+
docker-dev:
142+
name: Push Development Docker
143+
runs-on: ubuntu-latest
144+
steps:
145+
- name: Checkout
146+
uses: actions/checkout@v6
147+
148+
- name: Set Development 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 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: Extract metadata
168+
id: meta
169+
uses: docker/metadata-action@v5
170+
with:
171+
images: ${{ env.REGISTRY }}/${{ github.repository }}
172+
tags: |
173+
type=raw,value=dev
174+
type=sha,prefix=dev-,format=short
175+
type=sha,prefix=dev-,format=long
176+
177+
- name: Build and push
178+
uses: docker/build-push-action@v6
179+
with:
180+
context: .
181+
build-args: LOCK_FLAG=
182+
platforms: linux/amd64,linux/arm64
183+
push: true
184+
tags: ${{ steps.meta.outputs.tags }}
185+
labels: ${{ steps.meta.outputs.labels }}
186+
cache-from: type=gha
187+
cache-to: type=gha,mode=max
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
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+
cpu: x86-64-v3
27+
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
28+
- target: x86_64-unknown-linux-gnu
29+
os: ubuntu-latest
30+
cpu: x86-64-v3
31+
install_deps: "false"
32+
- target: aarch64-unknown-linux-musl
33+
os: ubuntu-24.04-arm
34+
cpu: neoverse-n1
35+
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
36+
- target: aarch64-unknown-linux-gnu
37+
os: ubuntu-24.04-arm
38+
cpu: neoverse-n1
39+
install_deps: "false"
40+
- target: x86_64-apple-darwin
41+
os: macos-15-intel
42+
cpu: x86-64-v3
43+
install_deps: "false"
44+
- target: aarch64-apple-darwin
45+
os: macos-latest
46+
cpu: apple-m1
47+
install_deps: "false"
48+
- target: x86_64-pc-windows-msvc
49+
os: windows-latest
50+
cpu: x86-64-v3
51+
install_deps: "false"
52+
- target: aarch64-pc-windows-msvc
53+
os: windows-11-arm
54+
cpu: cortex-a76
55+
install_deps: "false"
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 README.md 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 README.md
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 README.md
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+
generate_release_notes: true
123+
files: artifacts/*
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 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=semver,pattern={{major}}.{{minor}}
151+
type=sha,prefix={{version}}-,format=short
152+
type=sha,prefix={{version}}-,format=long
153+
154+
- name: Build and push
155+
uses: docker/build-push-action@v6
156+
with:
157+
context: .
158+
platforms: linux/amd64,linux/arm64
159+
push: true
160+
tags: ${{ steps.meta.outputs.tags }}
161+
labels: ${{ steps.meta.outputs.labels }}
162+
cache-from: type=gha
163+
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)