wirepusher 1.0.0-alpha.2

Official Rust Client Library for WirePusher - Send push notifications with async/await support
Documentation
# Cloud Build configuration for WirePusher Rust SDK
# Runs tests, code coverage checks, and builds the package

steps:
  # Step 1: Restore dependencies
  - name: 'rust:latest'
    id: 'fetch'
    entrypoint: 'cargo'
    args:
      - 'fetch'
      - '--locked'

  # Step 2: Build in release mode
  - name: 'rust:latest'
    id: 'build'
    entrypoint: 'cargo'
    waitFor: ['fetch']
    args:
      - 'build'
      - '--release'
      - '--locked'

  # Step 3: Run tests
  - name: 'rust:latest'
    id: 'test'
    entrypoint: 'cargo'
    waitFor: ['build']
    args:
      - 'test'
      - '--locked'

  # Step 4: Check coverage with tarpaulin (90% threshold)
  - name: 'rust:latest'
    id: 'coverage'
    entrypoint: 'bash'
    waitFor: ['test']
    args:
      - '-c'
      - |
        cargo install cargo-tarpaulin --locked
        cargo tarpaulin --out Xml --output-dir ./coverage --locked

        # Extract line coverage percentage
        if [ -f coverage/cobertura.xml ]; then
          COV_RATE=$$(grep -oP 'line-rate="\K[0-9.]+' coverage/cobertura.xml | head -1)
          COV_PCT=$$(echo "$$COV_RATE * 100" | bc)
          echo "Line coverage: $$COV_PCT%"

          # Check if coverage meets threshold
          if (( $$(echo "$$COV_RATE < 0.80" | bc -l) )); then
            echo "ERROR: Coverage $$COV_PCT% is below 80% threshold"
            exit 1
          fi

          echo "Coverage threshold met (>= 80%)"
        else
          echo "ERROR: Coverage report not found"
          exit 1
        fi

  # Step 5: Run clippy (linter)
  - name: 'rust:latest'
    id: 'clippy'
    entrypoint: 'bash'
    waitFor: ['build']
    args:
      - '-c'
      - |
        rustup component add clippy
        cargo clippy --all-targets --locked -- -D warnings

  # Step 6: Check formatting
  - name: 'rust:latest'
    id: 'fmt'
    entrypoint: 'bash'
    waitFor: ['fetch']
    args:
      - '-c'
      - |
        rustup component add rustfmt
        cargo fmt -- --check

  # Step 7: Build documentation
  - name: 'rust:latest'
    id: 'docs'
    entrypoint: 'cargo'
    waitFor: ['build']
    args:
      - 'doc'
      - '--no-deps'
      - '--locked'

  # Step 8: Package the crate
  - name: 'rust:latest'
    id: 'package'
    entrypoint: 'cargo'
    waitFor: ['coverage', 'clippy', 'fmt']
    args:
      - 'package'
      - '--locked'
      - '--allow-dirty'

  # Step 9: Publish to crates.io (ONLY on Git tags)
  # Requires CRATES_IO_TOKEN secret
  - name: 'rust:latest'
    id: 'publish'
    entrypoint: 'bash'
    waitFor: ['package']
    secretEnv: ['CRATES_IO_TOKEN']
    args:
      - '-c'
      - |
        if [ -n "$TAG_NAME" ]; then
          echo "Publishing version $TAG_NAME to crates.io..."
          cargo publish --token "$$CRATES_IO_TOKEN" --locked --allow-dirty
          echo ""
          echo "Successfully published $TAG_NAME to crates.io!"
          echo "View at: https://crates.io/crates/wirepusher"
        else
          echo "Skipping crates.io publish (not a tagged release)"
          echo "To publish: git tag v1.0.0 && git push origin v1.0.0"
        fi

  # Step 10: Send notification on successful release (only on tags)
  - name: 'curlimages/curl:latest'
    id: 'notify-release'
    waitFor: ['publish']
    entrypoint: 'sh'
    secretEnv: ['WIREPUSHER_TOKEN']
    args:
      - '-c'
      - |
        if [ -z "$TAG_NAME" ]; then
          echo "=== No Git tag detected ==="
          echo "Skipping notification (only runs on tags)"
          exit 0
        fi

        echo "=== Sending release notification via NotifAI ==="
        curl -s -X POST https://api.wirepusher.dev/notifai \
          -H "Authorization: Bearer $$WIREPUSHER_TOKEN" \
          -H "Content-Type: application/json" \
          -d "{
            \"text\": \"WirePusher Rust SDK $TAG_NAME released to crates.io successfully. Add wirepusher = version to Cargo.toml. View package at https://crates.io/crates/wirepusher\",
            \"type\": \"release\"
          }"

        echo ""
        echo "✓ Release notification sent via NotifAI"

timeout: '600s'
options:
  machineType: 'E2_HIGHCPU_8'
  logging: CLOUD_LOGGING_ONLY

# Artifacts to save
artifacts:
  objects:
    location: 'gs://${PROJECT_ID}_cloudbuild/artifacts/rust-sdk/${BUILD_ID}'
    paths:
      - 'target/package/*.crate'
      - 'target/doc/**'
      - 'coverage/*'

# Secret Manager secrets
availableSecrets:
  secretManager:
    - versionName: projects/$PROJECT_ID/secrets/crates-io-token/versions/latest
      env: 'CRATES_IO_TOKEN'
    - versionName: projects/$PROJECT_ID/secrets/wirepusher-token/versions/latest
      env: 'WIREPUSHER_TOKEN'