-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
91 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: daily |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Release | ||
on: | ||
release: | ||
types: | ||
- created | ||
jobs: | ||
publish: | ||
name: Build & Publish to NPM | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 # v1.1.1 | ||
with: | ||
deno-version: v1.x | ||
- name: Retrieve Version | ||
if: startsWith(github.ref, 'refs/tags/') | ||
id: get_tag_version | ||
run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//} | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16.x" | ||
registry-url: "https://registry.npmjs.org" | ||
- name: Build NPM Package | ||
run: deno run -A --no-check=remote ./_tasks/dnt.ts ${{steps.get_tag_version.outputs.TAG_VERSION}} | ||
- run: npm pack | ||
working-directory: "./target/npm_pkg/" | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: package | ||
path: "./target/npm_pkg/*.tgz" | ||
- uses: octokit/[email protected] | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
route: POST /repos/paritytech/npm_publish_automation/actions/workflows/publish.yml/dispatches | ||
ref: main | ||
inputs: '${{ format(''{{ "repo": "{0}", "run_id": "{1}" }}'', github.repository, github.run_id) }}' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.NPM_PUBLISH_AUTOMATION_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Test | ||
on: push | ||
jobs: | ||
test: | ||
name: Run Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 # v1.1.1 | ||
with: | ||
deno-version: v1.x | ||
- name: Download wabt | ||
run: | | ||
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.30/wabt-1.0.30-ubuntu.tar.gz | tar -xz -C ~ | ||
echo "$HOME/wabt-1.0.30/bin" >> $GITHUB_PATH | ||
- run: deno task star | ||
- run: deno task build --check | ||
- run: deno task test |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
import * as flags from "https://deno.land/[email protected]/flags/mod.ts" | ||
import * as path from "https://deno.land/[email protected]/path/mod.ts" | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts" | ||
import { encodeHex } from "../util.ts" | ||
|
||
const { check } = flags.parse(Deno.args, { boolean: ["check"] }) | ||
|
||
const wasmPaths = [ | ||
"hashers/xxhash", | ||
"hashers/blake2b", | ||
] | ||
|
||
await Promise.all(wasmPaths.map(build)) | ||
let success = true | ||
await Promise.all(wasmPaths.map((path) => | ||
build(path).catch((error) => { | ||
console.error(`${path}:`, error) | ||
success = false | ||
}) | ||
)) | ||
Deno.exit(success ? 0 : 1) | ||
|
||
async function build(wasmPath: string) { | ||
const process = Deno.run({ | ||
|
@@ -22,14 +33,19 @@ async function build(wasmPath: string) { | |
|
||
const wasm = await process.output() | ||
|
||
await Deno.writeTextFile( | ||
wasmPath + ".wasm.ts", | ||
` | ||
const content = ` | ||
// @generated | ||
import { decodeHex } from "${path.relative(path.dirname(wasmPath), "util.ts")}" | ||
export default decodeHex(\n"${encodeHex(wasm).replace(/.{0,64}|$/g, "\\\n$&")}",\n) | ||
`.trimStart(), | ||
) | ||
`.trimStart() | ||
|
||
const outputPath = wasmPath + ".wasm.ts" | ||
if (check) { | ||
const existing = await Deno.readTextFile(outputPath) | ||
assertEquals(existing, content, "Outdated file") | ||
} else { | ||
await Deno.writeTextFile(outputPath, content) | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// moderate --exclude *.wasm.ts | ||
|
||
export * from "./blake2b.ts" | ||
export * from "./common.ts" | ||
export * from "./xxhash.ts" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// moderate | ||
// moderate --exclude util.ts | ||
|
||
export * from "./hashers/mod.ts" | ||
export * from "./util.ts" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
dprint | ||
hashers | ||
paritytech | ||
deno | ||
denoland | ||
chiefbiiko | ||
wabt |