TEMPORARY: run on push to this branch #1
Workflow file for this run
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: Build gems | |
| # Builds both gems of a release and uploads them as artifacts, without publishing | |
| # anything. Pick the branch or tag to build from in the "Run workflow" dialog. | |
| # | |
| # | Gem | Platform | Parser | | |
| # | -------------------- | ------------- | ---------------------------- | | |
| # | `rbs-X.Y.Z.gem` | `ruby` (MRI) | C extension, compiled on install | | |
| # | `rbs-X.Y.Z-java.gem` | `java` (JRuby)| `rbs_parser.wasm`, prebuilt here | | |
| # | |
| # See docs/release.md. The `java` gem is built on CRuby: the platform comes from | |
| # `RBS_PLATFORM`, not from the engine running `gem build`, so the only thing JRuby | |
| # would add is the ability to run the result. | |
| on: | |
| workflow_dispatch: | |
| # TEMPORARY: remove before merging. `workflow_dispatch` only shows up in the | |
| # Actions UI once the file is on the default branch, so this is the only way | |
| # to exercise the workflow from the pull request. | |
| push: | |
| branches: | |
| - build-gems-workflow | |
| permissions: | |
| contents: read | |
| env: | |
| # Keep in sync with .github/workflows/wasm.yml and .github/workflows/jruby.yml. | |
| WASI_SDK_VERSION: "33" | |
| WASI_SDK_RELEASE: "33.0" | |
| jobs: | |
| ruby: | |
| name: ruby gem | |
| runs-on: ubuntu-latest | |
| steps: | |
| # The gemspec takes its file list from `git ls-files`, so the gem is built | |
| # from the committed state -- no compilation, and nothing from the runner. | |
| - uses: actions/checkout@v7 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ruby | |
| bundler: none | |
| - name: Update rubygems & bundler | |
| run: gem update --system | |
| - name: Build the gem | |
| run: | | |
| version=$(ruby -e 'load "lib/rbs/version.rb"; print RBS::VERSION') | |
| mkdir -p pkg | |
| gem build rbs.gemspec -o "pkg/rbs-${version}.gem" | |
| - name: Check the built gem | |
| run: | | |
| ruby -rrubygems/package -e ' | |
| spec = Gem::Package.new(ARGV[0]).spec | |
| raise "unexpected platform: #{spec.platform}" unless spec.platform.to_s == "ruby" | |
| raise "the C extension is not declared" if spec.extensions.empty? | |
| puts "#{spec.full_name}: #{spec.files.size} files, extensions: #{spec.extensions.join(", ")}" | |
| ' pkg/*.gem | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: gem-ruby | |
| path: pkg/*.gem | |
| if-no-files-found: error | |
| java: | |
| name: java gem | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ruby | |
| bundler: none | |
| - name: Update rubygems & bundler | |
| run: gem update --system | |
| - name: Install gems | |
| run: | | |
| bundle config set --local without libs:profilers | |
| bundle install --jobs 4 --retry 3 | |
| # `rake wasm:jruby_setup` compiles src/**/*.c to WebAssembly and copies the | |
| # result to lib/rbs/wasm/, where the gemspec picks it up. clang runs as a | |
| # subprocess, so this works on CRuby. | |
| - name: Install the WASI SDK | |
| run: | | |
| url="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_RELEASE}-x86_64-linux.tar.gz" | |
| mkdir -p "$HOME/wasi-sdk" | |
| curl -sSL "$url" | tar xz --strip-components=1 -C "$HOME/wasi-sdk" | |
| echo "WASI_SDK_PATH=$HOME/wasi-sdk" >> "$GITHUB_ENV" | |
| - name: Build rbs_parser.wasm | |
| run: bundle exec rake wasm:jruby_setup | |
| - name: Build the gem | |
| env: | |
| RBS_PLATFORM: java | |
| run: | | |
| version=$(ruby -e 'load "lib/rbs/version.rb"; print RBS::VERSION') | |
| mkdir -p pkg | |
| gem build rbs.gemspec -o "pkg/rbs-${version}-java.gem" | |
| # rbs_parser.wasm is a build artifact rather than a tracked file, so it is | |
| # the one thing `git ls-files` cannot vouch for. | |
| - name: Check the built gem | |
| run: | | |
| ruby -rrubygems/package -e ' | |
| spec = Gem::Package.new(ARGV[0]).spec | |
| raise "unexpected platform: #{spec.platform}" unless spec.platform.to_s == "java" | |
| raise "rbs_parser.wasm is missing" unless spec.files.include?("lib/rbs/wasm/rbs_parser.wasm") | |
| raise "the java gem must not declare an extension" unless spec.extensions.empty? | |
| puts "#{spec.full_name}: #{spec.files.size} files" | |
| ' pkg/*.gem | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: gem-java | |
| path: pkg/*.gem | |
| if-no-files-found: error |