Skip to main content

Interact with WebAssembly registries.

Project description

wasm-action

Wasm-action facilitates the creation, distribution and generic utilization of non-browser based WebAssembly workloads through a local-first approach with a focus on privacy and security. Written primarily in Python, it also explores the Python ecosystem's maturity for WebAssembly and beyond.

Features

  • Versatile use as GitHub action, CLI or Python library.
  • Supported registry types: warg (wa.dev)
  • Supported artifact types: wasm
  • Supported actions: push, pull
  • Supports Python 3.10+ on Linux, MacOS and Windows
  • Python sandbox using wasm build of cpython 3.14

Planned

  • OCI registry support (a.k.a. Docker registry)
  • Convert between formats (wit/wasm)

Usage

Pull from registry

      - uses: xelato/wasm-action@main
        with:
          action: pull
          registry: wa.dev
          package: component-book:adder

To pull a private package, define your token:

        env:
          WARG_TOKEN: ${{ secrets.WARG_TOKEN }}
Inputs
Name Description Required Example
action Pull from registry yes pull
registry Registry domain name yes wa.dev
package Package specification yes namespace:name@version
namespace:name
namespace/name
namespace/name@version
path Target path to save the download no file.wasm
Outputs
Name Description Example
registry Registry domain name wa.dev
registry-type Detected registry type warg
package Package foo:bar@1.2.3
package-namespace Package namespace foo
package-name Package name bar
package-version Package version 1.2.3
filename Download location foo-bar_1.2.3.wasm
digest File hash sha256:2afffac0...

Push to registry

      - uses: xelato/wasm-action@main
        with:
          action: push
          registry: wa.dev
          package: foo:bar@1.2.3
          path: files/foo_bar_1.2.3.wasm
        env:
          WARG_TOKEN: ${{ secrets.WARG_TOKEN }}
          WARG_PRIVATE_KEY: ${{ secrets.WARG_PRIVATE_KEY }}

CLI

The tool can be run without installing, using uv/uvx.

$ uvx wasm-action --help          
Usage: wasm-action [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  eval     Expression evaluator
  key      Generate private key or read one from stdin
  pull     Pull from registry
  push     Push to registry
  python   Python in a sandbox
  version  Print version
  x        Run a WebAssembly file
Pull from registry
$ uvx wasm-action pull --registry wa.dev --package wasi:io
registry=wa.dev
registry-type=warg
warg-url=https://warg.wa.dev
package=wasi:io@0.2.0
package-namespace=wasi
package-name=io
package-version=0.2.0
digest=sha256:c33b1dbf050f64229ff4decbf9a3d3420e0643a86f5f0cea29f81054820020a6
filename=wasi:io@0.2.0.wasm
$ file wasi:io@0.2.0.wasm 
wasi:io@0.2.0.wasm: WebAssembly (wasm) binary module version 0x1000d
Push to registry
$ export WARG_TOKEN="..."
$ export WARG_PRIVATE_KEY="..."
$ uvx wasm-action push -r wa.dev -p foo:bar@1.2.3 --path foo_bar_1.2.3.wasm
Key generation

New token registration and push to wa.dev require generation and configuration of a private/public key pair which can be facilitated with:

$ uvx wasm-action key
{
    "private": "ecdsa-p256:9y5nigLvFp3KZZQtuvN9DchpGIMUB4bwGAtkIoOCla4=",
    "public": "ecdsa-p256:AvspSQWBK65ItTou/uVCi5qC4P+HBCi4R34OIPb3ILRl",
    "id": "sha256:c836bd8a3082f2e8d70bdfa48296e580ab847fcdeadb351f448d03f152d44093"
}
# use private key to configure in github or save it elsewhere in a secure manner
$ uvx wasm-action key | jq .private | pbcopy
# use corresponding public key for new token registration at wa.dev
$ pbpaste | uvx wasm-action key | jq .public

Use as Library

The package is published to the Python Package Index and can be installed/depended-on under the name wasm-action on all supported Python versions.

$ pip install wasm-action
>>> import wasm_action as wa
>>> wa.pull('wa.dev', 'wasi:io')
PackageDownload(namespace='wasi', name='io', version='0.2.0', content='...', digest='sha256:c33b1dbf050f64229ff4decbf9a3d3420e0643a86f5f0cea29f81054820020a6')

However, the library interface is not yet standardised and may (and will!) change.

Python Sandbox

Experimental support for running a WASI build of python/cpython@3.14.

$ uvx --python 3.14 wasm-action python --version
Python 3.14.2+

Host Python

The Python interpreter used to run wasm-action. It orchestrates and mediates the guest Python execution under a supported WebAssembly Runtime (wasmtime).

Guest Python

The CPython interpreter that was compiled to WebAssembly. Guest Python runs in a restricted "sandbox" environment. In addition to the .wasm module file, it also requires the Python standard library folder, currently being reused from the host Python installation.

Layout

Guest code has access to the following paths:

  • / - host's current working directory (read/write)
  • /usr/local/lib/python3.14 - host Python's stdlib (read only)
  • /tmp (read/write)

Environment variables

Code running in the guest environment only has access to the environment variables explicitly defined:

>>> import os
>>> os.environ
environ({'PYTHONPATH': '/usr/local/lib/python3.14:/build'})

Limitations

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wasm_action-0.0.10.tar.gz (48.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wasm_action-0.0.10-py3-none-any.whl (113.6 kB view details)

Uploaded Python 3

File details

Details for the file wasm_action-0.0.10.tar.gz.

File metadata

  • Download URL: wasm_action-0.0.10.tar.gz
  • Upload date:
  • Size: 48.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wasm_action-0.0.10.tar.gz
Algorithm Hash digest
SHA256 617d4029893405ea36814aaaf7ce25dee8868e6b82bfb47a9632bbefa57363da
MD5 e5b7b119a59f7837fb2235cfcc73e4fd
BLAKE2b-256 f2e969049a3feadf26898109eae29343d46f7458957f2c2e26bd50393cba4e29

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasm_action-0.0.10.tar.gz:

Publisher: release.yml on xelato/wasm-action

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wasm_action-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: wasm_action-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 113.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wasm_action-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 836533b8b0def0b89a6008beea42ae38d9f464c267062891070adb2d9a457d3f
MD5 058db43bf2da86a347baadc1432b9904
BLAKE2b-256 869396eeb41d605d2d42ddb1ae5be15aeb929e5147bf85b464ac5110b70402cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasm_action-0.0.10-py3-none-any.whl:

Publisher: release.yml on xelato/wasm-action

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page