From a6c1c756d7163111a150c061f289163f87a3787c Mon Sep 17 00:00:00 2001 From: gngpp Date: Wed, 8 Jul 2026 07:06:29 +0800 Subject: [PATCH 1/2] ci: support Windows native gem builds --- .github/workflows/release.yml | 118 ++++++++++++++++++++++++++++++++-- README.md | 1 + 2 files changed, 113 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88c4ae1..fccb7c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,12 @@ on: workflow_dispatch: push: tags: ["v*"] + pull_request: + paths-ignore: + - "docs/**" + - "benchmark/**" + - "examples/**" + - "*.md" concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -31,7 +37,7 @@ jobs: path: pkg/*.gem if-no-files-found: error - cross-compile: + native-linux: name: Build native gem (${{ matrix.platform }}) runs-on: ubuntu-latest strategy: @@ -52,7 +58,7 @@ jobs: - uses: actions/upload-artifact@v7 with: - name: cross-gem-${{ matrix.platform }} + name: native-gem-${{ matrix.platform }} path: pkg/*.gem if-no-files-found: error @@ -125,9 +131,70 @@ jobs: path: pkg/*arm64-darwin*.gem if-no-files-found: error + native-windows: + name: Build native gem (x64-mingw-ucrt) + runs-on: windows-latest + steps: + - uses: actions/checkout@v7 + + - uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-pc-windows-gnu + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.3" + bundler-cache: true + + - name: Compile for Ruby 3.3 + shell: pwsh + env: + RB_SYS_CARGO_PROFILE: release + run: | + ./script/build_windows_gnu.ps1 -SkipBundleInstall + New-Item -ItemType Directory -Force "lib\wreq_ruby\3.3" | Out-Null + Copy-Item "lib\wreq_ruby\wreq_ruby.so" "lib\wreq_ruby\3.3\wreq_ruby.so" -Force + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.4" + bundler-cache: true + + - name: Compile for Ruby 3.4 + shell: pwsh + env: + RB_SYS_CARGO_PROFILE: release + run: | + ./script/build_windows_gnu.ps1 -SkipBundleInstall + New-Item -ItemType Directory -Force "lib\wreq_ruby\3.4" | Out-Null + Copy-Item "lib\wreq_ruby\wreq_ruby.so" "lib\wreq_ruby\3.4\wreq_ruby.so" -Force + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "4.0" + bundler-cache: true + + - name: Compile for Ruby 4.0 + shell: pwsh + env: + RB_SYS_CARGO_PROFILE: release + run: | + ./script/build_windows_gnu.ps1 -SkipBundleInstall + New-Item -ItemType Directory -Force "lib\wreq_ruby\4.0" | Out-Null + Copy-Item "lib\wreq_ruby\wreq_ruby.so" "lib\wreq_ruby\4.0\wreq_ruby.so" -Force + + - name: Build platform gem + run: ruby script/build_platform_gem.rb x64-mingw-ucrt + + - uses: actions/upload-artifact@v7 + with: + name: native-gem-x64-mingw-ucrt + path: pkg/*x64-mingw-ucrt*.gem + if-no-files-found: error + smoke-test: name: Smoke test Linux (Ruby ${{ matrix.ruby }}) - needs: [cross-compile] + needs: [native-linux] runs-on: ubuntu-latest strategy: fail-fast: false @@ -140,7 +207,7 @@ jobs: - uses: actions/download-artifact@v8 with: - name: cross-gem-x86_64-linux + name: native-gem-x86_64-linux path: pkg/ - name: Install native gem @@ -173,9 +240,48 @@ jobs: - name: Verify gem loads and prints version run: ruby -rwreq -e "puts Wreq::VERSION" + smoke-test-windows: + name: Smoke test Windows (${{ matrix.platform }}, Ruby ${{ matrix.ruby }}) + needs: [native-windows] + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + include: + - platform: x64-mingw-ucrt + ruby: "3.3" + - platform: x64-mingw-ucrt + ruby: "3.4" + - platform: x64-mingw-ucrt + ruby: "4.0" + steps: + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + + - uses: actions/download-artifact@v8 + with: + name: native-gem-${{ matrix.platform }} + path: pkg/ + + - name: Install native gem + run: gem install pkg/wreq-*-${{ matrix.platform }}.gem + + - name: Verify gem loads and prints version + run: ruby -rwreq -e "puts Wreq::VERSION" + release: name: Release - needs: [source-gem, cross-compile, native-darwin, smoke-test, smoke-test-darwin] + needs: + [ + source-gem, + native-linux, + native-darwin, + native-windows, + smoke-test, + smoke-test-darwin, + smoke-test-windows, + ] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') permissions: @@ -194,7 +300,7 @@ jobs: - uses: actions/download-artifact@v8 with: path: pkg/ - pattern: "{cross-gem-*,native-gem-*,source-gem}" + pattern: "{native-gem-*,source-gem}" merge-multiple: true - name: List gems diff --git a/README.md b/README.md index f21cdc8..4f2b22b 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ gem "wreq" ``` Pre-compiled native gems are available for: + - Linux (x86_64, aarch64) - macOS (arm64) - Windows (x86_64) From 1f8ff50e8b649d6d8da841be31861755482d6ffc Mon Sep 17 00:00:00 2001 From: gngpp Date: Wed, 8 Jul 2026 07:08:33 +0800 Subject: [PATCH 2/2] Add macOS tests to CI --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fefbffa..852e1b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,37 @@ jobs: - name: Run tests run: bundle exec rake test + macos-tests: + name: macOS Tests (macos-latest, ${{ matrix.ruby }}) + runs-on: macos-latest + env: + HTTPBIN_URL: https://httpbin.io + strategy: + fail-fast: false + matrix: + ruby: ['3.3', '3.4', '4.0'] + + steps: + - uses: actions/checkout@v7 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Install dependencies + run: bundle install + + - name: Compile native extension + run: bundle exec rake compile + + - name: Run tests + run: bundle exec rake test + windows-gnu-tests: name: Windows Tests (windows-latest, ${{ matrix.ruby }}) runs-on: windows-latest