Skip to content

Commit 9cd8a95

Browse files
o-azzerosnacks
andauthored
feat: harden npm publish & make installer leaner (#11600)
Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
1 parent 1d1004c commit 9cd8a95

File tree

25 files changed

+245
-291
lines changed

25 files changed

+245
-291
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ testdata/fixtures/**/* eol=lf
99

1010
dprint.json linguist-language=JSON-with-Comments
1111
.devcontainer/devcontainer.json linguist-language=JSON-with-Comments
12+
13+
.env.example linguist-language=Dotenv

.github/workflows/npm.yml

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish NPM
1+
name: npm
22

33
on:
44
workflow_dispatch:
@@ -22,6 +22,7 @@ defaults:
2222
env:
2323
ACTIONS_RUNNER_DEBUG: true
2424
NPM_CONFIG_PROVENANCE: true
25+
NPM_REGISTRY_URL: "https://registry.npmjs.org"
2526

2627
jobs:
2728
publish-arch:
@@ -54,31 +55,38 @@ jobs:
5455
}}
5556
outputs:
5657
RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
57-
env:
58-
NPM_REGISTRY_URL: "https://registry.npmjs.org"
5958
steps:
6059
- name: Checkout
6160
uses: actions/checkout@v5
6261

62+
- name: Set Isolated Artifact Directory
63+
id: set-artifact-dir
64+
# Use RUNNER_TEMP env var to persist ARTIFACT_DIR across steps
65+
run: echo "ARTIFACT_DIR=$RUNNER_TEMP/foundry_artifacts" >> "$GITHUB_ENV"
66+
67+
- name: Prepare Isolated Artifact Directory
68+
run: |
69+
mkdir -p "$ARTIFACT_DIR"
70+
ls -la "$ARTIFACT_DIR" || true
71+
6372
- name: Download Release Assets
6473
uses: actions/download-artifact@v5
6574
with:
6675
merge-multiple: true
6776
# Download all foundry artifacts from the triggering release run
6877
pattern: "foundry_*"
69-
path: foundry_artifacts
78+
# Extract artifacts into an isolated temp directory, not the workspace
79+
path: ${{ runner.temp }}/foundry_artifacts
7080
github-token: ${{ secrets.GITHUB_TOKEN }}
7181
run-id: ${{ github.event.workflow_run.id || inputs.run_id }}
7282

7383
- name: Setup Bun
74-
uses: oven-sh/setup-bun@main
84+
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
7585
with:
7686
bun-version: latest
77-
registries: |
78-
https://registry.npmjs.org
7987

8088
- name: Setup Node (for npm publish auth)
81-
uses: actions/setup-node@v4
89+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
8290
with:
8391
node-version: "24"
8492
registry-url: "https://registry.npmjs.org"
@@ -102,12 +110,12 @@ jobs:
102110
run: |
103111
set -euo pipefail
104112
105-
echo "Artifacts in foundry_artifacts:"
106-
ls -la ../foundry_artifacts || true
113+
echo "Artifacts in $ARTIFACT_DIR:"
114+
ls -la "$ARTIFACT_DIR" || true
107115
108116
# Derive RELEASE_VERSION from any foundry artifact we downloaded
109117
# Expected names: foundry_<VERSION>_<platform>_<arch>.{tar.gz,zip}
110-
first_file=$(ls ../foundry_artifacts/foundry_* 2>/dev/null | head -n1 || true)
118+
first_file=$(ls "$ARTIFACT_DIR"/foundry_* 2>/dev/null | head -n1 || true)
111119
if [[ -z "${first_file}" ]]; then
112120
echo "No foundry artifacts found to publish" >&2
113121
exit 1
@@ -125,20 +133,20 @@ jobs:
125133
RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
126134
run: |
127135
set -euo pipefail
128-
mkdir -p tmp
136+
mkdir -p "$ARTIFACT_DIR/tmp"
129137
130-
FILE_PREFIX="../foundry_artifacts/foundry_${RELEASE_VERSION}_${{ matrix.os }}_${{ matrix.arch }}"
138+
FILE_PREFIX="$ARTIFACT_DIR/foundry_${RELEASE_VERSION}_${{ matrix.os }}_${{ matrix.arch }}"
131139
if [[ -f "${FILE_PREFIX}.zip" ]]; then
132140
echo "Extracting ${FILE_PREFIX}.zip"
133141
if ! command -v unzip >/dev/null 2>&1; then
134142
sudo apt-get update -y && sudo apt-get install -y unzip
135143
fi
136-
unzip -o "${FILE_PREFIX}.zip" -d ./tmp
137-
BIN=./tmp/forge.exe
144+
unzip -o "${FILE_PREFIX}.zip" -d "$ARTIFACT_DIR/tmp"
145+
BIN="$ARTIFACT_DIR/tmp/forge.exe"
138146
else
139147
echo "Extracting ${FILE_PREFIX}.tar.gz"
140-
tar -xzf "${FILE_PREFIX}.tar.gz" -C ./tmp
141-
BIN=./tmp/forge
148+
tar -xzf "${FILE_PREFIX}.tar.gz" -C "$ARTIFACT_DIR/tmp"
149+
BIN="$ARTIFACT_DIR/tmp/forge"
142150
fi
143151
144152
echo "Staging binary $BIN into @foundry-rs/forge-${{ matrix.os }}-${{ matrix.arch }}"
@@ -193,23 +201,20 @@ jobs:
193201
name: Publish Meta Package
194202
runs-on: ubuntu-latest
195203
env:
196-
RELEASE_VERSION: ${{ needs.publish-arch.outputs.RELEASE_VERSION }}
197204
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
198205
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
199-
NPM_REGISTRY_URL: "https://registry.npmjs.org"
206+
RELEASE_VERSION: ${{ needs.publish-arch.outputs.RELEASE_VERSION }}
200207
steps:
201208
- name: Checkout
202209
uses: actions/checkout@v5
203210

