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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- uses: dtolnay/rust-toolchain@stable
with:
Expand Down
113 changes: 102 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,116 @@ on:

env:
IMAGE_NAME: monadfoundation/soteria
CARGO_TERM_COLOR: always

jobs:
artifacts:
runs-on: ubuntu-latest
binaries:
name: Build ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
platform:
- name: linux x86_64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: soteria-linux-x86_64

- name: linux arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
artifact: soteria-linux-arm64

# macOS Intel
- name: macos x86_64
runner: macos-15-intel
target: x86_64-apple-darwin
artifact: soteria-darwin-x86_64

# macOS Apple Silicon
- name: macos arm64
runner: macos-26
target: aarch64-apple-darwin
artifact: soteria-darwin-arm64

# Windows x86_64
- name: windows x86_64
runner: windows-latest
target: x86_64-pc-windows-msvc
artifact: soteria-windows-x86_64

# Windows ARM64
- name: windows arm64
runner: windows-11-arm
target: aarch64-pc-windows-msvc
artifact: soteria-windows-arm64

Comment on lines +49 to +53
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runner label 'windows-11-arm' doesn't exist in GitHub-hosted runners. GitHub Actions doesn't currently provide hosted Windows ARM64 runners. You would need to use self-hosted runners for Windows ARM64 builds or remove this platform from the matrix.

Suggested change
- name: windows arm64
runner: windows-11-arm
target: aarch64-pc-windows-msvc
artifact: soteria-windows-arm64

Copilot uses AI. Check for mistakes.
steps:
- uses: actions/checkout@v5
- name: Checkout
uses: actions/checkout@v6

- uses: dtolnay/rust-toolchain@stable
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.platform.target }}
components: rustfmt

- uses: Swatinem/rust-cache@v2
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.platform.target }}
cache-on-failure: true

- run: cargo build --release --locked --all-features -v

- name: Upload release version artifact
uses: actions/upload-artifact@v4
- name: Build release binary
run: cargo build --release --locked --all-features --target ${{ matrix.platform.target }} -v

