Skip to content

Commit 4fe7992

Browse files
authored
Prepare next release and initial release of huff-neo-js (#61)
1 parent 9c572ae commit 4fe7992

File tree

11 files changed

+229
-21
lines changed

11 files changed

+229
-21
lines changed

.github/scripts/check_wasm.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env bash
2+
3+
# Fork from https://github.com/paradigmxyz/reth/blob/main/.github/assets/check_wasm.sh
4+
5+
set +e # Disable immediate exit on error
6+
7+
# Array of crates to compile
8+
crates=($(cargo metadata --format-version=1 --no-deps | jq -r '.packages[].name' | grep '^huff-neo' | sort))
9+
10+
# Array of crates to exclude
11+
# Used with the `contains` function.
12+
# shellcheck disable=SC2034
13+
exclude_crates=(
14+
"huff-neo-test-runner"
15+
)
16+
17+
# Array to hold the results
18+
results=()
19+
# Flag to track if any command fails
20+
any_failed=0
21+
22+
# Function to check if a value exists in an array
23+
contains() {
24+
local array="$1[@]"
25+
local seeking=$2
26+
local in=1
27+
for element in "${!array}"; do
28+
if [[ "$element" == "$seeking" ]]; then
29+
in=0
30+
break
31+
fi
32+
done
33+
return $in
34+
}
35+
36+
for crate in "${crates[@]}"; do
37+
if contains exclude_crates "$crate"; then
38+
results+=("3:⏭️:$crate")
39+
continue
40+
fi
41+
42+
export RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
43+
cmd="cargo +stable build -p $crate --target wasm32-unknown-unknown --no-default-features"
44+
45+
if [ -n "$CI" ]; then
46+
echo "::group::$cmd"
47+
else
48+
printf "\n%s:\n %s\n" "$crate" "$cmd"
49+
fi
50+
51+
set +e # Disable immediate exit on error
52+
# Run the command and capture the return code
53+
$cmd
54+
ret_code=$?
55+
set -e # Re-enable immediate exit on error
56+
57+
# Store the result in the dictionary
58+
if [ $ret_code -eq 0 ]; then
59+
results+=("1:✅:$crate")
60+
else
61+
results+=("2:❌:$crate")
62+
any_failed=1
63+
fi
64+
65+
if [ -n "$CI" ]; then
66+
echo "::endgroup::"
67+
fi
68+
done
69+
70+
# Sort the results by status and then by crate name
71+
IFS=$'\n' sorted_results=($(sort <<<"${results[*]}"))
72+
unset IFS
73+
74+
# Print summary
75+
echo -e "\nSummary of build results:"
76+
for result in "${sorted_results[@]}"; do
77+
status="${result#*:}"
78+
status="${status%%:*}"
79+
crate="${result##*:}"
80+
echo "$status $crate"
81+
done
82+
83+
# Exit with a non-zero status if any command fails
84+
exit $any_failed

.github/scripts/make_package.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Check if jq is installed
5+
if ! [ -x "$(command -v jq)" ]; then
6+
echo "jq is not installed" >& 2
7+
exit 1
8+
fi
9+
10+
# Clean previous packages
11+
if [ -d "pkg" ]; then
12+
rm -rf pkg
13+
fi
14+
15+
if [ -d "pkg-node" ]; then
16+
rm -rf pkg-node
17+
fi
18+
19+
# Build for both targets
20+
export RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
21+
wasm-pack build -t nodejs -d pkg-node crates/js
22+
wasm-pack build -t browser -d pkg crates/js
23+
24+
# Get the package name
25+
PKG_NAME=$(jq -r .name crates/js/pkg/package.json | sed 's/\-/_/g')
26+
27+
# Give the packages a version tag
28+
if [ -n "$VERSION_TAG" ]; then
29+
# Overwrite the version in the package.json
30+
jq --arg v $VERSION_TAG '.version = $v' crates/js/pkg/package.json > temp.json && mv temp.json crates/js/pkg/package.json
31+
jq --arg v $VERSION_TAG '.version = $v' crates/js/pkg-node/package.json > temp.json && mv temp.json crates/js/pkg-node/package.json
32+
fi

.github/workflows/ci.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,24 @@ jobs:
115115
with:
116116
log-level: warn
117117
command: check
118-
arguments: --all-features
118+
arguments: --all-features
119+
120+
wasm:
121+
runs-on: ubuntu-latest
122+
timeout-minutes: 30
123+
steps:
124+
- uses: actions/checkout@v4
125+
with:
126+
fetch-depth: 0
127+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
128+
- uses: dtolnay/rust-toolchain@stable
129+
with:
130+
target: wasm32-wasip1
131+
- uses: Swatinem/rust-cache@v2
132+
with:
133+
cache-on-failure: true
134+
- uses: dcarbone/install-jq-action@v3
135+
- name: Run Wasm checks
136+
run: |
137+
sudo apt update && sudo apt install gcc-multilib
138+
.github/scripts/check_wasm.sh
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release NPM
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.*
7+
8+
jobs:
9+
release-npm:
10+
name: Release NPM
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
18+
- uses: dtolnay/rust-toolchain@stable
19+
20+
- name: Get version tag
21+
id: vars
22+
run: |
23+
export pkg_version=${GITHUB_REF#refs/*/}
24+
echo "tag=$pkg_version" >> $GITHUB_OUTPUT
25+
26+
- name: Install Wasm Pack
27+
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
28+
29+
- name: Build
30+
env:
31+
PACKAGE_VERSION: ${{ steps.vars.outputs.tag }}
32+
run: ./.github/scripts/make_packages.sh
33+
34+
- name: Publish to NPM
35+
run: npm publish
36+
working-directory: ./crates/js
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,26 @@ jobs:
7777
# - $target - Target triple.
7878
# - $tag - Tag of this release.
7979
# When multiple binary names are specified, default archive name or $bin variable cannot be used.
80-
archive: $bin-$tag-$target
80+
archive: $bin-$tag-$target
81+
82+
83+
build-wasm:
84+
needs: create-release
85+
name: Build
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
- uses: moonrepo/setup-rust@v1
90+
with:
91+
cache: false
92+
targets: wasm32-wasi
93+
- id: build
94+
uses: moonrepo/build-wasm-plugin@v0
95+
- if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
96+
uses: ncipollo/release-action@v1
97+
with:
98+
artifacts: builds/*
99+
artifactErrorsFailBuild: true
100+
body: ${{ steps.build.outputs.changelog-entry }}
101+
prerelease: ${{ steps.build.outputs.prerelease == 'true' }}
102+
skipIfReleaseExists: true

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
# Huff Neo Compiler changelog
44

55
## [Unreleased]
6+
7+
## [1.1.7] - 2025-03-30
68
- Throw error if the argument count for a macro call is not equal to the macro definition (Fixes: #49).
79
- Fix error where an opcode could not be handled as second argument in a macro call (Fixes: #50).
10+
- Release `huff-neo-js` to npm.
811

912
## [1.1.6] - 2025-03-29
1013
- Throw an error if an argument (e.g. `<arg>`) is used but not defined (Fixes: #46).

Cargo.lock

Lines changed: 20 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ thiserror = "2.0.12"
4949
tokio = "1.44.1"
5050
tracing = "0.1.41"
5151
tracing-subscriber = { version = "0.3.19", default-features = false, features = ["env-filter", "fmt"] }
52-
uuid = { version = "1.16.0", features = ["v4"] }
52+
uuid = { version = "1.16.0", default-features = false, features = ["js", "v4"] }
5353
walkdir = "2.5.0"
5454
wasm-bindgen = "0.2.100"
5555
yansi = "1.0.1"
@@ -62,11 +62,11 @@ serde-wasm-bindgen = "0.6.5"
6262
serde_json = "1.0.140"
6363
strum = "0.27.1"
6464
strum_macros = "0.27.1"
65-
toml = "0.8.20"
65+
toml = { version = "0.8.20", default-features = false, features = ["parse"] }
6666

6767
# dev
6868
criterion = "0.5.1"
69-
getrandom = { version = "0.3.1", features = ["wasm_js"] }
69+
getrandom = { version = "0.3.2", features = ["wasm_js"] }
7070
rayon = "1.10.0"
7171

7272
[profile.test]

crates/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ rayon.workspace = true
3434

3535
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
3636
getrandom.workspace = true
37+
uuid = { workspace = true, features = ["js"] }
3738

3839
[[bench]]
3940
harness = false

crates/core/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,12 +546,10 @@ impl<'a, 'l> Compiler<'a, 'l> {
546546
}
547547

548548
// Now that we have all the file sources, we have to recurse and get their source
549-
let mut dependency_results = Vec::with_capacity(file_sources.len());
550-
551-
file_sources
549+
let dependency_results: Vec<_> = file_sources
552550
.into_par_iter()
553551
.map(|inner_fs| Self::recurse_deps(Arc::clone(&inner_fs), remapper, reader.clone(), walk_level.clone()))
554-
.collect_into_vec(&mut dependency_results);
552+
.collect();
555553

556554
// Verify that all dependencies were successfully fetched
557555
let mut dependencies = Vec::with_capacity(dependency_results.len());

0 commit comments

Comments
 (0)