Skip to content

Commit 592d09d

Browse files
authored
feat(npm): publish forge to npm for each arch (#11047)
* feat(npm): publish forge to npmjs.com * chore: make names similar to github release * chore: fmt * cleanup * up deps * chore(npm): fix windows and update deps * chore(npm): rm unused file * chore(npm): more specific home pages * chore: pull out npm publish * chore: complete vardaccio script * chore: rename publish to npm * chore: disable workflow_run temporarily * chore: comment out workflow_run deps
1 parent e36e96a commit 592d09d

37 files changed

+1610
-16
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
crates/cheatcodes/assets/*.json linguist-generated
22
testdata/cheats/Vm.sol linguist-generated
3+
bun.lock linguist-generated
34

45
# See <https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header>
56
*.rs diff=rust

.github/workflows/npm.yml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: Publish NPM
2+
3+
on:
4+
workflow_dispatch:
5+
#
6+
# Temporarily disabled
7+
#
8+
# workflow_run:
9+
# types: [completed]
10+
# workflows: [release]
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
env:
21+
ACTIONS_RUNNER_DEBUG: true
22+
NPM_CONFIG_PROVENANCE: true
23+
24+
jobs:
25+
publish-arch:
26+
permissions:
27+
actions: read
28+
contents: read
29+
id-token: write
30+
name: ${{ matrix.os }}-${{ matrix.arch }}
31+
runs-on: ubuntu-latest
32+
strategy:
33+
max-parallel: 3
34+
fail-fast: false
35+
matrix:
36+
# we don't need a specific runner for any of these
37+
# because they've all been built already. We're just publishing
38+
include:
39+
- os: linux
40+
arch: amd64
41+
- os: linux
42+
arch: arm64
43+
- os: darwin
44+
arch: amd64
45+
- os: darwin
46+
arch: arm64
47+
- os: win32
48+
arch: amd64
49+
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
50+
outputs:
51+
RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
52+
env:
53+
NPM_REGISTRY_URL: "https://registry.npmjs.org"
54+
steps:
55+
- name: Download Release Assets
56+
uses: actions/download-artifact@v5
57+
with:
58+
merge-multiple: true
59+
# Download all foundry artifacts from the triggering release run
60+
pattern: "foundry_*"
61+
repository: foundry-rs/foundry
62+
github-token: ${{ secrets.GITHUB_TOKEN }}
63+
# run-id: ${{ github.event.workflow_run.id }}
64+
path: foundry_artifacts
65+
66+
- name: Setup Bun
67+
uses: oven-sh/setup-bun@main
68+
with:
69+
bun-version: latest
70+
registries: |
71+
https://registry.npmjs.org
72+
73+
- name: Setup Node (for npm publish auth)
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: lts
77+
registry-url: "https://registry.npmjs.org"
78+
79+
- name: Install Dependencies
80+
working-directory: npm
81+
run: bun install --frozen-lockfile
82+
83+
- name: Derive RELEASE_VERSION
84+
id: release-version
85+
run: |
86+
set -euo pipefail
87+
88+
# Derive RELEASE_VERSION from any foundry artifact we downloaded
89+
# Expected names: foundry_<VERSION>_<platform>_<arch>.{tar.gz,zip}
90+
91+
first_file=$(ls ../foundry_artifacts/foundry_* 2>/dev/null | head -n1 || true)
92+
if [[ -z "${first_file}" ]]; then
93+
echo "No foundry artifacts found to publish" >&2
94+
exit 1
95+
fi
96+
97+
version_part=$(basename "$first_file")
98+
version_part=${version_part#foundry_}
99+
100+
export RELEASE_VERSION=${version_part%%_*}
101+
102+
echo "Detected RELEASE_VERSION=$RELEASE_VERSION"
103+
echo "RELEASE_VERSION=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
104+
105+
- name: Publish Binaries
106+
working-directory: npm
107+
env:
108+
PROVENANCE: true
109+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
110+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
111+
NPM_REGISTRY_URL: ${{ env.NPM_REGISTRY_URL }}
112+
run: |
113+
set -euo pipefail
114+
115+
echo "Artifacts in foundry_artifacts:"
116+
ls -la ../foundry_artifacts || true
117+
118+
# Derive RELEASE_VERSION from any foundry artifact we downloaded
119+
# Expected names: foundry_<VERSION>_<platform>_<arch>.{tar.gz,zip}
120+
first_file=$(ls ../foundry_artifacts/foundry_* 2>/dev/null | head -n1 || true)
121+
if [[ -z "${first_file}" ]]; then
122+
echo "No foundry artifacts found to publish" >&2
123+
exit 1
124+
fi
125+
version_part=$(basename "$first_file")
126+
version_part=${version_part#foundry_}
127+
export RELEASE_VERSION=${version_part%%_*}
128+
echo "Detected RELEASE_VERSION=$RELEASE_VERSION"
129+
130+
publish-meta:
131+
needs: publish-arch
132+
runs-on: ubuntu-latest
133+
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
134+
env:
135+
RELEASE_VERSION: ${{ needs.publish-arch.outputs.RELEASE_VERSION }}
136+
steps:
137+
- name: Checkout
138+
uses: actions/checkout@v5
139+
140+
- name: Setup Bun
141+
uses: oven-sh/setup-bun@main
142+
with:
143+
bun-version: latest
144+
registries: |
145+
https://registry.npmjs.org
146+
147+
- name: Setup Node (for npm publish auth)
148+
uses: actions/setup-node@v4
149+
with:
150+
node-version: lts
151+
registry-url: "https://registry.npmjs.org"
152+
153+
- name: Install Dependencies
154+
working-directory: npm
155+
run: bun install --frozen-lockfile
156+
157+
- name: Publish @foundry-rs/foundry
158+
working-directory: npm
159+
env:
160+
PROVENANCE: true
161+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
162+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
163+
run: |
164+
set -euo pipefail
165+
166+
bun ./scripts/publish.ts ./@foundry-rs/foundry
167+
echo "Published @foundry-rs/foundry"

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ jobs:
210210
fi
211211
echo "foundry_attestation=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.attestation.txt" >> $GITHUB_OUTPUT
212212
213+
- name: Upload build artifacts
214+
uses: actions/upload-artifact@v4
215+
with:
216+
retention-days: 1
217+
name: ${{ steps.artifacts.outputs.file_name }}
218+
path: ${{ steps.artifacts.outputs.file_name }}
219+
213220
- name: Build man page
214221
id: man
215222
if: matrix.target == 'x86_64-unknown-linux-gnu'

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,11 @@ CLAUDE.md
1111
node_modules
1212
dist
1313
bin
14-
_
14+
_
15+
*.tgz
16+
.zed
17+
.vercel
18+
.vite
19+
.wrangler
20+
build
21+
*.zip

dprint.json

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/dprint/dprint/refs/heads/main/website/src/assets/schemas/v0.json",
3-
"incremental": true,
43
"indentWidth": 2,
54
"useTabs": false,
6-
"includes": [
7-
"*.md",
8-
"*.{toml}",
9-
"Dockerfile",
10-
"*.{yml,yaml}",
11-
"*.{json,jsonc}",
12-
"*.{js,cjs,mjs,d.ts,d.cts,d.mts,ts,tsx,jsx}"
13-
],
145
"excludes": [
6+
"!npm/**/*.{json,md,toml}",
7+
"!npm/**/*.{js,cjs,mjs,d.ts,d.cts,d.mts,ts,tsx,jsx}",
8+
"**/_",
9+
"dprint.json",
10+
"**/abi",
1511
"**/build",
16-
"**/abi/**",
1712
"**/target",
1813
"**/test/**",
1914
"**/*.min.*",
2015
"**/dist/**",
2116
"testdata/**",
2217
"**/tests/**",
18+
"node_modules",
2319
"changelog.json",
2420
"**/test-data/**",
25-
"**/node_modules",
2621
"**/cheatcodes/**",
22+
"**/node_modules/**",
2723
".github/scripts/**",
2824
".github/ISSUE_TEMPLATE/**"
2925
],
@@ -40,13 +36,15 @@
4036
"textWrap": "maintain"
4137
},
4238
"toml": {
43-
"columnWidth": 100
39+
"lineWidth": 100
4440
},
4541
"json": {
46-
"useTabs": false,
42+
"lineWidth": 1,
4743
"indentWidth": 2,
44+
"useTabs": false,
4845
"trailingCommas": "never",
49-
"array.preferSingleLine": true
46+
"preferSingleLine": false,
47+
"array.preferSingleLine": false
5048
},
5149
"typescript": {
5250
"useTabs": false,
@@ -59,4 +57,4 @@
5957
"exportDeclaration.sortTypeOnlyExports": "none",
6058
"importDeclaration.sortTypeOnlyImports": "none"
6159
}
62-
}
60+
}

