Skip to content

Commit dc1d21b

Browse files
grandizzyo-az0xrusowsky
authored
feat: npm publish anvil, cast and chisel (#11945)
* save * save * chore: gitignore build dir local to npm * chore: update deps * chore: up * chore: save * chore: types * chore: simple check script * chore: update npm.yml to handle rest of tools * chore: simplify npm.yml * fix: rebase * fix: missing `colors` import * chore: update `.gitignore` * chore: add missing file copy step * Update npm/@foundry-rs/anvil/README.md Co-authored-by: 0xrusowsky <[email protected]> * chore: include missing const.mjs * chore: include missing shebang * chore: add `TARGET_TOOL` in postinstall script --------- Co-authored-by: o-az <[email protected]> Co-authored-by: 0xrusowsky <[email protected]>
1 parent f61c113 commit dc1d21b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1881
-1095
lines changed

.github/workflows/npm.yml

Lines changed: 84 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ defaults:
2222
shell: bash
2323

2424
env:
25-
ACTIONS_RUNNER_DEBUG: true
2625
NPM_CONFIG_PROVENANCE: true
2726
NPM_REGISTRY_URL: "https://registry.npmjs.org"
2827

@@ -32,22 +31,72 @@ jobs:
3231
contents: read
3332
actions: read
3433
id-token: write
35-
name: ${{ matrix.os }}-${{ matrix.arch }}
34+
name: ${{ matrix.tool }}-${{ matrix.os }}-${{ matrix.arch }}
3635
runs-on: ubuntu-latest
3736
strategy:
3837
max-parallel: 3
3938
fail-fast: false
4039
matrix:
4140
include:
42-
- os: linux
41+
- tool: forge
42+
os: linux
4343
arch: amd64
44-
- os: linux
44+
- tool: forge
45+
os: linux
4546
arch: arm64
46-
- os: darwin
47+
- tool: forge
48+
os: darwin
4749
arch: amd64
48-
- os: darwin
50+
- tool: forge
51+
os: darwin
4952
arch: arm64
50-
- os: win32
53+
- tool: forge
54+
os: win32
55+
arch: amd64
56+
- tool: cast
57+
os: linux
58+
arch: amd64
59+
- tool: cast
60+
os: linux
61+
arch: arm64
62+
- tool: cast
63+
os: darwin
64+
arch: amd64
65+
- tool: cast
66+
os: darwin
67+
arch: arm64
68+
- tool: cast
69+
os: win32
70+
arch: amd64
71+
- tool: anvil
72+
os: linux
73+
arch: amd64
74+
- tool: anvil
75+
os: linux
76+
arch: arm64
77+
- tool: anvil
78+
os: darwin
79+
arch: amd64
80+
- tool: anvil
81+
os: darwin
82+
arch: arm64
83+
- tool: anvil
84+
os: win32
85+
arch: amd64
86+
- tool: chisel
87+
os: linux
88+
arch: amd64
89+
- tool: chisel
90+
os: linux
91+
arch: arm64
92+
- tool: chisel
93+
os: darwin
94+
arch: amd64
95+
- tool: chisel
96+
os: darwin
97+
arch: arm64
98+
- tool: chisel
99+
os: win32
51100
arch: amd64
52101
# Run automatically after a successful 'release' workflow, or manually if a run_id is provided
53102
if: >-
@@ -98,14 +147,6 @@ jobs:
98147
node-version: "24"
99148
registry-url: "https://registry.npmjs.org"
100149

101-
- name: Install Dependencies
102-
working-directory: ./npm
103-
run: bun install --frozen-lockfile
104-
105-
- name: Transpile TS -> JS
106-
working-directory: ./npm
107-
run: bun run build
108-
109150
- name: Derive RELEASE_VERSION
110151
id: release-version
111152
working-directory: ./npm
@@ -142,33 +183,26 @@ jobs:
142183
ARTIFACT_DIR: ${{ steps.paths.outputs.artifact_dir }}
143184
run: |
144185
set -euo pipefail
145-
mkdir -p "$ARTIFACT_DIR/tmp"
146186
147-
FILE_PREFIX="$ARTIFACT_DIR/foundry_${RELEASE_VERSION}_${{ matrix.os }}_${{ matrix.arch }}"
148-
if [[ -f "${FILE_PREFIX}.zip" ]]; then
149-
echo "Extracting ${FILE_PREFIX}.zip"
150-
if ! command -v unzip >/dev/null 2>&1; then
151-
sudo apt-get update -y && sudo apt-get install -y unzip
152-
fi
153-
unzip -o "${FILE_PREFIX}.zip" -d "$ARTIFACT_DIR/tmp"
154-
BIN="$ARTIFACT_DIR/tmp/forge.exe"
155-
else
156-
echo "Extracting ${FILE_PREFIX}.tar.gz"
157-
tar -xzf "${FILE_PREFIX}.tar.gz" -C "$ARTIFACT_DIR/tmp"
158-
BIN="$ARTIFACT_DIR/tmp/forge"
159-
fi
160-
161-
echo "Staging binary $BIN into @foundry-rs/forge-${{ matrix.os }}-${{ matrix.arch }}"
162-
PLATFORM_NAME=${{ matrix.os }} ARCH=${{ matrix.arch }} FORGE_BIN_PATH="$BIN" bun ./scripts/prepublish.ts
187+
bun ./scripts/stage-from-artifact.mjs \
188+
--tool '${{ matrix.tool }}' \
189+
--platform '${{ matrix.os }}' \
190+
--arch '${{ matrix.arch }}' \
191+
--release-version "$RELEASE_VERSION" \
192+
--artifact-dir "$ARTIFACT_DIR"
163193
164194
- name: Sanity Check Binary
165195
working-directory: ./npm
166196
run: |
167197
set -euo pipefail
168-
PKG_DIR="./@foundry-rs/forge-${{ matrix.os }}-${{ matrix.arch }}"
169-
BIN="$PKG_DIR/bin/forge"
170-
if [[ "${{ matrix.os }}" == "win32" ]]; then
171-
BIN="$PKG_DIR/bin/forge.exe"
198+
TOOL='${{ matrix.tool }}'
199+
PLATFORM='${{ matrix.os }}'
200+
ARCH='${{ matrix.arch }}'
201+
202+
PKG_DIR="./@foundry-rs/${TOOL}-${PLATFORM}-${ARCH}"
203+
BIN="$PKG_DIR/bin/${TOOL}"
204+
if [[ "$PLATFORM" == "win32" ]]; then
205+
BIN="$PKG_DIR/bin/${TOOL}.exe"
172206
fi
173207
echo "Verifying binary at: $BIN"
174208
ls -la "$BIN"
@@ -195,11 +229,16 @@ jobs:
195229
run: |
196230
set -euo pipefail
197231
198-
ls -la ./@foundry-rs/forge-${{ matrix.os }}-${{ matrix.arch }}
232+
TOOL='${{ matrix.tool }}'
233+
PLATFORM='${{ matrix.os }}'
234+
ARCH='${{ matrix.arch }}'
199235
200-
bun ./scripts/publish.ts ./@foundry-rs/forge-${{ matrix.os }}-${{ matrix.arch }}
236+
PACKAGE_DIR="./@foundry-rs/${TOOL}-${PLATFORM}-${ARCH}"
237+
ls -la "$PACKAGE_DIR"
201238
202-
echo "Published @foundry-rs/forge-${{ matrix.os }}-${{ matrix.arch }}"
239+
bun ./scripts/publish.mjs "$PACKAGE_DIR"
240+
241+
echo "Published @foundry-rs/${TOOL}-${PLATFORM}-${ARCH}"
203242
204243
publish-meta:
205244
permissions:
@@ -234,13 +273,15 @@ jobs:
234273
working-directory: ./npm
235274
run: bun install --frozen-lockfile
236275

237-
- name: Transpile TS -> JS
276+
- name: Typecheck
238277
working-directory: ./npm
239-
run: bun run build
278+
run: bun tsc --project tsconfig.json --noEmit
240279

241-
- name: Publish Meta
280+
- name: Publish Meta Packages
242281
working-directory: ./npm
243-
run: bun run ./scripts/publish.ts ./@foundry-rs/forge
282+
run: |
283+
set -euo pipefail
284+
bun ./scripts/publish-meta.mjs --release-version "$RELEASE_VERSION"
244285
env:
245286
PROVENANCE: true
246287
VERSION_NAME: ${{ env.RELEASE_VERSION }}

dprint.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"indentWidth": 2,
44
"useTabs": false,
55
"excludes": [
6+
"!dprint.json",
67
"!npm/**/*.{json,md,toml}",
78
"!npm/**/*.{js,cjs,mjs,d.ts,d.cts,d.mts,ts,tsx,jsx}",
89
"**/_",
9-
"dprint.json",
1010
"**/abi",
1111
"**/build",
1212
"**/target",
@@ -25,8 +25,8 @@
2525
],
2626
"plugins": [
2727
"https://plugins.dprint.dev/toml-0.7.0.wasm",
28-
"https://plugins.dprint.dev/json-0.20.0.wasm",
29-
"https://plugins.dprint.dev/markdown-0.19.0.wasm",
28+
"https://plugins.dprint.dev/json-0.21.0.wasm",
29+
"https://plugins.dprint.dev/markdown-0.20.0.wasm",
3030
"https://plugins.dprint.dev/dockerfile-0.3.3.wasm",
3131
"https://plugins.dprint.dev/typescript-0.95.11.wasm",
3232
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm"
@@ -57,4 +57,4 @@
5757
"exportDeclaration.sortTypeOnlyExports": "none",
5858
"importDeclaration.sortTypeOnlyImports": "none"
5959
}
60-
}
60+
}

