Skip to content

Commit 0e2cb1d

Browse files
committed
update
1 parent fccc90b commit 0e2cb1d

File tree

8 files changed

+59
-10
lines changed

8 files changed

+59
-10
lines changed

.github/workflows/publish.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish a Wasm Component to GitHub Artifacts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
run-tests:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v2
19+
20+
- name: Run build script
21+
run: bash scripts/build.sh
22+
23+
- name: Run publish script
24+
run: bash scripts/publish.sh

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "hello-wasi-http"
2+
name = "rust-wasi-hello"
33
version = "0.0.0"
44
edition = "2021"
55
publish = false
@@ -8,7 +8,7 @@ publish = false
88
crate-type = ["cdylib"]
99

1010
[package.metadata.component]
11-
package = "component:hello-wasi-http"
11+
package = "component:rust-wasi-hello"
1212
# This tells cargo-component to use a special adapter, which doesn't depend on
1313
# `get-environment` or other things not present in the proxy world.
1414
proxy = true

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ information on building Wasm components from different languages, check [here]!
2020
With that, build the Wasm component from source in this repository:
2121
```sh
2222
$ cargo component build
23-
Compiling hello-wasi-http v0.0.0 (/home/wasm/hello-wasi-http)
23+
Compiling rust-wasi-hello v0.0.0 (/home/wasm/rust-wasi-hello)
2424
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.01s
2525
Creating component target/wasm32-wasip1/debug/hello_wasi_http.wasm
2626
```
@@ -90,11 +90,11 @@ Here are my notes on how I created this repository, in case you're interested in
9090
To create a new project, run:
9191

9292
```sh
93-
$ cargo component new --proxy --lib hello-wasi-http
94-
Created binary (application) `hello-wasi-http` package
95-
Updated manifest of package `hello-wasi-http`
93+
$ cargo component new --proxy --lib rust-wasi-hello
94+
Created binary (application) `rust-wasi-hello` package
95+
Updated manifest of package `rust-wasi-hello`
9696
Generated source file `src/main.rs`
97-
$ cd hello-wasi-http
97+
$ cd rust-wasi-hello
9898
```
9999

100100
Copy the `wit` directory from your version of Wasmtime, to ensure that we're using the same version of the API that

scripts/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# install cargo-component
4+
cargo install cargo-component
5+
6+
# build our project
7+
cargo component build --release

scripts/publish.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# setup dir
4+
mkdir -p tmp
5+
cd tmp
6+
7+
# install wkg
8+
git clone https://github.com/bytecodealliance/wasm-pkg-tools
9+
cd wasm-pkg-tools
10+
cargo install --path .
11+
12+
# login to the registry
13+
gh auth token | docker login ghcr.io --username YOURUSER --password-stdin
14+
15+
# publish using wkg
16+
PROJECT_NAME="rust_wasi_hello"
17+
REGISTRY_REFERENCE="ghcr.io/yoshuawuyts/rust-wasi-hello:latest"
18+
wkg oci push $REGISTRY_REFERENCE target/wasm32-wasip1/release/$PROJECT_NAME.wasm

src/bindings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8490,7 +8490,7 @@ now\x01\x02\x04\0\x0aresolution\x01\x02\x03\x01\x1cwasi:clocks/[email protected]\
84908490
\x02\x03\x02\x01\x14\x04\0\x10incoming-request\x03\0\0\x02\x03\x02\x01\x15\x04\0\
84918491
\x11response-outparam\x03\0\x02\x01i\x01\x01i\x03\x01@\x02\x07request\x04\x0cres\
84928492
ponse-out\x05\x01\0\x04\0\x06handle\x01\x06\x04\x01\x20wasi:http/incoming-handle\
8493-
[email protected]\x05\x16\x04\x01(sunfishcode:hello-wasi-http/target-world\x04\0\x0b\x12\x01\
8493+
[email protected]\x05\x16\x04\x01(sunfishcode:rust-wasi-hello/target-world\x04\0\x0b\x12\x01\
84948494
\0\x0ctarget-world\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-compon\
84958495
ent\x070.208.1\x10wit-bindgen-rust\x060.25.0";
84968496

wit/world.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package sunfishcode:hello-wasi-http;
1+
package sunfishcode:rust-wasi-hello;
22

33
world target-world {
44
include wasi:http/proxy@0.2.0;

0 commit comments

Comments
 (0)