native-gems #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: native-gems | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| build: | |
| name: ${{ matrix.platform }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: arm64-darwin-23 | |
| runner: macos-latest | |
| - platform: x86_64-linux | |
| runner: ubuntu-22.04 | |
| - platform: aarch64-linux | |
| runner: ubuntu-22.04-arm | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ruby | |
| bundler-cache: true | |
| - name: Download tessdata for build | |
| run: | | |
| mkdir -p tessdata | |
| curl -L https://github.com/tesseract-ocr/tessdata_fast/raw/main/eng.traineddata -o tessdata/eng.traineddata | |
| - name: Build native gem | |
| env: | |
| TESSDATA_PREFIX: ${{ github.workspace }}/tessdata | |
| run: | | |
| bundle exec rake native gem | |
| - name: Upload gem artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: parsekit-bin-${{ matrix.platform }} | |
| path: pkg/*${{ matrix.platform }}.gem | |
| if-no-files-found: warn | |
| publish: | |
| name: Publish gems to RubyGems | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ruby | |
| bundler-cache: true | |
| - name: Download all gem artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: parsekit-bin-* | |
| merge-multiple: true | |
| path: pkg | |
| - name: Download tessdata for build | |
| run: | | |
| mkdir -p tessdata | |
| curl -L https://github.com/tesseract-ocr/tessdata_fast/raw/main/eng.traineddata -o tessdata/eng.traineddata | |
| - name: Build universal gem | |
| env: | |
| TESSDATA_PREFIX: ${{ github.workspace }}/tessdata | |
| run: bundle exec rake build | |
| - name: Publish to RubyGems | |
| env: | |
| GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
| run: | | |
| set -euo pipefail | |
| shopt -s nullglob | |
| gems=(pkg/*.gem) | |
| if [ ${#gems[@]} -eq 0 ]; then | |
| echo "No gem files found in pkg/. Nothing to publish." | |
| exit 1 | |
| fi | |
| for gem_file in "${gems[@]}"; do | |
| echo "Pushing ${gem_file}" | |
| gem push "$gem_file" | |
| done |