Merge pull request #562 from mame/add-have_devel-for-static-build #1797
This file contains 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 ruby.wasm | |
on: | |
push: | |
branches: [main] | |
tags: ["*"] | |
paths-ignore: | |
- "*.md" | |
- "docs/**" | |
pull_request: | |
workflow_call: | |
inputs: | |
publish: | |
type: boolean | |
description: "Whether to publish or not" | |
default: true | |
prerel_name: | |
type: string | |
description: "Pre-release name to be released" | |
required: true | |
secrets: | |
NODE_AUTH_TOKEN: | |
required: true | |
jobs: | |
lint: | |
runs-on: ubuntu-20.04 | |
if: ${{ github.event_name == 'pull_request' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "head" | |
bundler-cache: true | |
- run: ./bin/setup | |
- run: bundle exec rake check:type | |
- run: sudo apt-get install clang-format | |
- run: ./bin/clang-format-diff.sh | |
- run: bundle exec rake check:bindgen | |
- run: git diff --exit-code | |
build-builder-image: | |
strategy: | |
fail-fast: false | |
matrix: | |
entry: | |
- { target: wasm32-unknown-wasip1 } | |
- { target: wasm32-unknown-emscripten } | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/login-action@v3 | |
with: | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
registry: ghcr.io | |
- uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
images: ghcr.io/${{ github.repository_owner }}/ruby.wasm/builder/${{ matrix.entry.target }} | |
- uses: docker/build-push-action@v5 | |
with: | |
context: builders/${{ matrix.entry.target }} | |
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-rake-task-matrix: | |
runs-on: ubuntu-20.04 | |
outputs: | |
entries: ${{ steps.set-matrix.outputs.entries }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "head" | |
bundler-cache: true | |
- run: ./bin/setup | |
- run: rake ci:pin_build_manifest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build-manifest | |
path: build_manifest.json | |
- name: Set matrix | |
id: set-matrix | |
run: | | |
rake ci:rake_task_matrix | |
echo "entries=$(cat ci_matrix.json)" >> $GITHUB_OUTPUT | |
rake-tasks: | |
strategy: | |
fail-fast: false | |
matrix: | |
entry: ${{ fromJson(needs.build-rake-task-matrix.outputs.entries) }} | |
needs: [build-rake-task-matrix] | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build-manifest | |
- uses: actions/[email protected] | |
if: ${{ matrix.entry.rubies_cache_key != null }} | |
with: | |
path: ./rubies | |
key: ${{ matrix.entry.rubies_cache_key }} | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/build-push-action@v5 | |
id: builder-image | |
env: | |
DOCKER_BUILD_NO_SUMMARY: true | |
with: | |
context: builders/${{ matrix.entry.builder }} | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Setup builder container | |
run: | | |
docker run -dit -v "$GITHUB_WORKSPACE:/home/me/build" -w /home/me/build \ | |
-e "ENABLE_GITHUB_ACTIONS_MARKUP=true" \ | |
-e "RUBYWASM_UID=$(id -u)" -e "RUBYWASM_GID=$(id -g)" \ | |
-e "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" \ | |
--name builder \ | |
${{ steps.builder-image.outputs.imageid }} /bin/sh | |
echo 'docker exec -u me builder "$@"' > ./build-exec | |
chmod +x ./build-exec | |
# wait for docker exec to be ready | |
timeout 10 bash -c 'until ./build-exec bundle config set --local without check; do sleep 1; done' | |
- run: ./build-exec ./bin/setup | |
- run: ./build-exec bundle exec rake compile | |
- name: Pre-release configuration | |
run: ./build-exec bundle exec rake ${{ matrix.entry.prerelease }}[${{ inputs.prerel_name }}] | |
if: ${{ inputs.prerel_name != '' && matrix.entry.prerelease != '' }} | |
- name: rake ${{ matrix.entry.task }} | |
run: ./build-exec rake --verbose ${{ matrix.entry.task }} | |
- uses: actions/upload-artifact@v4 | |
if: ${{ matrix.entry.artifact }} | |
with: | |
name: ${{ matrix.entry.artifact_name }} | |
path: ${{ matrix.entry.artifact }} | |
- uses: ruby/setup-ruby@v1 | |
if: ${{ matrix.entry.test != '' }} | |
with: | |
ruby-version: "head" | |
bundler-cache: false | |
- name: rake ${{ matrix.entry.test }} | |
run: | | |
bundle install --with=check --without=development | |
rake ${{ matrix.entry.test }} | |
if: ${{ matrix.entry.test != '' }} | |
release-artifacts: | |
needs: [rake-tasks] | |
runs-on: ubuntu-20.04 | |
if: ${{ startsWith(github.ref, 'refs/tags/') || inputs.publish }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build-manifest | |
- uses: actions/download-artifact@v4 | |
with: | |
path: release | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
registry-url: https://registry.npmjs.org/ | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "head" | |
bundler-cache: true | |
- run: ./bin/setup | |
- run: echo "PREREL_NAME=${{ inputs.prerel_name }}" >> $GITHUB_ENV | |
- run: bundle exec rake "ci:publish[${PREREL_NAME:-$GITHUB_REF_NAME}]" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} |