pic-protocol 0.1.6

PIC Protocol - Provenance Identity Continuity Protocol
Documentation
# Copyright 2025 Nitro Agility S.r.l.
#
# Licensed under the Apache License, Version 2.0 (the "License")
# ...

name: Publish to crates.io

on:
  push:
    tags:
      - "v*.*.*"

permissions:
  contents: read

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Repository
      uses: actions/checkout@v4

    - name: Set up Rust
      uses: dtolnay/rust-toolchain@stable

    - name: Extract Version from Tag
      run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

    - name: Bump version in Cargo.toml
      run: |
        # Unica riga version = "..." รจ in [workspace.package]
        sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml

    - name: Debug - Verify versions
      run: |
        echo "=== Expected: ${VERSION} ==="
        grep -E "^version" Cargo.toml || true
        grep -E "^version" crates/pic-pca/Cargo.toml || true
        grep -E "^version" crates/pic-cat/Cargo.toml || true

    - name: Build workspace
      run: cargo build --release --workspace

    - name: Run tests
      run: cargo test --workspace

    - name: Publish pic-pca
      run: cargo publish -p pic-pca --allow-dirty --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

    - name: Wait for crates.io
      run: sleep 30

    - name: Update pic-cat dependency
      run: sed -i "s|pic-pca = { path = \"../pic-pca\" }|pic-pca = \"${VERSION}\"|" crates/pic-cat/Cargo.toml

    - name: Publish pic-cat
      run: cargo publish -p pic-cat --allow-dirty --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

    - name: Wait for crates.io
      run: sleep 30

    - name: Update root dependencies
      run: |
        sed -i "s|pic-pca = { path = \"crates/pic-pca\" }|pic-pca = \"${VERSION}\"|" Cargo.toml
        sed -i "s|pic-cat = { path = \"crates/pic-cat\" }|pic-cat = \"${VERSION}\"|" Cargo.toml

    - name: Publish pic-protocol
      run: cargo publish --allow-dirty --token ${{ secrets.CARGO_REGISTRY_TOKEN }}