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
108 changes: 108 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: CI

env:
RUST_TOOLCHAIN: "1.90.0"

permissions:
contents: read

on:
pull_request:
branches: [main]
paths-ignore:
- "**/*.md"
- LICENSE
- "**/*.gitignore"
- .editorconfig
- docs/**

jobs:
validate-pr:
name: Validate PR source and version bump
runs-on: ubuntu-latest
steps:
- name: Checkout PR head
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch main branch for comparison
run: git fetch origin main:refs/remotes/origin/main

- name: Read versions (Cargo.toml)
id: versions
shell: bash
run: |
PR_CRATE_VER=$(grep -m1 '^version\s*=\s*"' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')
MAIN_CRATE_VER=$(git show origin/main:Cargo.toml | grep -m1 '^version\s*=\s*"' | sed -E 's/.*"([^"]+)".*/\1/')
echo "pr_crate_ver=$PR_CRATE_VER" >> $GITHUB_OUTPUT
echo "main_crate_ver=$MAIN_CRATE_VER" >> $GITHUB_OUTPUT
echo "PR Cargo.toml version: $PR_CRATE_VER"
echo "Main Cargo.toml version: $MAIN_CRATE_VER"

- name: Ensure workspace/package versions match (if both present)
if: ${{ github.event.pull_request.base.ref == 'main' }}
shell: bash
run: |
set -euo pipefail
PKG_VER=$(grep -m1 '^version\s*=\s*"' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/' || true)
WS_VER=$(awk '/^\[workspace.package\]/{f=1;next} /^\[/{f=0} f && /^version\s*=/{print; exit}' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/' || true)
if [ -n "${WS_VER}" ] && [ -n "${PKG_VER}" ] && [ "${WS_VER}" != "${PKG_VER}" ]; then
echo "[workspace.package].version (${WS_VER}) does not match [package].version (${PKG_VER}). Please keep them in sync before merging to main." >&2
exit 1
fi

- name: Ensure version increased
if: ${{ github.event.pull_request.base.ref == 'main' }}
shell: bash
run: |
cmp_versions () { [ "$1" = "$2" ] && return 1; printf '%s\n%s\n' "$2" "$1" | sort -V | head -n1 | grep -q "^$2$"; }
if ! cmp_versions "${{ steps.versions.outputs.pr_crate_ver }}" "${{ steps.versions.outputs.main_crate_ver }}"; then
echo "Cargo.toml version must be greater in the PR than on main (current: ${{ steps.versions.outputs.pr_crate_ver }}, main: ${{ steps.versions.outputs.main_crate_ver }})." >&2
exit 1
fi

rust-checks:
name: Rust checks (${{ matrix.os }})
needs: validate-pr
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4

# --- Rust toolchain ---
- name: Setup Rust toolchain (pinned)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: clippy,rustfmt

- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Show versions
shell: bash
run: |
rustc -Vv
cargo -V
echo "Running on: $(uname -a || echo windows)"

- name: Test
run: cargo test --all-features

- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Fmt
run: cargo fmt --all -- --check
104 changes: 104 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Release on push to main

env:
RUST_TOOLCHAIN: "1.75.0"

permissions:
contents: write
id-token: write

on:
push:
branches: [main]

jobs:
rust-tests:
name: Rust tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Rust toolchain (pinned)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Test
run: cargo test --all-features

create-release:
name: Create GitHub Release
needs: rust-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Read crate version
id: ver
shell: bash
run: |
set -euo pipefail
VERSION=$(grep -m1 '^version\s*=\s*"' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$VERSION" ]; then
echo "Failed to read version from Cargo.toml" >&2
exit 1
fi
echo "version=v$VERSION" >> "$GITHUB_OUTPUT"

- name: Create tag if missing
shell: bash
run: |
set -euo pipefail
TAG="${{ steps.ver.outputs.version }}"
if ! git rev-parse "$TAG" >/dev/null 2>&1; then
git tag "$TAG" "${GITHUB_SHA}"
git push origin "$TAG"
fi

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.ver.outputs.version }}
name: Release ${{ steps.ver.outputs.version }}
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-crates:
name: Publish to crates.io
needs: [rust-tests, create-release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Rust toolchain (pinned)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Check crates.io token is present
shell: bash
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ -z "${CARGO_REGISTRY_TOKEN}" ]; then
echo "CARGO_REGISTRY_TOKEN is empty/missing." >&2
exit 1
fi

- name: Publish crate
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --no-verify --allow-dirty
8 changes: 3 additions & 5 deletions Cargo.lock

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

12 changes: 4 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "action-layer-driver"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
rust-version = "1.75.0"
rust-version = "1.90.0"
description = "Generic driver for Action Layer (CHIP-0050) singleton spend construction on Chia"
license = "MIT"
authors = ["DIG Network"]
Expand Down Expand Up @@ -32,20 +32,16 @@ hex-literal = "0.4"
# Error handling
thiserror = "2"

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
anyhow = "1.0"

[workspace]
members = [
"examples/singlelaunch",
"examples/wallet",
]

[workspace.package]
version = "0.1.0"
version = "0.1.1"
edition = "2021"
rust-version = "1.75.0"
rust-version = "1.90.0"
license = "MIT"
authors = ["DIG Network"]

Expand Down
Loading