npm/.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
NODE_ENV="development"
2+
3+
NPM_TOKEN=""
4+
NPM_REGISTRY_URL=""
5+
NPM_USERNAME="foundry-rs"
6+
7+
PLATFORM_NAME=""
8+
ARCH=""

npm/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store
35+
36+
forge/*/bin/forge
37+
@foundry-rs/*/bin/
38+
test/workspace/bun.lock
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# forge
2+
3+
This is the macOS 64-bit binary for `forge`, a CLI tool for testing, building, and deploying your smart contracts.
4+
See <https://getfoundry.sh/forge/overview> for details.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@foundry-rs/forge-darwin-amd64",
3+
"version": "1.2.3",
4+
"type": "module",
5+
"homepage": "https://getfoundry.sh/forge",
6+
"description": "Fast and flexible Ethereum testing framework (macOS amd64)",
7+
"bin": {
8+
"forge": "./bin/forge"
9+
},
10+
"os": [
11+
"darwin"
12+
],
13+
"cpu": [
14+
"x64"
15+
],
16+
"files": [
17+
"bin"
18+
],
19+
"engines": {
20+
"node": ">=20"
21+
},
22+
"license": "MIT OR Apache-2.0",
23+
"repository": {
24+
"directory": "npm",
25+
"url": "https://github.com/foundry-rs/foundry"
26+
},
27+
"keywords": [
28+
"foundry",
29+
"testing",
30+
"ethereum",
31+
"solidity",
32+
"blockchain",
33+
"smart-contracts"
34+
],
35+
"publishConfig": {
36+
"provenance": true
37+
}
38+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# forge
2+
3+
This is the macOS ARM 64-bit binary for `forge`, a CLI tool for testing, building, and deploying your smart contracts.
4+
See <https://getfoundry.sh/forge/overview> for details.

0 commit comments

Comments
 (0)