From d63b19060217ecadb2bb2fe1d81178daa31f2e89 Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Tue, 22 Nov 2022 18:40:20 +0100 Subject: [PATCH 01/10] Add scaffold script --- README.md | 6 +++++ scaffold.ts | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 scaffold.ts diff --git a/README.md b/README.md index b76d0d4..4fb4edd 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,12 @@ in Rust. ### QuickStart +If you want to create a scaffold automatically you can run: + +```sh +deno run -A https://deno.land/x/deno_bindgen/scaffold.ts my_project_name +``` + Annotate on top of Rust `fn`, `struct` and `enum` to make them available to Deno. ```rust diff --git a/scaffold.ts b/scaffold.ts new file mode 100644 index 0000000..970d352 --- /dev/null +++ b/scaffold.ts @@ -0,0 +1,63 @@ +import { basename } from "https://deno.land/std@0.145.0/path/mod.ts"; + +const libPath = Deno.args[0]; + +// 1- Create cargo fixture +Deno.mkdirSync(libPath + "/src", { recursive: true }); + +// 2- Create lib.rs +Deno.writeTextFileSync( + libPath + "/src/lib.rs", + `\ +// add.rs +use deno_bindgen::deno_bindgen; + +#[deno_bindgen] +pub struct Input { + a: i32, + b: i32, +} + +#[deno_bindgen] +fn add(input: Input) -> i32 { + input.a + input.b +}`, +); + +// 3- Create Cargo.toml +Deno.writeTextFileSync( + libPath + "/Cargo.toml", + `\ +[package] +name = "${basename(libPath)}" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +deno_bindgen = "0.7.0" +serde = { version = "1", features = ["derive"] } + +[lib] +crate-type = ["cdylib"]`, +); + +// 4- Create mod.ts +Deno.writeTextFileSync( + libPath + "/mod.ts", + `\ +// add.ts +import { add } from "./bindings/bindings.ts"; + +console.log( + add({ a: 1, b: 2 }), +);`, +); + +// 5- Create github action +// TODO + +console.log("1- cd ", libPath); +console.log("2- Run deno_bindgen"); +console.log("3- Run deno run --unstable lib.ts"); From 065bc33d0601959d02e75d39dfad341fd9f84e85 Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Tue, 22 Nov 2022 18:50:02 +0100 Subject: [PATCH 02/10] Don't override directories --- scaffold.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scaffold.ts b/scaffold.ts index 970d352..86b0f0d 100644 --- a/scaffold.ts +++ b/scaffold.ts @@ -3,6 +3,11 @@ import { basename } from "https://deno.land/std@0.145.0/path/mod.ts"; const libPath = Deno.args[0]; // 1- Create cargo fixture +try { + Deno.statSync(libPath); + console.error("Path already exists: ", libPath); + Deno.exit(1); +} catch { /**/ } Deno.mkdirSync(libPath + "/src", { recursive: true }); // 2- Create lib.rs From 0daa4c64812c69d50abb1e0d957996d0983dc3c6 Mon Sep 17 00:00:00 2001 From: sigmaSd Date: Wed, 23 Nov 2022 18:05:04 +0100 Subject: [PATCH 03/10] Use lower permissions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fb4edd..ff46e37 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ in Rust. If you want to create a scaffold automatically you can run: ```sh -deno run -A https://deno.land/x/deno_bindgen/scaffold.ts my_project_name +deno run --allow-read=. --allow-write=. https://deno.land/x/deno_bindgen/scaffold.ts my_project_name ``` Annotate on top of Rust `fn`, `struct` and `enum` to make them available to Deno. From 5390912b0bd5317cfa5200541ae9898ff0480464 Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Wed, 23 Nov 2022 19:12:32 +0100 Subject: [PATCH 04/10] Add github action --- scaffold.ts | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/scaffold.ts b/scaffold.ts index 86b0f0d..7543eb7 100644 --- a/scaffold.ts +++ b/scaffold.ts @@ -1,6 +1,7 @@ import { basename } from "https://deno.land/std@0.145.0/path/mod.ts"; const libPath = Deno.args[0]; +const libName = basename(libPath); // 1- Create cargo fixture try { @@ -34,7 +35,7 @@ Deno.writeTextFileSync( libPath + "/Cargo.toml", `\ [package] -name = "${basename(libPath)}" +name = "${libName}" version = "0.1.0" edition = "2021" @@ -61,8 +62,94 @@ console.log( ); // 5- Create github action -// TODO +Deno.mkdirSync(libPath + "/.github/workflows", { recursive: true }); +Deno.writeTextFileSync( + libPath + "/.github/workflows/release.yml", + `\ +name: Release libs + +on: + workflow_dispatch: + inputs: + tag: + description: "tag name" + required: true + +jobs: + build: + name: Release libs + runs-on: \${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - uses: goto-bus-stop/setup-zig@v1 + with: + version: 0.9.0 + + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release + + - name: Build MacOS x86_64 + if: runner.os == 'MacOS' + run: | + mv target/release/lib${libName}.dylib lib${libName}_x86_64.dylib + + - name: Upload MacOS x86_64 + if: runner.os == 'MacOS' + uses: svenstaro/upload-release-action@v2 + with: + file: lib${libName}_x86_64.dylib + tag: \${{ github.event.inputs.tag }} + overwrite: true + + - name: Build MacOS aarch64 lib + if: runner.os == 'Linux' + run: | + rustup target add aarch64-apple-darwin + cargo install cargo-zigbuild + cargo zigbuild --release --target aarch64-apple-darwin + mv target/aarch64-apple-darwin/release/lib${libName}.dylib lib${libName}_aarch64.dylib + + - name: Upload MacOS aarch64 + if: runner.os == 'Linux' + uses: svenstaro/upload-release-action@v2 + with: + file: lib${libName}_aarch64.dylib + tag: \${{ github.event.inputs.tag }} + overwrite: true + + - name: Release Linux lib + if: runner.os == 'Linux' + uses: svenstaro/upload-release-action@v2 + with: + file: target/release/lib${libName}.so + tag: \${{ github.event.inputs.tag }} + overwrite: true + + - name: Release Windows lib + if: runner.os == 'Windows' + uses: svenstaro/upload-release-action@v2 + with: + file: target/release/${libName}.dll + tag: \${{ github.event.inputs.tag }} + overwrite: true`, +); console.log("1- cd ", libPath); -console.log("2- Run deno_bindgen"); +console.log( + "2- If you're developing locally run deno_bindgen\n" + + "If you want to create release bindings, you can trigger a github action build manually in {github_repo}/actions\n" + + "Then use deno_bindgen --release={github_repo}/releases/download/{tag_name}", +); console.log("3- Run deno run --unstable lib.ts"); From be72d751d5c15f61ccdc28dfbca1b91f7f38ff12 Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Wed, 23 Nov 2022 19:15:38 +0100 Subject: [PATCH 05/10] mention ga --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff46e37..0cd480b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ in Rust. ### QuickStart -If you want to create a scaffold automatically you can run: +If you want to create a scaffold (with github action support) automatically you can run: ```sh deno run --allow-read=. --allow-write=. https://deno.land/x/deno_bindgen/scaffold.ts my_project_name From 689c858a78424817adcf792932cf6952091972af Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Tue, 13 Dec 2022 08:21:17 +0100 Subject: [PATCH 06/10] make macos arm optional --- scaffold.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scaffold.ts b/scaffold.ts index 7543eb7..1fde79b 100644 --- a/scaffold.ts +++ b/scaffold.ts @@ -89,10 +89,10 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable - - - uses: goto-bus-stop/setup-zig@v1 - with: - version: 0.9.0 + #uncomment to build for macos arm + #- uses: goto-bus-stop/setup-zig@v1 + # with: + # version: 0.9.0 - name: Build uses: actions-rs/cargo@v1 @@ -113,13 +113,14 @@ jobs: tag: \${{ github.event.inputs.tag }} overwrite: true - - name: Build MacOS aarch64 lib - if: runner.os == 'Linux' - run: | - rustup target add aarch64-apple-darwin - cargo install cargo-zigbuild - cargo zigbuild --release --target aarch64-apple-darwin - mv target/aarch64-apple-darwin/release/lib${libName}.dylib lib${libName}_aarch64.dylib + #uncomment to build for macos arm + #- name: Build MacOS aarch64 lib + # if: runner.os == 'Linux' + # run: | + # rustup target add aarch64-apple-darwin + # cargo install cargo-zigbuild + # cargo zigbuild --release --target aarch64-apple-darwin + # mv target/aarch64-apple-darwin/release/lib${libName}.dylib lib${libName}_aarch64.dylib - name: Upload MacOS aarch64 if: runner.os == 'Linux' From 133bed29460ba6dad89fb9ea627d5f6d264d897e Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Wed, 14 Dec 2022 08:57:10 +0100 Subject: [PATCH 07/10] generate bindings automaticly --- README.md | 2 +- scaffold.ts | 156 ------------------------------------------- scaffold/action.yml | 112 +++++++++++++++++++++++++++++++ scaffold/scaffold.ts | 80 ++++++++++++++++++++++ 4 files changed, 193 insertions(+), 157 deletions(-) delete mode 100644 scaffold.ts create mode 100644 scaffold/action.yml create mode 100644 scaffold/scaffold.ts diff --git a/README.md b/README.md index 0cd480b..50e3051 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ in Rust. If you want to create a scaffold (with github action support) automatically you can run: ```sh -deno run --allow-read=. --allow-write=. https://deno.land/x/deno_bindgen/scaffold.ts my_project_name +deno run --allow-read=. --allow-write=. https://deno.land/x/deno_bindgen/scaffold/scaffold.ts my_project_name ``` Annotate on top of Rust `fn`, `struct` and `enum` to make them available to Deno. diff --git a/scaffold.ts b/scaffold.ts deleted file mode 100644 index 1fde79b..0000000 --- a/scaffold.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { basename } from "https://deno.land/std@0.145.0/path/mod.ts"; - -const libPath = Deno.args[0]; -const libName = basename(libPath); - -// 1- Create cargo fixture -try { - Deno.statSync(libPath); - console.error("Path already exists: ", libPath); - Deno.exit(1); -} catch { /**/ } -Deno.mkdirSync(libPath + "/src", { recursive: true }); - -// 2- Create lib.rs -Deno.writeTextFileSync( - libPath + "/src/lib.rs", - `\ -// add.rs -use deno_bindgen::deno_bindgen; - -#[deno_bindgen] -pub struct Input { - a: i32, - b: i32, -} - -#[deno_bindgen] -fn add(input: Input) -> i32 { - input.a + input.b -}`, -); - -// 3- Create Cargo.toml -Deno.writeTextFileSync( - libPath + "/Cargo.toml", - `\ -[package] -name = "${libName}" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -deno_bindgen = "0.7.0" -serde = { version = "1", features = ["derive"] } - -[lib] -crate-type = ["cdylib"]`, -); - -// 4- Create mod.ts -Deno.writeTextFileSync( - libPath + "/mod.ts", - `\ -// add.ts -import { add } from "./bindings/bindings.ts"; - -console.log( - add({ a: 1, b: 2 }), -);`, -); - -// 5- Create github action -Deno.mkdirSync(libPath + "/.github/workflows", { recursive: true }); -Deno.writeTextFileSync( - libPath + "/.github/workflows/release.yml", - `\ -name: Release libs - -on: - workflow_dispatch: - inputs: - tag: - description: "tag name" - required: true - -jobs: - build: - name: Release libs - runs-on: \${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - #uncomment to build for macos arm - #- uses: goto-bus-stop/setup-zig@v1 - # with: - # version: 0.9.0 - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release - - - name: Build MacOS x86_64 - if: runner.os == 'MacOS' - run: | - mv target/release/lib${libName}.dylib lib${libName}_x86_64.dylib - - - name: Upload MacOS x86_64 - if: runner.os == 'MacOS' - uses: svenstaro/upload-release-action@v2 - with: - file: lib${libName}_x86_64.dylib - tag: \${{ github.event.inputs.tag }} - overwrite: true - - #uncomment to build for macos arm - #- name: Build MacOS aarch64 lib - # if: runner.os == 'Linux' - # run: | - # rustup target add aarch64-apple-darwin - # cargo install cargo-zigbuild - # cargo zigbuild --release --target aarch64-apple-darwin - # mv target/aarch64-apple-darwin/release/lib${libName}.dylib lib${libName}_aarch64.dylib - - - name: Upload MacOS aarch64 - if: runner.os == 'Linux' - uses: svenstaro/upload-release-action@v2 - with: - file: lib${libName}_aarch64.dylib - tag: \${{ github.event.inputs.tag }} - overwrite: true - - - name: Release Linux lib - if: runner.os == 'Linux' - uses: svenstaro/upload-release-action@v2 - with: - file: target/release/lib${libName}.so - tag: \${{ github.event.inputs.tag }} - overwrite: true - - - name: Release Windows lib - if: runner.os == 'Windows' - uses: svenstaro/upload-release-action@v2 - with: - file: target/release/${libName}.dll - tag: \${{ github.event.inputs.tag }} - overwrite: true`, -); - -console.log("1- cd ", libPath); -console.log( - "2- If you're developing locally run deno_bindgen\n" + - "If you want to create release bindings, you can trigger a github action build manually in {github_repo}/actions\n" + - "Then use deno_bindgen --release={github_repo}/releases/download/{tag_name}", -); -console.log("3- Run deno run --unstable lib.ts"); diff --git a/scaffold/action.yml b/scaffold/action.yml new file mode 100644 index 0000000..35a5f09 --- /dev/null +++ b/scaffold/action.yml @@ -0,0 +1,112 @@ +name: Release libs + +on: + workflow_dispatch: + inputs: + tag: + description: "tag name" + required: true + +jobs: + build: + name: Release libs + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v2 + with: + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release + + - name: Build MacOS x86_64 + if: runner.os == 'MacOS' + run: | + mv target/release/libg.dylib libg_x86_64.dylib + + - name: Upload MacOS x86_64 + if: runner.os == 'MacOS' + uses: svenstaro/upload-release-action@v2 + with: + file: libg_x86_64.dylib + tag: ${{ github.event.inputs.tag }} + overwrite: true + + - name: Release Linux lib + if: runner.os == 'Linux' + uses: svenstaro/upload-release-action@v2 + with: + file: target/release/libg.so + tag: ${{ github.event.inputs.tag }} + overwrite: true + + - name: Release Windows lib + if: runner.os == 'Windows' + uses: svenstaro/upload-release-action@v2 + with: + file: target/release/g.dll + tag: ${{ github.event.inputs.tag }} + overwrite: true + + #uncomment to build for macos arm + #- uses: goto-bus-stop/setup-zig@v1 + # with: + # version: 0.9.0 + + #- name: Build MacOS aarch64 lib + # if: runner.os == 'Linux' + # run: | + # rustup target add aarch64-apple-darwin + # cargo install cargo-zigbuild + # cargo zigbuild --release --target aarch64-apple-darwin + # mv target/aarch64-apple-darwin/release/libg.dylib libg_aarch64.dylib + + # - name: Upload MacOS aarch64 + # if: runner.os == 'Linux' + # uses: svenstaro/upload-release-action@v2 + # with: + # file: libg_aarch64.dylib + # tag: ${{ github.event.inputs.tag }} + # overwrite: true + + + #uncomment to automaticly generate bindings + # - name: Setup Deno + # if: runner.os == 'Linux' + # uses: denoland/setup-deno@v1 + + # - name: Generate bindings + # if: runner.os == 'Linux' + # run: | + # libUrl=https://github.com/$GITHUB_REPOSITORY/releases/download/${{ github.event.inputs.tag }} + # touch src/lib.rs # Required to trigger cargo build correctly (to generate bindings.json) + # deno run -A -r https://deno.land/x/deno_bindgen/cli.ts --release=$libUrl + + # - name: Commit bindings + # if: runner.os == 'Linux' + # run: | + # git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + # git config --local user.name "github-actions[bot]" + # git add bindings/bindings.ts + # git commit -m "update bindings to ${{ github.event.inputs.tag }}" + + # - name: Push changes + # if: runner.os == 'Linux' + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} + + diff --git a/scaffold/scaffold.ts b/scaffold/scaffold.ts new file mode 100644 index 0000000..3cda3bd --- /dev/null +++ b/scaffold/scaffold.ts @@ -0,0 +1,80 @@ +import { basename } from "https://deno.land/std@0.145.0/path/mod.ts"; + +const libPath = Deno.args[0]; +const libName = basename(libPath); + +// 1- Create cargo fixture +try { + Deno.statSync(libPath); + console.error("Path already exists: ", libPath); + Deno.exit(1); +} catch { /**/ } +Deno.mkdirSync(libPath + "/src", { recursive: true }); + +// 2- Create lib.rs +Deno.writeTextFileSync( + libPath + "/src/lib.rs", + `\ +// add.rs +use deno_bindgen::deno_bindgen; + +#[deno_bindgen] +pub struct Input { + a: i32, + b: i32, +} + +#[deno_bindgen] +fn add(input: Input) -> i32 { + input.a + input.b +}`, +); + +// 3- Create Cargo.toml +Deno.writeTextFileSync( + libPath + "/Cargo.toml", + `\ +[package] +name = "${libName}" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +deno_bindgen = "0.7.0" +serde = { version = "1", features = ["derive"] } + +[lib] +crate-type = ["cdylib"]`, +); + +// 4- Create mod.ts +Deno.writeTextFileSync( + libPath + "/mod.ts", + `\ +// add.ts +import { add } from "./bindings/bindings.ts"; + +console.log( + add({ a: 1, b: 2 }), +);`, +); + +// 5- Create github action +Deno.mkdirSync(libPath + "/.github/workflows", { recursive: true }); +const githubAction = await fetch( + import.meta.resolve("./action.yml"), +).then((r) => r.text()); +Deno.writeTextFileSync( + libPath + "/.github/workflows/release.yml", + githubAction, +); + +console.log("1- cd ", libPath); +console.log( + "2- If you're developing locally run deno_bindgen\n" + + "If you want to create release bindings, you can trigger a github action build manually in {github_repo}/actions\n" + + "Then use deno_bindgen --release={github_repo}/releases/download/{tag_name}", +); +console.log("3- Run deno run --unstable lib.ts"); From e6f23d5c36db18952ddcb05199943853d7bb8e1d Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Wed, 14 Dec 2022 15:21:50 +0100 Subject: [PATCH 08/10] retouche --- scaffold/action.yml | 80 ++++++++++++++++++++++---------------------- scaffold/scaffold.ts | 10 ++---- 2 files changed, 43 insertions(+), 47 deletions(-) diff --git a/scaffold/action.yml b/scaffold/action.yml index 35a5f09..161c162 100644 --- a/scaffold/action.yml +++ b/scaffold/action.yml @@ -34,29 +34,29 @@ jobs: - name: Build MacOS x86_64 if: runner.os == 'MacOS' run: | - mv target/release/libg.dylib libg_x86_64.dylib + mv target/release/lib$NAME_HERE.dylib lib$NAME_HERE_x86_64.dylib - name: Upload MacOS x86_64 if: runner.os == 'MacOS' uses: svenstaro/upload-release-action@v2 with: - file: libg_x86_64.dylib + file: lib$NAME_HERE_x86_64.dylib tag: ${{ github.event.inputs.tag }} overwrite: true - - name: Release Linux lib + - name: Upload Linux if: runner.os == 'Linux' uses: svenstaro/upload-release-action@v2 with: - file: target/release/libg.so + file: target/release/lib$NAME_HERE.so tag: ${{ github.event.inputs.tag }} overwrite: true - - name: Release Windows lib + - name: Upload Windows if: runner.os == 'Windows' uses: svenstaro/upload-release-action@v2 with: - file: target/release/g.dll + file: target/release/$NAME_HERE.dll tag: ${{ github.event.inputs.tag }} overwrite: true @@ -65,48 +65,48 @@ jobs: # with: # version: 0.9.0 - #- name: Build MacOS aarch64 lib + #- name: Build MacOS aarch64 # if: runner.os == 'Linux' # run: | # rustup target add aarch64-apple-darwin # cargo install cargo-zigbuild # cargo zigbuild --release --target aarch64-apple-darwin - # mv target/aarch64-apple-darwin/release/libg.dylib libg_aarch64.dylib + # mv target/aarch64-apple-darwin/release/lib$NAME_HERE.dylib lib$NAME_HERE_aarch64.dylib - # - name: Upload MacOS aarch64 - # if: runner.os == 'Linux' - # uses: svenstaro/upload-release-action@v2 - # with: - # file: libg_aarch64.dylib - # tag: ${{ github.event.inputs.tag }} - # overwrite: true + #- name: Upload MacOS aarch64 + # if: runner.os == 'Linux' + # uses: svenstaro/upload-release-action@v2 + # with: + # file: lib$NAME_HERE_aarch64.dylib + # tag: ${{ github.event.inputs.tag }} + # overwrite: true #uncomment to automaticly generate bindings - # - name: Setup Deno - # if: runner.os == 'Linux' - # uses: denoland/setup-deno@v1 - - # - name: Generate bindings - # if: runner.os == 'Linux' - # run: | - # libUrl=https://github.com/$GITHUB_REPOSITORY/releases/download/${{ github.event.inputs.tag }} - # touch src/lib.rs # Required to trigger cargo build correctly (to generate bindings.json) - # deno run -A -r https://deno.land/x/deno_bindgen/cli.ts --release=$libUrl - - # - name: Commit bindings - # if: runner.os == 'Linux' - # run: | - # git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - # git config --local user.name "github-actions[bot]" - # git add bindings/bindings.ts - # git commit -m "update bindings to ${{ github.event.inputs.tag }}" - - # - name: Push changes - # if: runner.os == 'Linux' - # uses: ad-m/github-push-action@master - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # branch: ${{ github.ref }} + #- name: Setup Deno + # if: runner.os == 'Linux' + # uses: denoland/setup-deno@v1 + + #- name: Generate bindings + # if: runner.os == 'Linux' + # run: | + # libUrl=https://github.com/$GITHUB_REPOSITORY/releases/download/${{ github.event.inputs.tag }} + # touch src/lib.rs # Required to trigger cargo build correctly (to generate bindings.json) + # deno run -A -r https://deno.land/x/deno_bindgen/cli.ts --release=$libUrl + + #- name: Commit bindings + # if: runner.os == 'Linux' + # run: | + # git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + # git config --local user.name "github-actions[bot]" + # git add bindings/bindings.ts + # git commit -m "update bindings to ${{ github.event.inputs.tag }}" + + #- name: Push changes + # if: runner.os == 'Linux' + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} diff --git a/scaffold/scaffold.ts b/scaffold/scaffold.ts index 3cda3bd..68dbe12 100644 --- a/scaffold/scaffold.ts +++ b/scaffold/scaffold.ts @@ -65,16 +65,12 @@ console.log( Deno.mkdirSync(libPath + "/.github/workflows", { recursive: true }); const githubAction = await fetch( import.meta.resolve("./action.yml"), -).then((r) => r.text()); +).then((r) => r.text()).then((a) => a.replaceAll("$NAME_HERE", libName)); Deno.writeTextFileSync( libPath + "/.github/workflows/release.yml", githubAction, ); console.log("1- cd ", libPath); -console.log( - "2- If you're developing locally run deno_bindgen\n" + - "If you want to create release bindings, you can trigger a github action build manually in {github_repo}/actions\n" + - "Then use deno_bindgen --release={github_repo}/releases/download/{tag_name}", -); -console.log("3- Run deno run --unstable lib.ts"); +console.log("2- Run deno_bindgen to develop locally"); +console.log("3- Run deno run --unstable mod.ts"); From 51d04e8c0427c68406f3b1630d252cadb6c677a3 Mon Sep 17 00:00:00 2001 From: sigmaSd Date: Sun, 2 Jul 2023 07:58:16 +0100 Subject: [PATCH 09/10] update denobindgen version --- scaffold/scaffold.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/scaffold.ts b/scaffold/scaffold.ts index 68dbe12..0a7c93b 100644 --- a/scaffold/scaffold.ts +++ b/scaffold/scaffold.ts @@ -42,7 +42,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -deno_bindgen = "0.7.0" +deno_bindgen = "0.8.1" serde = { version = "1", features = ["derive"] } [lib] From dd4dbda500a3a7506ea8aed5f8696738508176aa Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Sun, 2 Jul 2023 08:04:15 +0100 Subject: [PATCH 10/10] check for project name --- scaffold/scaffold.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/scaffold/scaffold.ts b/scaffold/scaffold.ts index 0a7c93b..7aa7d89 100644 --- a/scaffold/scaffold.ts +++ b/scaffold/scaffold.ts @@ -1,6 +1,7 @@ import { basename } from "https://deno.land/std@0.145.0/path/mod.ts"; const libPath = Deno.args[0]; +if (!libPath) throw new Error("no project name provided"); const libName = basename(libPath); // 1- Create cargo fixture