diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..03f4879 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustflags = ["-Ctarget-cpu=native"] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..16dec30 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,56 @@ +name: Build + +on: + workflow_call: + workflow_dispatch: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + strategy: + matrix: + target: + - aarch64-apple-darwin + - x86_64-apple-darwin + - x86_64-pc-windows-msvc + - aarch64-unknown-linux-musl + - x86_64-unknown-linux-musl + include: + - target: aarch64-apple-darwin + runner: macos-14 + - target: x86_64-apple-darwin + runner: macos-latest + - target: x86_64-pc-windows-msvc + runner: windows-latest + - target: aarch64-unknown-linux-musl + runner: ubuntu-latest + - target: x86_64-unknown-linux-musl + runner: ubuntu-latest + fail-fast: false + runs-on: ${{ matrix.runner }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + target: ${{ matrix.target }} + + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Build + run: cargo build --release --locked --target ${{ matrix.target }} + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + if-no-files-found: "error" + name: purr-${{ matrix.target }} + path: | + ./target/${{ matrix.target }}/release/purr${{ contains(matrix.target, 'windows') && '.exe' || '' }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3ee159b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: Release + +on: + push: + tags: ["v*.*.*"] + +jobs: + check: + uses: ./.github/workflows/check.yml + + build: + uses: ./.github/workflows/build.yml + + publish: + needs: [check, build] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Publish + run: cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} + + release: + needs: [publish] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.0.21 + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Generate release notes + run: bunx changelogithub@latest --output CHANGELOG.txt + + - name: Create release + uses: softprops/action-gh-release@v1 + with: + body_path: CHANGELOG.txt + files: artifacts/**/* diff --git a/Cargo.toml b/Cargo.toml index c7fa0c9..03d065b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,10 @@ url = "2.5.0" [lints.clippy] all = "warn" pedantic = "warn" + +[profile.release] +lto = "fat" +strip = "symbols" +codegen-units = 1 +opt-level = "z" +panic = "abort"