- name: Prepare artifact (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p artifacts
cp target/${{ matrix.platform.target }}/release/soteria artifacts/
cd artifacts
tar -czvf ${{ matrix.platform.artifact }}.tar.gz soteria
rm soteria

- name: Prepare artifact (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path artifacts
Copy-Item "target/${{ matrix.platform.target }}/release/soteria.exe" -Destination "artifacts/"
Compress-Archive -Path "artifacts/soteria.exe" -DestinationPath "artifacts/${{ matrix.platform.artifact }}.zip"
Remove-Item "artifacts/soteria.exe"

- name: Upload artifact
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.platform.artifact }}
path: artifacts/*
if-no-files-found: error

publish:
name: Publish GitHub Release assets
runs-on: ubuntu-latest
needs: [binaries]
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v5
with:
path: dist
merge-multiple: true

- name: Update release and upload assets
uses: softprops/action-gh-release@v2
with:
name: soteria
path: ./target/release/soteria
generate_release_notes: true
fail_on_unmatched_files: true
files: |
dist/*.tar.gz
dist/*.zip

docker:
runs-on: ubuntu-latest
Expand All @@ -53,6 +140,10 @@ jobs:
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
sbom: true
provenance: mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "soteria"
authors = ["QEDK <[email protected]>"]
license = "Apache-2.0"
version = "0.1.0"
version = "0.1.6"
edition = "2024"

[dependencies]
Expand Down
201 changes: 201 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
name: 'run soteria CLI'
description: 'uses the soteria CLI to validate safe transaction hashes in JSON log files'
author: 'Monad Foundation'

branding:
icon: 'shield'
color: 'purple'

inputs:
directory:
description: 'Path to the directory containing JSON files to validate'
required: true
version:
description: 'Version of Soteria to use (e.g., "v0.1.5" or "latest")'
required: false
default: 'latest'
github-token:
description: 'GitHub token for API requests (to avoid rate limiting)'
required: false
default: ${{ github.token }}
fail-on-error:
description: 'Whether to fail the workflow if validation errors are found'
required: false
default: 'true'

outputs:
validation-result:
description: 'The result of the validation (success or failure)'
value: ${{ steps.run-soteria.outputs.result }}
soteria-version:
description: 'The version of Soteria that was used'
value: ${{ steps.download.outputs.tag_name }}

runs:
using: 'composite'
steps:
- name: Determine platform
id: platform
shell: bash
run: |
OS="${{ runner.os }}"
ARCH="${{ runner.arch }}"
case "$OS" in
Linux)
case "$ARCH" in
X64)
echo "target=x86_64-unknown-linux-gnu" >> $GITHUB_OUTPUT
echo "asset_pattern=soteria-*linux*x86_64*" >> $GITHUB_OUTPUT
echo "fallback_pattern=soteria*linux*" >> $GITHUB_OUTPUT
;;
ARM64)
echo "target=aarch64-unknown-linux-gnu" >> $GITHUB_OUTPUT
echo "asset_pattern=soteria-*linux*aarch64*" >> $GITHUB_OUTPUT
echo "fallback_pattern=soteria*linux*arm*" >> $GITHUB_OUTPUT
;;
*)
echo "::error::Unsupported architecture: $ARCH"
exit 1
;;
esac
;;
macOS)
case "$ARCH" in
X64)
echo "target=x86_64-apple-darwin" >> $GITHUB_OUTPUT
echo "asset_pattern=soteria-*darwin*x86_64*" >> $GITHUB_OUTPUT
echo "fallback_pattern=soteria*darwin*" >> $GITHUB_OUTPUT
;;
ARM64)
echo "target=aarch64-apple-darwin" >> $GITHUB_OUTPUT
echo "asset_pattern=soteria-*darwin*aarch64*" >> $GITHUB_OUTPUT
echo "fallback_pattern=soteria*darwin*arm*" >> $GITHUB_OUTPUT
;;
*)
echo "::error::Unsupported architecture: $ARCH"
exit 1
;;
esac
;;
Windows)
echo "target=x86_64-pc-windows-msvc" >> $GITHUB_OUTPUT
echo "asset_pattern=soteria-*windows*x86_64*" >> $GITHUB_OUTPUT
echo "fallback_pattern=soteria*windows*" >> $GITHUB_OUTPUT
Comment on lines +82 to +84
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows platform detection doesn't handle ARM64 architecture. The case statement only sets x86_64 target regardless of the ARCH value, which means Windows ARM64 runners would incorrectly use the x86_64 target instead of aarch64-pc-windows-msvc.

Suggested change
echo "target=x86_64-pc-windows-msvc" >> $GITHUB_OUTPUT
echo "asset_pattern=soteria-*windows*x86_64*" >> $GITHUB_OUTPUT
echo "fallback_pattern=soteria*windows*" >> $GITHUB_OUTPUT
case "$ARCH" in
X64)
echo "target=x86_64-pc-windows-msvc" >> $GITHUB_OUTPUT
echo "asset_pattern=soteria-*windows*x86_64*" >> $GITHUB_OUTPUT
echo "fallback_pattern=soteria*windows*" >> $GITHUB_OUTPUT
;;
ARM64)
echo "target=aarch64-pc-windows-msvc" >> $GITHUB_OUTPUT
echo "asset_pattern=soteria-*windows*aarch64*" >> $GITHUB_OUTPUT
echo "fallback_pattern=soteria*windows*arm*" >> $GITHUB_OUTPUT
;;
*)
echo "::error::Unsupported architecture: $ARCH"
exit 1
;;
esac

Copilot uses AI. Check for mistakes.
;;
*)
echo "::error::Unsupported operating system: $OS"
exit 1
;;
esac
echo "os=$OS" >> $GITHUB_OUTPUT
echo "arch=$ARCH" >> $GITHUB_OUTPUT
- name: Download Soteria binary
id: download
uses: robinraju/release-downloader@v1
with:
repository: 'monad-developers/soteria'
latest: ${{ inputs.version == 'latest' }}
tag: ${{ inputs.version != 'latest' && inputs.version || '' }}
fileName: '*'
out-file-path: '${{ runner.temp }}/soteria-download'
extract: true
token: ${{ inputs.github-token }}

- name: Find and setup Soteria binary
id: setup
shell: bash
run: |
DOWNLOAD_DIR="${{ runner.temp }}/soteria-download"
INSTALL_DIR="${{ runner.temp }}/soteria-bin"
mkdir -p "$INSTALL_DIR"
echo "Looking for Soteria binary in: $DOWNLOAD_DIR"
ls -la "$DOWNLOAD_DIR" || true
# Look for the binary - try various patterns
BINARY=""
# First, try to find a binary matching the platform
for pattern in "soteria" "soteria-${{ steps.platform.outputs.target }}" "soteria_${{ steps.platform.outputs.target }}"; do
if [ -f "$DOWNLOAD_DIR/$pattern" ]; then
BINARY="$DOWNLOAD_DIR/$pattern"
break
fi
if [ -f "$DOWNLOAD_DIR/${pattern}.exe" ]; then
BINARY="$DOWNLOAD_DIR/${pattern}.exe"
break
fi
done
# If not found, search recursively for any soteria binary
if [ -z "$BINARY" ]; then
BINARY=$(find "$DOWNLOAD_DIR" -type f \( -name "soteria" -o -name "soteria.exe" -o -name "soteria-*" \) 2>/dev/null | head -n 1)
fi
if [ -z "$BINARY" ] || [ ! -f "$BINARY" ]; then
echo "::warning::No pre-built binary found. Building from source..."
# Install Rust if needed
if ! command -v cargo &> /dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'source' command on line 144 is a bash-specific builtin and may not work in Windows Git Bash or other non-standard shells. Consider using dot notation (. "$HOME/.cargo/env") which is POSIX-compliant, or check if this step should be skipped on Windows entirely since the cargo install fallback doesn't handle Windows properly (see the .exe extension issue on lines 151-152).

Suggested change
source "$HOME/.cargo/env"
. "$HOME/.cargo/env"

Copilot uses AI. Check for mistakes.
fi
# Install soteria from source
cargo install --git https://github.com/monad-developers/soteria.git --root "$INSTALL_DIR"
BINARY="$INSTALL_DIR/bin/soteria"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build command on line 149 will produce a binary at '$INSTALL_DIR/bin/soteria.exe' on Windows, not '$INSTALL_DIR/bin/soteria'. The code should handle the Windows .exe extension when setting BINARY path after cargo install.

Suggested change
BINARY="$INSTALL_DIR/bin/soteria"
if [ "${{ runner.os }}" = "Windows" ]; then
BINARY="$INSTALL_DIR/bin/soteria.exe"
else
BINARY="$INSTALL_DIR/bin/soteria"
fi

Copilot uses AI. Check for mistakes.
else
cp "$BINARY" "$INSTALL_DIR/soteria"
BINARY="$INSTALL_DIR/soteria"
Comment on lines +151 to +152
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback pattern for Windows on line 151 will fail because it copies to 'soteria' without the .exe extension, but on Windows the binary is named 'soteria.exe'. This should append .exe for Windows platforms to match the actual binary name.

Suggested change
cp "$BINARY" "$INSTALL_DIR/soteria"
BINARY="$INSTALL_DIR/soteria"
if [ "${{ runner.os }}" = "Windows" ]; then
cp "$BINARY" "$INSTALL_DIR/soteria.exe"
BINARY="$INSTALL_DIR/soteria.exe"
else
cp "$BINARY" "$INSTALL_DIR/soteria"
BINARY="$INSTALL_DIR/soteria"
fi

Copilot uses AI. Check for mistakes.
fi
# Make executable (on Unix systems)
if [ "${{ runner.os }}" != "Windows" ]; then
chmod +x "$BINARY"
fi
echo "binary_path=$BINARY" >> $GITHUB_OUTPUT
echo "Binary location: $BINARY"
# Verify binary
"$BINARY" --help || "$BINARY" -h || echo "Binary verification skipped"
- name: Run Soteria validation
id: run-soteria
shell: bash
run: |
BINARY="${{ steps.setup.outputs.binary_path }}"
DIRECTORY="${{ inputs.directory }}"
echo "Running Soteria on directory: $DIRECTORY"
echo "Using binary: $BINARY"
# Validate directory exists
if [ ! -d "$DIRECTORY" ]; then
echo "::error::Directory does not exist: $DIRECTORY"
exit 1
fi
# Run soteria
set +e
OUTPUT=$("$BINARY" "$DIRECTORY" 2>&1)
EXIT_CODE=$?
set -e
echo "$OUTPUT"
if [ $EXIT_CODE -eq 0 ]; then
echo "result=success" >> $GITHUB_OUTPUT
echo "::notice::Soteria validation completed successfully"
else
echo "result=failure" >> $GITHUB_OUTPUT
if [ "${{ inputs.fail-on-error }}" == "true" ]; then
echo "::error::Soteria validation failed"
exit $EXIT_CODE
else
echo "::warning::Soteria validation found issues (exit code: $EXIT_CODE)"
fi
fi