Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ on:
workflow_dispatch:

jobs:
version-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Check version consistency
run: bash ./scripts/check-version-consistency.sh

build-mac-arm:
runs-on: macos-latest
needs: version-check
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -45,6 +55,7 @@ jobs:

build-mac-amd:
runs-on: macos-latest
needs: version-check
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -84,6 +95,7 @@ jobs:

build-linux-arm:
runs-on: ubuntu-latest
needs: version-check
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -129,6 +141,7 @@ jobs:

build-linux-amd:
runs-on: ubuntu-latest
needs: version-check
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -168,6 +181,7 @@ jobs:

build-linux-armv7:
runs-on: ubuntu-latest
needs: version-check
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -216,6 +230,7 @@ jobs:

build-linux-riscv:
runs-on: ubuntu-latest
needs: version-check
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -261,6 +276,7 @@ jobs:

build-npm-package:
runs-on: ubuntu-latest
needs: version-check
defaults:
run:
working-directory: ./helios-ts
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ env:
SEPOLIA_EXECUTION_RPC: ${{ secrets.SEPOLIA_EXECUTION_RPC }}

jobs:
version-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Check version consistency
run: bash ./scripts/check-version-consistency.sh

check:
runs-on: ubuntu-latest
needs: version-check
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
Expand All @@ -28,6 +38,7 @@ jobs:

test:
runs-on: ubuntu-latest
needs: version-check
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
Expand All @@ -45,6 +56,7 @@ jobs:

fmt:
runs-on: ubuntu-latest
needs: version-check
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
Expand All @@ -61,6 +73,7 @@ jobs:

clippy:
runs-on: ubuntu-latest
needs: version-check
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
Expand All @@ -76,6 +89,7 @@ jobs:
args: --all -- -D warnings
wasm-compatibility:
runs-on: ubuntu-latest
needs: version-check
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
Expand Down
4 changes: 2 additions & 2 deletions helios-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion helios-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@a16z/helios",
"description": "A fast, secure, and portable multichain light client for Ethereum",
"version": "0.9.0",
"version": "0.9.3",
"main": "./dist/lib.umd.js",
"module": "./dist/lib.mjs",
"types": "./dist/lib.d.ts",
Expand Down
94 changes: 94 additions & 0 deletions scripts/check-version-consistency.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

set -euo pipefail

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

echo "Checking version consistency between Cargo.toml and helios-ts/package.json..."

# Function to extract version from Cargo.toml
get_workspace_version() {
# First try direct version in [package] section
local version=$(grep -E '^version = ' Cargo.toml 2>/dev/null | head -1 | sed 's/.*= "\(.*\)"/\1/' || true)

# If no direct version, check workspace version
if [ -z "$version" ]; then
version=$(grep -A 5 '\[workspace.package\]' Cargo.toml | grep 'version = ' | sed 's/.*= "\(.*\)"/\1/' || true)
fi

echo "$version"
}

# Function to extract version from package.json
get_ts_version() {
if command -v jq >/dev/null 2>&1; then
jq -r '.version' helios-ts/package.json
else
# Fallback if jq is not available
grep '"version"' helios-ts/package.json | sed 's/.*"version": "\(.*\)".*/\1/'
fi
}

# Function to validate semantic version format
validate_version_format() {
local version="$1"
if ! echo "$version" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\-\.]*)?(\+[a-zA-Z0-9\-\.]*)?$' >/dev/null; then
return 1
fi
return 0
}

# Main version check
main() {
local cargo_version=$(get_workspace_version)
local package_version=$(get_ts_version)

echo -e "Cargo.toml workspace version: ${YELLOW}${cargo_version}${NC}"
echo -e "helios-ts/package.json version: ${YELLOW}${package_version}${NC}"

# Check if versions were found
if [ -z "$cargo_version" ]; then
echo -e "${RED}Could not find version in Cargo.toml${NC}"
exit 1
fi

if [ -z "$package_version" ]; then
echo -e "${RED}Could not find version in helios-ts/package.json${NC}"
exit 1
fi

# Validate version formats
if ! validate_version_format "$cargo_version"; then
echo -e "${RED}Invalid version format in Cargo.toml: $cargo_version${NC}"
echo "Version must follow semantic versioning (e.g., 1.2.3, 1.2.3-beta.1)"
exit 1
fi

if ! validate_version_format "$package_version"; then
echo -e "${RED}Invalid version format in package.json: $package_version${NC}"
echo "Version must follow semantic versioning (e.g., 1.2.3, 1.2.3-beta.1)"
exit 1
fi

# Compare versions
if [ "$cargo_version" != "$package_version" ]; then
echo -e "${RED}Version mismatch detected!${NC}"
echo ""
echo "The versions in the following files do not match:"
echo " • Cargo.toml [workspace.package]: $cargo_version"
echo " • helios-ts/package.json: $package_version"
echo ""
echo "To fix this, ensure both files have the same version specified."
exit 1
fi

echo -e "${GREEN}Versions are consistent: $cargo_version${NC}"
echo "Version check passed!"
}

# Run main function
main "$@"
Loading