npm/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3434
.DS_Store
3535

3636
forge/*/bin/forge
37+
anvil/*/bin/anvil
38+
cast/*/bin/cast
39+
chisel/*/bin/chisel
3740
@foundry-rs/*/bin/
38-
test/workspace/bun.lock
41+
_

npm/@foundry-rs/anvil/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Anvil
2+
3+
Anvil is a fast local Ethereum development node.
4+
The anvil binary can be used both within and outside of a Foundry project.

npm/@foundry-rs/anvil/package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@foundry-rs/anvil",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"homepage": "https://getfoundry.sh/anvil",
6+
"description": "Anvil is a fast local Ethereum development node",
7+
"bin": {
8+
"anvil": "./bin.mjs"
9+
},
10+
"files": [
11+
"bin",
12+
"dist"
13+
],
14+
"scripts": {
15+
"postinstall": "TARGET_TOOL=anvil node ./dist/postinstall.mjs"
16+
},
17+
"optionalDependencies": {
18+
"@foundry-rs/anvil-darwin-arm64": "0.0.0",
19+
"@foundry-rs/anvil-darwin-amd64": "0.0.0",
20+
"@foundry-rs/anvil-linux-arm64": "0.0.0",
21+
"@foundry-rs/anvil-linux-amd64": "0.0.0",
22+
"@foundry-rs/anvil-win32-amd64": "0.0.0"
23+
},
24+
"publishConfig": {
25+
"access": "public",
26+
"provenance": true,
27+
"registry": "https://registry.npmjs.org"
28+
},
29+
"license": "MIT OR Apache-2.0",
30+
"repository": {
31+
"directory": "npm",
32+
"url": "https://github.com/foundry-rs/foundry"
33+
}
34+
}

npm/@foundry-rs/cast/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Cast
2+
3+
Cast is a Swiss Army knife for interacting with Ethereum applications from the command line.
4+
You can make smart contract calls, send transactions, or retrieve any type of chain data - all from your command-line!
5+
The cast binary can be used both within and outside of a Foundry project.

npm/@foundry-rs/cast/package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@foundry-rs/cast",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"homepage": "https://getfoundry.sh/cast",
6+
"description": "Swiss Army knife for interacting with Ethereum applications from the command line",
7+
"bin": {
8+
"cast": "./bin.mjs"
9+
},
10+
"files": [
11+
"bin",
12+
"dist"
13+
],
14+
"scripts": {
15+
"postinstall": "TARGET_TOOL=cast node ./dist/postinstall.mjs"
16+
},
17+
"optionalDependencies": {
18+
"@foundry-rs/cast-darwin-arm64": "0.0.0",
19+
"@foundry-rs/cast-darwin-amd64": "0.0.0",
20+
"@foundry-rs/cast-linux-arm64": "0.0.0",
21+
"@foundry-rs/cast-linux-amd64": "0.0.0",
22+
"@foundry-rs/cast-win32-amd64": "0.0.0"
23+
},
24+
"publishConfig": {
25+
"access": "public",
26+
"provenance": true,
27+
"registry": "https://registry.npmjs.org"
28+
},
29+
"license": "MIT OR Apache-2.0",
30+
"repository": {
31+
"directory": "npm",
32+
"url": "https://github.com/foundry-rs/foundry"
33+
}
34+
}

npm/@foundry-rs/chisel/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Chisel
2+
3+
Chisel is a fast, utilitarian, and verbose Solidity REPL.
4+
The chisel binary can be used both within and outside of a Foundry project.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@foundry-rs/chisel",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"homepage": "https://getfoundry.sh/chisel",
6+
"description": "Chisel is a fast, utilitarian, and verbose Solidity REPL",
7+
"bin": {
8+
"chisel": "./bin.mjs"
9+
},
10+
"files": [
11+
"bin",
12+
"dist"
13+
],
14+
"scripts": {
15+
"postinstall": "TARGET_TOOL=chisel node ./dist/postinstall.mjs"
16+
},
17+
"optionalDependencies": {
18+
"@foundry-rs/chisel-darwin-arm64": "0.0.0",
19+
"@foundry-rs/chisel-darwin-amd64": "0.0.0",
20+
"@foundry-rs/chisel-linux-arm64": "0.0.0",
21+
"@foundry-rs/chisel-linux-amd64": "0.0.0",
22+
"@foundry-rs/chisel-win32-amd64": "0.0.0"
23+
},
24+
"publishConfig": {
25+
"access": "public",
26+
"provenance": true,
27+
"registry": "https://registry.npmjs.org"
28+
},
29+
"license": "MIT OR Apache-2.0",
30+
"repository": {
31+
"directory": "npm",
32+
"url": "https://github.com/foundry-rs/foundry"
33+
}
34+
}

npm/@foundry-rs/forge-darwin-amd64/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)