This is a refactoring proposal in itself; #47
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: CI | |
| env: | |
| DEBUG: napi:* | |
| APP_NAME: webview | |
| MACOSX_DEPLOYMENT_TARGET: '10.13' | |
| CARGO_INCREMENTAL: '1' | |
| CARGO_TERM_COLOR: always | |
| permissions: | |
| contents: write | |
| id-token: write | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags-ignore: | |
| - '**' | |
| paths-ignore: | |
| - '**/*.md' | |
| - LICENSE | |
| - '**/*.gitignore' | |
| - .editorconfig | |
| - docs/** | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '**/*.md' | |
| - LICENSE | |
| - '**/*.gitignore' | |
| - .editorconfig | |
| - docs/** | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: ${{ matrix.settings.os }} - ${{ matrix.settings.target }} | |
| timeout-minutes: 60 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| # macOS | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| build_script: | | |
| export PKG_CONFIG_ALLOW_CROSS=1 | |
| bun run build --target aarch64-apple-darwin | |
| # Windows | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| - os: windows-latest | |
| target: i686-pc-windows-msvc | |
| - os: windows-latest | |
| target: aarch64-pc-windows-msvc | |
| # Linux x86_64 | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| sys_deps: pkg-config libwebkit2gtk-4.1-dev libsoup-3.0-dev libglib2.0-dev libcairo2-dev libpango1.0-dev libatk1.0-dev libgdk-pixbuf2.0-dev libgtk-3-dev | |
| # Linux ARM64 | |
| - os: ubuntu-22.04 | |
| target: aarch64-unknown-linux-gnu | |
| cross_arch: arm64 | |
| # Added X11, Wayland, and XKB dependencies required by tao/wry | |
| cross_sys_deps: >- | |
| libwebkit2gtk-4.1-dev:arm64 | |
| libsoup-3.0-dev:arm64 | |
| libgtk-3-dev:arm64 | |
| libx11-dev:arm64 | |
| libxkbcommon-dev:arm64 | |
| libwayland-dev:arm64 | |
| libxcb-shape0-dev:arm64 | |
| libxcb-xfixes0-dev:arm64 | |
| libglib2.0-dev:arm64 | |
| libcairo2-dev:arm64 | |
| libpango1.0-dev:arm64 | |
| libatk1.0-dev:arm64 | |
| libgdk-pixbuf2.0-dev:arm64 | |
| cross_gcc: gcc-aarch64-linux-gnu | |
| cross_gpp: g++-aarch64-linux-gnu | |
| cross_triplet: aarch64-linux-gnu | |
| build_script: | | |
| set -e | |
| rustup target add aarch64-unknown-linux-gnu | |
| export PKG_CONFIG_ALLOW_CROSS=1 | |
| # In Ubuntu Multiarch, the sysroot is actually / | |
| export PKG_CONFIG_SYSROOT_DIR=/ | |
| # Only use the target's pkgconfig directory to prevent host library leakage | |
| export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig | |
| export CC=aarch64-linux-gnu-gcc | |
| export CXX=aarch64-linux-gnu-g++ | |
| export AR=aarch64-linux-gnu-ar | |
| export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc | |
| bun run build --target aarch64-unknown-linux-gnu | |
| # Linux ARMv7 | |
| - os: ubuntu-22.04 | |
| target: armv7-unknown-linux-gnueabihf | |
| cross_arch: armhf | |
| # Added X11, Wayland, and XKB dependencies required by tao/wry | |
| cross_sys_deps: >- | |
| libwebkit2gtk-4.1-dev:armhf | |
| libsoup-3.0-dev:armhf | |
| libgtk-3-dev:armhf | |
| libx11-dev:armhf | |
| libxkbcommon-dev:armhf | |
| libwayland-dev:armhf | |
| libxcb-shape0-dev:armhf | |
| libxcb-xfixes0-dev:armhf | |
| libglib2.0-dev:armhf | |
| libcairo2-dev:armhf | |
| libpango1.0-dev:armhf | |
| libatk1.0-dev:armhf | |
| libgdk-pixbuf2.0-dev:armhf | |
| cross_gcc: gcc-arm-linux-gnueabihf | |
| cross_gpp: g++-arm-linux-gnueabihf | |
| cross_triplet: arm-linux-gnueabihf | |
| build_script: | | |
| set -e | |
| rustup target add armv7-unknown-linux-gnueabihf | |
| export PKG_CONFIG_ALLOW_CROSS=1 | |
| # In Ubuntu Multiarch, sysroot is / | |
| export PKG_CONFIG_SYSROOT_DIR=/ | |
| # Only use target's pkgconfig to prevent host library leakage | |
| export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig | |
| export CC=arm-linux-gnueabihf-gcc | |
| export CXX=arm-linux-gnueabihf-g++ | |
| export AR=arm-linux-gnueabihf-ar | |
| export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc | |
| bun run build --target armv7-unknown-linux-gnueabihf | |
| # Android | |
| - os: ubuntu-latest | |
| target: aarch64-linux-android | |
| - os: ubuntu-latest | |
| target: armv7-linux-androideabi | |
| runs-on: ${{ matrix.settings.os }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.settings.target || matrix.settings.rust_target }} | |
| - name: Setup Zig for cross-compilation | |
| if: matrix.settings.use_zig | |
| uses: goto-bus-stop/setup-zig@v2 | |
| with: | |
| version: 0.13.0 | |
| - name: Cache Bun dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb', '**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Cache Cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| key: ${{ matrix.settings.target }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ matrix.settings.target }}-cargo-registry- | |
| - name: Cache Cargo build | |
| uses: actions/cache@v4 | |
| with: | |
| path: target/ | |
| # Added ${{ matrix.settings.os }} to the key | |
| key: ${{ matrix.settings.os }}-${{ matrix.settings.target }}-cargo-build-${{ github.sha }} | |
| restore-keys: | | |
| ${{ matrix.settings.os }}-${{ matrix.settings.target }}-cargo-build- | |
| - name: Install system dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y pkg-config | |
| - name: Install system dependencies (Linux x86_64) | |
| if: runner.os == 'Linux' && matrix.settings.sys_deps | |
| run: | | |
| sudo apt-get install -y ${{ matrix.settings.sys_deps }} | |
| - name: Install cross-compilation dependencies (Linux ARM) | |
| if: runner.os == 'Linux' && matrix.settings.cross_arch | |
| run: | | |
| sudo dpkg --add-architecture ${{ matrix.settings.cross_arch }} | |
| # 1. Fix existing sources to be amd64-only | |
| # This handles traditional .list files (Jammy 22.04) | |
| sudo find /etc/apt/sources.list /etc/apt/sources.list.d/ -name "*.list" -type f -exec \ | |
| sudo sed -i -E 's/^(deb(-src)? )([^[])/\1[arch=amd64] \3/' {} + | |
| # This handles the new DEB822 .sources files (Noble 24.04+) | |
| # It adds "Architectures: amd64" to blocks that don't have it | |
| sudo find /etc/apt/sources.list.d/ /etc/apt/ -name "*.sources" -type f -exec \ | |
| sudo sh -c 'grep -q "Architectures:" "$1" || sed -i "/^Types: deb/a Architectures: amd64" "$1"' _ {} \; | |
| # 2. Add the Ports repository for the cross-architecture | |
| CODENAME=$(lsb_release -sc) | |
| echo "deb [arch=${{ matrix.settings.cross_arch }}] http://ports.ubuntu.com/ubuntu-ports $CODENAME main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/ports.list | |
| echo "deb [arch=${{ matrix.settings.cross_arch }}] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports.list | |
| echo "deb [arch=${{ matrix.settings.cross_arch }}] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports.list | |
| # 3. Update and install | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| ${{ matrix.settings.cross_gcc }} \ | |
| ${{ matrix.settings.cross_gpp }} \ | |
| ${{ matrix.settings.cross_sys_deps }} | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build | |
| run: ${{ matrix.settings.build_script || format('bun run build --target {0}', matrix.settings.target) }} | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: ${{ env.APP_NAME }}.*.node | |
| if-no-files-found: error | |
| retention-days: 7 | |
| # build-freebsd: | |
| # runs-on: ubuntu-latest | |
| # name: Build FreeBSD | |
| # timeout-minutes: 90 | |
| # steps: | |
| # - uses: actions/checkout@v4 | |
| # - name: Build | |
| # id: build | |
| # uses: cross-platform-actions/action@v0.25.0 | |
| # env: | |
| # DEBUG: napi:* | |
| # RUSTUP_IO_THREADS: 1 | |
| # with: | |
| # operating_system: freebsd | |
| # version: '14.0' | |
| # memory: 8G | |
| # cpu_count: 3 | |
| # environment_variables: 'DEBUG RUSTUP_IO_THREADS' | |
| # shell: bash | |
| # run: | | |
| # sudo pkg install -y -f curl node libnghttp2 npm pkg-config | |
| # sudo npm install -g bun --ignore-scripts | |
| # curl https://sh.rustup.rs -sSf --output rustup.sh | |
| # sh rustup.sh -y --profile minimal --default-toolchain beta | |
| # source "$HOME/.cargo/env" | |
| # echo "~~~~ rustc --version ~~~~" | |
| # rustc --version | |
| # echo "~~~~ node -v ~~~~" | |
| # node -v | |
| # echo "~~~~ bun --version ~~~~" | |
| # bun --version | |
| # pwd | |
| # ls -lah | |
| # whoami | |
| # env | |
| # freebsd-version | |
| # bun install | |
| # bun run build | |
| # rm -rf node_modules | |
| # rm -rf target | |
| # rm -rf .bun/cache | |
| # - name: Upload artifact | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: bindings-freebsd | |
| # path: ${{ env.APP_NAME }}.*.node | |
| # if-no-files-found: error | |
| # retention-days: 7 | |
| publish: | |
| name: Publish to npm | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| needs: | |
| - build | |
| # - build-freebsd | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Move artifacts | |
| run: bun run artifacts | |
| - name: List packages | |
| run: ls -R ./npm | |
| shell: bash | |
| - name: Extract version from commit message | |
| id: version | |
| run: | | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| if echo "$COMMIT_MSG" | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+$"; then | |
| echo "is_release=true" >> $GITHUB_OUTPUT | |
| echo "tag=latest" >> $GITHUB_OUTPUT | |
| elif echo "$COMMIT_MSG" | grep -qE "^[0-9]+\.[0-9]+\.[0-9]"; then | |
| echo "is_release=true" >> $GITHUB_OUTPUT | |
| echo "tag=next" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to npm | |
| if: steps.version.outputs.is_release == 'true' | |
| run: | | |
| npm config set provenance true | |
| npm publish --access public --tag ${{ steps.version.outputs.tag }} | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Skip publish (not a release) | |
| if: steps.version.outputs.is_release == 'false' | |
| run: | | |
| echo "Not a release commit, skipping publish" |