204211
- name: Setup Bun
205-
uses: oven-sh/setup-bun@main
212+
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
206213
with:
207214
bun-version: latest
208-
registries: |
209-
https://registry.npmjs.org
210215

211216
- name: Setup Node (for npm publish auth)
212-
uses: actions/setup-node@v4
217+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
213218
with:
214219
node-version: "24"
215220
registry-url: "https://registry.npmjs.org"

dprint.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"plugins": [
2727
"https://plugins.dprint.dev/toml-0.7.0.wasm",
2828
"https://plugins.dprint.dev/json-0.20.0.wasm",
29-
"https://plugins.dprint.dev/markdown-0.18.0.wasm",
29+
"https://plugins.dprint.dev/markdown-0.19.0.wasm",
3030
"https://plugins.dprint.dev/dockerfile-0.3.3.wasm",
31-
"https://plugins.dprint.dev/typescript-0.95.7.wasm",
31+
"https://plugins.dprint.dev/typescript-0.95.11.wasm",
3232
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm"
3333
],
3434
"markdown": {

npm/.env.example

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
NODE_ENV="development"
22

33
NPM_TOKEN=""
4-
NPM_REGISTRY_URL=""
5-
NPM_USERNAME="foundry-rs"
64

75
PLATFORM_NAME=""
8-
ARCH=""
6+
ARCH=""
7+
8+
# for testing purposes
9+
NPM_EMAIL=""
10+
NPM_PASSWORD=""
11+
NPM_REGISTRY_URL=""
12+
NPM_USER="foundry-rs"
13+
ALLOW_NO_INTEGRITY=false
14+
ALLOW_INSECURE_REGISTRY=false

npm/@foundry-rs/forge-darwin-amd64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@foundry-rs/forge-darwin-amd64",
3-
"version": "1.3.2",
3+
"version": "0.0.0",
44
"type": "module",
55
"homepage": "https://getfoundry.sh/forge",
66
"description": "Fast and flexible Ethereum testing framework (macOS amd64)",

npm/@foundry-rs/forge-darwin-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@foundry-rs/forge-darwin-arm64",
3-
"version": "1.3.2",
3+
"version": "0.0.0",
44
"type": "module",
55
"homepage": "https://getfoundry.sh/forge",
66
"description": "Fast and flexible Ethereum testing framework (macOS arm64)",

npm/@foundry-rs/forge-linux-amd64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@foundry-rs/forge-linux-amd64",
3-
"version": "1.3.2",
3+
"version": "0.0.0",
44
"type": "module",
55
"homepage": "https://getfoundry.sh/forge",
66
"description": "Fast and flexible Ethereum testing framework (Linux amd64)",

npm/@foundry-rs/forge-linux-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@foundry-rs/forge-linux-arm64",
3-
"version": "1.3.2",
3+
"version": "0.0.0",
44
"type": "module",
55
"homepage": "https://getfoundry.sh/forge",
66
"description": "Fast and flexible Ethereum testing framework (Linux arm64)",

npm/@foundry-rs/forge-win32-amd64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@foundry-rs/forge-win32-amd64",
3-
"version": "1.3.2",
3+
"version": "0.0.0",
44
"type": "module",
55
"homepage": "https://getfoundry.sh/forge",
66
"description": "Fast and flexible Ethereum testing framework (Windows amd64)",

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# forge
1+
# Forge
22

3-
A CLI tool for testing, building, and deploying your smart contracts.
4-
See <https://getfoundry.sh/forge/overview> for details.
3+
Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts.
4+
Forge is part of the Foundry suite and is installed alongside `cast`, `chisel`, and `anvil`.

0 commit comments

Comments
 (0)