Skip to content

Commit

Permalink
Merge pull request #1 from kokamkarsahil/main
Browse files Browse the repository at this point in the history
[FEAT] Builds using github actions
  • Loading branch information
juntao committed May 3, 2023
2 parents 04af2f6 + cc4dd2e commit ebbbf7a
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 32 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release
on:
push:
branches:
- main
tags:
- v*

jobs:
build:
name: WASM examples
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-wasi
- uses: actions-rs/cargo@v1
with:
command: build
args: --target wasm32-wasi --release

- name: Upload Artifacts
id: upload-artifacts
uses: actions/upload-artifact@v3
with:
name: Artifacts
path: |
target/wasm32-wasi/release/*.wasm
if-no-files-found: error


- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Wasm Edge Build Files
draft: false
prerelease: false
- uses: xresloader/upload-to-github-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "target/wasm32-wasi/release/*.wasm"
release_id: ${{ steps.create_release.outputs.id }}
overwrite: true
verbose: true
21 changes: 21 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[workspace]

members = [
"control",
"function",
"hello",
"move",
"server",
"string",
"struct",
"wasi",
]

[workspace.package]

version = "0.1.0"
authors = ["Michael Yuan <michael@secondstate.io>"]
description = "Example Files for WasmEdge"
homepage = "https://wasmedge.org"
documentation = "https://wasmedge.org/docs/"
edition = "2018"
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ rustup target add wasm32-wasi
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | sudo bash -s -- -p /usr/local
```

**Note**: Running `cargo build` in any package directory the output will get stored at parent directory of folder because of Cargo Workspace.

```
├── Cargo.lock
├── Cargo.toml
├── control
├── function
├── hello
├── move
├── README.md
├── server
├── string
├── struct
├── target # Your Build files
└── wasi
```

## Standalone examples

This set of examples demonstrate Rust apps that each has a `main()` function and can be started and executed a standalone app.
Expand Down
9 changes: 6 additions & 3 deletions control/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]
name = "control"
version = "0.1.0"
authors = ["ubuntu"]
edition = "2018"
edition.workspace = true
version.workspace = true
authors.workspace = true
description.workspace = true
homepage.workspace = true
documentation.workspace = true

[[bin]]
name = "control"
Expand Down
2 changes: 1 addition & 1 deletion control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $ cargo build --target wasm32-wasi --release
Run the Wasm bytecode file in WasmEdge CLI.

```
$ wasmedge target/wasm32-wasi/release/control.wasm
$ wasmedge ../target/wasm32-wasi/release/control.wasm
Hello WasmEdge!
Howdy WasmEdge!
Hola WasmEdge!
Expand Down
9 changes: 6 additions & 3 deletions function/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]
name = "function"
version = "0.1.0"
authors = ["ubuntu"]
edition = "2018"
edition.workspace = true
version.workspace = true
authors.workspace = true
description.workspace = true
homepage.workspace = true
documentation.workspace = true

[[bin]]
name = "function"
Expand Down
2 changes: 1 addition & 1 deletion function/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $ cargo build --target wasm32-wasi --release
Run the Wasm bytecode file in WasmEdge CLI.

```
$ wasmedge target/wasm32-wasi/release/function.wasm
$ wasmedge ../target/wasm32-wasi/release/function.wasm
Hello WasmEdge!
Howdy WasmEdge!
Hola WasmEdge!
Expand Down
9 changes: 6 additions & 3 deletions hello/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]
name = "hello"
version = "0.1.0"
authors = ["ubuntu"]
edition = "2018"
edition.workspace = true
version.workspace = true
authors.workspace = true
description.workspace = true
homepage.workspace = true
documentation.workspace = true

[[bin]]
name = "hello"
Expand Down
2 changes: 1 addition & 1 deletion hello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $ cargo build --target wasm32-wasi --release
Run the Wasm bytecode file in WasmEdge CLI.

```
$ wasmedge target/wasm32-wasi/release/hello.wasm
$ wasmedge ../target/wasm32-wasi/release/hello.wasm
Hello WasmEdge!
```

Expand Down
9 changes: 6 additions & 3 deletions move/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]
name = "move"
version = "0.1.0"
authors = ["ubuntu"]
edition = "2018"
edition.workspace = true
version.workspace = true
authors.workspace = true
description.workspace = true
homepage.workspace = true
documentation.workspace = true

[[bin]]
name = "move"
Expand Down
2 changes: 1 addition & 1 deletion move/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $ cargo build --target wasm32-wasi --release
Run the Wasm bytecode file in WasmEdge CLI.

```
$ wasmedge target/wasm32-wasi/release/move.wasm
$ wasmedge ../target/wasm32-wasi/release/move.wasm
```

## Build and publish on Docker
Expand Down
9 changes: 6 additions & 3 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]
name = "server"
version = "0.1.0"
authors = ["ubuntu"]
edition = "2018"
edition.workspace = true
version.workspace = true
authors.workspace = true
description.workspace = true
homepage.workspace = true
documentation.workspace = true

[[bin]]
name = "server"
Expand Down
2 changes: 1 addition & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $ cargo build --target wasm32-wasi --release
Run the Wasm bytecode file in WasmEdge CLI.

```
$ wasmedge target/wasm32-wasi/release/server.wasm
$ wasmedge ../target/wasm32-wasi/release/server.wasm
Listening on http://0.0.0.0:8080
```

Expand Down
9 changes: 6 additions & 3 deletions string/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]
name = "string"
version = "0.1.0"
authors = ["ubuntu"]
edition = "2018"
edition.workspace = true
version.workspace = true
authors.workspace = true
description.workspace = true
homepage.workspace = true
documentation.workspace = true

[[bin]]
name = "string"
Expand Down
2 changes: 1 addition & 1 deletion string/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $ cargo build --target wasm32-wasi --release
Run the Wasm bytecode file in WasmEdge CLI.

```
$ wasmedge target/wasm32-wasi/release/string.wasm
$ wasmedge ../target/wasm32-wasi/release/string.wasm
... ART ...
Hello WasmEdge!
Howdy WasmEdge!
Expand Down
9 changes: 6 additions & 3 deletions struct/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]
name = "struct"
version = "0.1.0"
authors = ["ubuntu"]
edition = "2018"
edition.workspace = true
version.workspace = true
authors.workspace = true
description.workspace = true
homepage.workspace = true
documentation.workspace = true

[[bin]]
name = "struct"
Expand Down
2 changes: 1 addition & 1 deletion struct/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ cargo build --target wasm32-wasi --release
Run the Wasm bytecode file in WasmEdge CLI.

```
$ wasmedge target/wasm32-wasi/release/struct.wasm
$ wasmedge ../target/wasm32-wasi/release/struct.wasm
English Hello WasmEdge!
Spanish Hola WasmEdge!
Texan Howdy WasmEdge!
Expand Down
9 changes: 6 additions & 3 deletions wasi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[package]
name = "wasi"
version = "0.1.0"
authors = ["ubuntu"]
edition = "2018"
edition.workspace = true
version.workspace = true
authors.workspace = true
description.workspace = true
homepage.workspace = true
documentation.workspace = true

[[bin]]
name = "wasi"
Expand Down
2 changes: 1 addition & 1 deletion wasi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ cargo build --target wasm32-wasi --release
Run the Wasm bytecode file in WasmEdge CLI.

```
$ wasmedge --dir .:. target/wasm32-wasi/release/wasi.wasm
$ wasmedge --dir .:. ../target/wasm32-wasi/release/wasi.wasm
Random number: -1157533356
Random bytes: [159, 159, 9, 119, 106, 172, 207, 82, 173, 145, 233, 214, 104, 35, 23, 53, 155, 12, 102, 231, 117, 67, 192, 215, 207, 202, 128, 198, 213, 41, 235, 57, 89, 223, 138, 70, 185, 137, 74, 162, 42, 20, 226, 177, 114, 170, 172, 39, 149, 99, 122, 68, 115, 205, 155, 202, 4, 48, 178, 224, 124, 42, 24, 56, 215, 90, 203, 150, 106, 128, 127, 201, 177, 187, 20, 195, 172, 56, 72, 28, 53, 163, 59, 36, 129, 160, 69, 203, 196, 72, 113, 61, 46, 249, 81, 134, 94, 134, 159, 51, 233, 247, 253, 116, 202, 210, 100, 75, 74, 95, 197, 44, 81, 87, 89, 115, 20, 226, 143, 139, 50, 60, 196, 59, 206, 105, 161, 226]
Printed from wasi: This is from a main function
Expand Down

0 comments on commit ebbbf7a

Please sign in to comment.