Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
target/
.git/
.github/
benchmark/
tests/
*.md
LICENSE
.gitignore
.dockerignore
76 changes: 76 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install Linux build deps
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake zlib1g-dev libbz2-dev liblzma-dev \
libcurl4-openssl-dev libssl-dev libfontconfig1-dev pkg-config clang

- name: Install macOS build deps
if: runner.os == 'macOS'
run: brew install bzip2 xz

- uses: Swatinem/rust-cache@v2

- name: Build
run: cargo build --release

- name: Test
run: cargo test --release

fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Install Linux build deps
run: |
sudo apt-get update
sudo apt-get install -y cmake zlib1g-dev libbz2-dev liblzma-dev \
libcurl4-openssl-dev libssl-dev libfontconfig1-dev pkg-config clang

- uses: Swatinem/rust-cache@v2

- run: cargo clippy -- -D warnings
190 changes: 190 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
name: Release

on:
push:
tags:
- "v[0-9]+.*"

permissions:
contents: write
packages: write

env:
CARGO_TERM_COLOR: always

jobs:
# ------------------------------------------------------------------
# 1. Create a draft GitHub release
# ------------------------------------------------------------------
create-release:
name: Create release
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- uses: actions/checkout@v4

- name: Get tag
id: tag
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"

- name: Create draft release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "${{ steps.tag.outputs.tag }}" --draft --verify-tag --title "${{ steps.tag.outputs.tag }}"

# ------------------------------------------------------------------
# 2. Build binaries for each target
# ------------------------------------------------------------------
build-binaries:
name: Build ${{ matrix.name }}
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- name: linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use-cross: false
# Linux aarch64
- name: linux-aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
use-cross: true
# macOS x86_64
- name: macos-x86_64
os: macos-13
target: x86_64-apple-darwin
use-cross: false
# macOS aarch64 (Apple Silicon)
- name: macos-aarch64
os: macos-latest
target: aarch64-apple-darwin
use-cross: false

steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

# Linux build dependencies (native)
- name: Install Linux build deps
if: runner.os == 'Linux' && !matrix.use-cross
run: |
sudo apt-get update
sudo apt-get install -y cmake zlib1g-dev libbz2-dev liblzma-dev \
libcurl4-openssl-dev libssl-dev libfontconfig1-dev pkg-config clang

# macOS build dependencies
- name: Install macOS build deps
if: runner.os == 'macOS'
run: brew install bzip2 xz

# Cross (for Linux aarch64)
- name: Install cross
if: matrix.use-cross
uses: taiki-e/install-action@v2
with:
tool: cross

- name: Build
run: |
if [ "${{ matrix.use-cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi

- name: Package
id: package
run: |
BIN="duprust"
TAG="${{ needs.create-release.outputs.tag }}"
ARCHIVE="${BIN}-${TAG}-${{ matrix.name }}"

mkdir -p "staging/${ARCHIVE}"
cp "target/${{ matrix.target }}/release/${BIN}" "staging/${ARCHIVE}/"
cp README.md LICENSE "staging/${ARCHIVE}/" 2>/dev/null || true

cd staging
tar czf "../${ARCHIVE}.tar.gz" "${ARCHIVE}"
cd ..

# SHA256 checksum
shasum -a 256 "${ARCHIVE}.tar.gz" > "${ARCHIVE}.tar.gz.sha256"

echo "archive=${ARCHIVE}.tar.gz" >> "$GITHUB_OUTPUT"
echo "checksum=${ARCHIVE}.tar.gz.sha256" >> "$GITHUB_OUTPUT"

- name: Upload to release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${{ needs.create-release.outputs.tag }}" \
"${{ steps.package.outputs.archive }}" \
"${{ steps.package.outputs.checksum }}"

# ------------------------------------------------------------------
# 3. Build & push Docker image to GHCR
# ------------------------------------------------------------------
docker:
name: Docker image
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# ------------------------------------------------------------------
# 4. Publish the release (undraft)
# ------------------------------------------------------------------
publish-release:
name: Publish release
needs: [create-release, build-binaries, docker]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
run: gh release edit "${{ needs.create-release.outputs.tag }}" --draft=false
Loading
Loading