From e5e4173ee63dcb39d394fac7a72f9e910245e41c Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Wed, 24 Jun 2026 20:03:32 -0500 Subject: [PATCH] Add CI and release GitHub Actions workflows * ci.yml: on pull requests to main, runs on windows-latest and macos-latest; checks formatting, runs clippy (warnings denied), and runs the unit tests (`cargo test --workspace`). * release.yml: manual workflow_dispatch (tag + optional prerelease inputs); builds release binaries for Windows (x86_64) and macOS (aarch64 + x86_64), then publishes them to GitHub Releases with auto-generated notes. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/ci.yml | 40 +++++++++++++++ .github/workflows/release.yml | 91 +++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..29a805d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + pull_request: + branches: [main] + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + name: Test (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, macos-latest] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - name: Cache cargo build + uses: Swatinem/rust-cache@v2 + + - name: Format check + run: cargo fmt --all -- --check + + - name: Clippy + run: cargo clippy --workspace --all-targets --locked -- -D warnings + + - name: Run unit tests + run: cargo test --workspace --locked diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c951036 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,91 @@ +name: Release + +on: + workflow_dispatch: + inputs: + tag: + description: "Release tag, e.g. v0.1.0" + required: true + type: string + prerelease: + description: "Mark this release as a pre-release" + required: false + type: boolean + default: false + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + name: Build ${{ matrix.asset }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + target: x86_64-pc-windows-msvc + bin: drmlibre.exe + asset: drmlibre-windows-x86_64.exe + - os: macos-latest + target: aarch64-apple-darwin + bin: drmlibre + asset: drmlibre-macos-aarch64 + - os: macos-latest + target: x86_64-apple-darwin + bin: drmlibre + asset: drmlibre-macos-x86_64 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache cargo build + uses: Swatinem/rust-cache@v2 + + - name: Build release binary + run: cargo build --release --locked --target ${{ matrix.target }} --bin drmlibre + + - name: Stage artifact + shell: bash + run: | + mkdir -p dist + cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "dist/${{ matrix.asset }}" + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.asset }} + path: dist/${{ matrix.asset }} + if-no-files-found: error + + release: + name: Publish GitHub Release + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + + - name: Publish to GitHub Releases + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ inputs.tag }} + name: ${{ inputs.tag }} + prerelease: ${{ inputs.prerelease }} + generate_release_notes: true + fail_on_unmatched_files: true + files: dist/*