diff --git a/.github/workflows/release_nightly.yml b/.github/workflows/release_nightly.yml index 76c96967d878..c36b4eb0b7dd 100644 --- a/.github/workflows/release_nightly.yml +++ b/.github/workflows/release_nightly.yml @@ -193,7 +193,7 @@ jobs: build-mac-universal-binary: name: Build macOS universal binary - needs: [create-nightly-release, build, build-web] + needs: [create-nightly-release, build, build-browser-extensions] runs-on: macos-14 env: PACKAGE_FILE: ${{ needs.create-nightly-release.outputs.package_prefix }}-macos-universal.tar.gz @@ -311,8 +311,11 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build-web: - name: Build web${{ matrix.demo && ' demo' || '' }} + # The first couple steps of this and the `build-web-demo-and-selfhosted` job + # (tool setup and dependency install) are identical. Hopefully in the future + # https://github.com/actions/runner/issues/1182 can help deduplicate them. + build-browser-extensions: + name: Build browser extensions needs: create-nightly-release if: needs.create-nightly-release.outputs.is_active == 'true' runs-on: ubuntu-24.04 @@ -324,9 +327,6 @@ jobs: id-token: write pull-requests: read statuses: write - strategy: - matrix: - demo: [false, true] steps: - name: Clone Ruffle repo uses: actions/checkout@v4 @@ -362,8 +362,7 @@ jobs: - name: Install node packages working-directory: web shell: bash -l {0} - run: | - npm ci + run: npm ci - name: Seal version data shell: bash -l {0} @@ -377,8 +376,7 @@ jobs: - name: Build web env: BUILD_ID: ${{ github.run_number }} - # Build web demo with WebGPU support for testing in Chrome origin trial on ruffle.rs - CARGO_FEATURES: jpegxr${{ matrix.demo && ',webgpu' || '' }} + CARGO_FEATURES: jpegxr FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }} # Needed to inject into manifest.json WASM_SOURCE: cargo_and_store working-directory: web @@ -386,14 +384,12 @@ jobs: run: npm run build:repro - name: Produce reproducible source archive - if: ${{ !matrix.demo }} shell: bash -l {0} run: | zip -r reproducible-source.zip . -x '/web/node_modules/*' '/web/*/node_modules/*' '/web/packages/*/dist/*' '/web/docker/docker_builds/packages/*' '/target/*' '/.git/*' '/tests/tests/swfs/*' cp reproducible-source.zip "${{ needs.create-nightly-release.outputs.package_prefix }}-reproducible-source.zip" - name: Upload reproducible source archive - if: ${{ !matrix.demo }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} @@ -402,36 +398,7 @@ jobs: package_file="${{ needs.create-nightly-release.outputs.package_prefix }}-reproducible-source.zip" gh release upload "$tag_name" "$package_file" - - name: Build web docs - working-directory: web - run: npm run docs - - - name: Publish npm package - if: ${{ !matrix.demo }} - # npm scoped packages are private by default, explicitly make public - run: npm publish --access public --provenance - continue-on-error: true - working-directory: web/packages/selfhosted/dist - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Package selfhosted - if: ${{ !matrix.demo }} - run: zip -r "${{ needs.create-nightly-release.outputs.package_prefix }}-web-selfhosted.zip" . - working-directory: web/packages/selfhosted/dist - - - name: Upload selfhosted - if: ${{ !matrix.demo }} - run: | - tag_name="${{ needs.create-nightly-release.outputs.tag_name }}" - package_file="${{ needs.create-nightly-release.outputs.package_prefix }}-web-selfhosted.zip" - gh release upload "$tag_name" "$package_file" - working-directory: web/packages/selfhosted/dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload generic extension - if: ${{ !matrix.demo }} run: | tag_name="${{ needs.create-nightly-release.outputs.tag_name }}" package_file="${{ needs.create-nightly-release.outputs.package_prefix }}-web-extension.zip" @@ -442,14 +409,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload Safari build artifact - if: ${{ !matrix.demo }} uses: actions/upload-artifact@v4 with: name: macos-safari path: ./web/packages/extension/dist/ruffle_extension.zip - name: Upload Firefox extension (unsigned) - if: ${{ !matrix.demo }} run: | tag_name="${{ needs.create-nightly-release.outputs.tag_name }}" package_file="${{ needs.create-nightly-release.outputs.package_prefix }}-web-extension-firefox-unsigned.xpi" @@ -460,7 +425,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish Chrome extension - if: env.CHROME_EXTENSION_ID != '' && !matrix.demo + if: env.CHROME_EXTENSION_ID != '' id: publish-chrome-extension continue-on-error: true env: @@ -474,7 +439,7 @@ jobs: file-path: ./web/packages/extension/dist/ruffle_extension.zip - name: Publish Edge extension - if: env.EDGE_PRODUCT_ID != '' && !matrix.demo + if: env.EDGE_PRODUCT_ID != '' id: publish-edge-extension continue-on-error: true env: @@ -486,46 +451,103 @@ jobs: client-id: ${{ secrets.EDGE_CLIENT_ID }} api-key: ${{ secrets.EDGE_API_KEY }} - - name: Clone web demo - if: matrix.demo + build-web-demo-and-selfhosted: + name: Build web demo and selfhosted package with docs + needs: create-nightly-release + if: needs.create-nightly-release.outputs.is_active == 'true' + runs-on: ubuntu-24.04 + permissions: + actions: read + attestations: write + checks: read + contents: write + id-token: write + pull-requests: read + statuses: write + steps: + - name: Clone Ruffle repo uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable with: - repository: ruffle-rs/demo - path: demo - ref: master - fetch-depth: 0 - persist-credentials: false # Needed to allow commit via RUFFLE_BUILD_TOKEN below + toolchain: stable + targets: wasm32-unknown-unknown + components: rust-src - - name: Update web demo - if: matrix.demo - run: | - # Delete the old build. - rm -fr * + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + registry-url: https://registry.npmjs.org - # Copy the fresh build into this folder. - cp -fr ../web/packages/demo/dist/* . + # wasm-bindgen-cli version must match wasm-bindgen crate version. + # Be sure to update in test_web.yml, Cargo.toml, web/docker/Dockerfile, + # and web/README.md as well. + - name: Install wasm-bindgen + run: cargo install wasm-bindgen-cli --version 0.2.100 - # Restore our custom swfs - git restore swfs swfs.json + # Keep the version number in sync in all workflows, + # and in the extension builder Dockerfile! + - name: Install wasm-opt + uses: sigoden/install-binary@v1 + with: + repo: WebAssembly/binaryen + tag: version_123 + name: wasm-opt - # Create git commit. Amend previous commit to avoid daily commit spam. - git config user.name "RuffleBuild" - git config user.email "ruffle@ruffle.rs" - git add -A - git commit --amend -m "Nightly build ${{ needs.create-nightly-release.outputs.date }}" - working-directory: demo + - name: Install node packages + working-directory: web + shell: bash -l {0} + run: npm ci - - name: Push web demo - if: github.repository == 'ruffle-rs/ruffle' && matrix.demo - uses: ad-m/github-push-action@master - with: - repository: ruffle-rs/demo - github_token: ${{ secrets.RUFFLE_BUILD_TOKEN }} - directory: demo - force: true + - name: Seal version data + shell: bash -l {0} + working-directory: web + env: + BUILD_ID: ${{ github.run_number }} + ENABLE_VERSION_SEAL: "true" + FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }} # Needed to inject into manifest.json + run: npm run version-seal + + - name: Build web + env: + BUILD_ID: ${{ github.run_number }} + # NOTE: In the future, we might want to enable some features (like `webgpu`) only in + # the demo build, for limited testing (like a Chrome origin trial) on ruffle.rs. + CARGO_FEATURES: jpegxr + FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }} # Needed to inject into manifest.json + WASM_SOURCE: cargo_and_store + working-directory: web + shell: bash -l {0} + run: npm run build:repro + + - name: Build web docs + working-directory: web + run: npm run docs + + - name: Publish npm package + # npm scoped packages are private by default, explicitly make public + run: npm publish --access public --provenance + continue-on-error: true + working-directory: web/packages/selfhosted/dist + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Package selfhosted + run: zip -r "${{ needs.create-nightly-release.outputs.package_prefix }}-web-selfhosted.zip" . + working-directory: web/packages/selfhosted/dist + + - name: Upload selfhosted + run: | + tag_name="${{ needs.create-nightly-release.outputs.tag_name }}" + package_file="${{ needs.create-nightly-release.outputs.package_prefix }}-web-selfhosted.zip" + gh release upload "$tag_name" "$package_file" + working-directory: web/packages/selfhosted/dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Clone JS docs - if: ${{ !matrix.demo }} uses: actions/checkout@v4 with: repository: ruffle-rs/js-docs @@ -535,7 +557,6 @@ jobs: persist-credentials: false # Needed to allow commit via RUFFLE_BUILD_TOKEN below - name: Update JS docs - if: ${{ !matrix.demo }} run: | # Delete the old docs rm -rf master/ @@ -551,7 +572,7 @@ jobs: working-directory: js-docs - name: Push JS docs - if: github.repository == 'ruffle-rs/ruffle' && !matrix.demo + if: github.repository == 'ruffle-rs/ruffle' uses: ad-m/github-push-action@master with: repository: ruffle-rs/js-docs @@ -559,6 +580,42 @@ jobs: directory: js-docs force: true + - name: Clone web demo + uses: actions/checkout@v4 + with: + repository: ruffle-rs/demo + path: demo + ref: master + fetch-depth: 0 + persist-credentials: false # Needed to allow commit via RUFFLE_BUILD_TOKEN below + + - name: Update web demo + run: | + # Delete the old build. + rm -fr * + + # Copy the fresh build into this folder. + cp -fr ../web/packages/demo/dist/* . + + # Restore our custom swfs + git restore swfs swfs.json + + # Create git commit. Amend previous commit to avoid daily commit spam. + git config user.name "RuffleBuild" + git config user.email "ruffle@ruffle.rs" + git add -A + git commit --amend -m "Nightly build ${{ needs.create-nightly-release.outputs.date }}" + working-directory: demo + + - name: Push web demo + if: github.repository == 'ruffle-rs/ruffle' + uses: ad-m/github-push-action@master + with: + repository: ruffle-rs/demo + github_token: ${{ secrets.RUFFLE_BUILD_TOKEN }} + directory: demo + force: true + publish-aur-package: name: Publish AUR package needs: [create-nightly-release, build] diff --git a/web/README.md b/web/README.md index 02bbca1026bf..b2d7066eeddd 100644 --- a/web/README.md +++ b/web/README.md @@ -105,8 +105,9 @@ In this project, you may run the following commands to build all packages: - You may also use `npm run build:debug` to disable Webpack optimizations and activate the (extremely verbose) ActionScript debugging output. - There is `npm run build:dual-wasm` as well, to build a second WebAssembly module that disables all supported WebAssembly extensions, potentially resulting in support for more browsers, at the expense of longer build time. - - `npm run build:repro` enables reproducible builds. Note that this also requires a `version_seal.json`, which is not provided in the normal Git repository - only specially-marked reproducible source archives. Running this without a version seal will generate one based on the current state of your environment. - - You will also need to run `rustup component add rust-src` with either of the previous two commands since we rebuild std for the vanilla WASM module. + - `npm run build:repro` enables reproducible builds with the default WASM module. Note that this also requires a `version_seal.json`, which is not provided in the normal Git repository - only specially-marked reproducible source archives. Running this without a version seal will generate one based on the current state of your environment. + - `npm run build:dual-wasm-repro` enables reproducible builds with both WASM modules. Note that this also requires a `version_seal.json`, which is not provided in the normal Git repository - only specially-marked reproducible source archives. Running this without a version seal will generate one based on the current state of your environment. + - You will also need to run `rustup component add rust-src` with either of the dual-wasm commands since we rebuild std for the vanilla WASM module. From here, you may follow the instructions to [use Ruffle on your website](packages/selfhosted/README.md), run a demo locally with `npm run demo`, or [install the extension in your browser](https://github.com/ruffle-rs/ruffle/wiki/Using-Ruffle#browser-extension). diff --git a/web/package.json b/web/package.json index e898a2f4a2ab..7970019c4342 100644 --- a/web/package.json +++ b/web/package.json @@ -45,7 +45,8 @@ "build": "npm run build --workspace=ruffle-core && npm run build --workspace=ruffle-demo --workspace=ruffle-extension --workspace=ruffle-selfhosted", "build:debug": "cross-env NODE_ENV=development CARGO_FEATURES=avm_debug npm run build", "build:dual-wasm": "cross-env BUILD_WASM_MVP=true npm run build", - "build:repro": "cross-env BUILD_WASM_MVP=true ENABLE_VERSION_SEAL=true npm run build", + "build:repro": "cross-env ENABLE_VERSION_SEAL=true npm run build", + "build:dual-wasm-repro": "cross-env BUILD_WASM_MVP=true ENABLE_VERSION_SEAL=true npm run build", "demo": "npm run preview --workspace ruffle-demo", "test": "npm test --workspaces --if-present", "wdio": "npm run wdio --workspaces --if-present --",