anya-core 1.2.0

Enterprise-grade Bitcoin Infrastructure Platform
Documentation
name: Release & Deployment

on:
  push:
    tags: ['v*']
  workflow_dispatch:
    inputs:
      version:
        description: 'Release version'
        required: true
        type: string

# Explicitly define permissions for GITHUB_TOKEN
permissions:
  contents: write  # Needed for release creation and file updates
  pull-requests: write  # Needed for PR creation

env:
  RUST_BACKTRACE: 1

jobs:
  pre-release-validation:
    name: Pre-Release Validation
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        
      - name: Pre-release Verification
        run: |
          echo "🔍 Running pre-release verification..."
          chmod +x scripts/verify_implementation_status.sh
          ./scripts/verify_implementation_status.sh
          
          # Strict release requirements
          UNIMPL_COUNT=$(grep -r "unimplemented!" --include="*.rs" . | wc -l)
          TODO_COUNT=$(grep -r "todo!" --include="*.rs" . | wc -l)
          MOCK_COUNT=$(grep -r "MockImpl\|placeholder\|FIXME" --include="*.rs" . | wc -l)
          
          echo "Unimplemented functions: $UNIMPL_COUNT"
          echo "TODO stubs: $TODO_COUNT"
          echo "Mock implementations: $MOCK_COUNT"
          
          # Release gate - no unimplemented functions allowed
          if [ "$UNIMPL_COUNT" -gt 0 ]; then
            echo "❌ Cannot release with $UNIMPL_COUNT unimplemented functions"
            echo "❌ All unimplemented!() macros must be replaced with real code"
            exit 1
          fi
          
          echo "✅ Pre-release validation passed"
          
      - name: Build Release
        run: |
          cargo build --release --all-features
          cargo test --release --all-features
        
      - name: Create Release
        uses: softprops/action-gh-release@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          files: |
            target/release/anya-core
            target/release/anya-cli
          draft: false
          prerelease: false
          
      - name: Update Version
        uses: actions/github-script@v7
        with:
          script: |
            const tag = context.ref.replace('refs/tags/', '');
            const version = tag.replace('v', '');
            
            // Update Cargo.toml version
            const cargoToml = await github.rest.repos.getContent({
              owner: context.repo.owner,
              repo: context.repo.repo,
              path: 'Cargo.toml'
            });
            
            const content = Buffer.from(cargoToml.data.content, 'base64').toString();
            const updatedContent = content.replace(
              /^version = ".*"$/m,
              `version = "${version}"`
            );
            
            await github.rest.repos.createOrUpdateFileContents({
              owner: context.repo.owner,
              repo: context.repo.repo,
              path: 'Cargo.toml',
              message: `chore: bump version to ${version}`,
              content: Buffer.from(updatedContent).toString('base64'),
              sha: cargoToml.data.sha
            });
            
      - name: Create Release PR
        uses: actions/github-script@v7
        with:
          script: |
            const tag = context.ref.replace('refs/tags/', '');
            const version = tag.replace('v', '');
            
            await github.rest.pulls.create({
              owner: context.repo.owner,
              repo: context.repo.repo,
              title: `chore: release ${version}`,
              head: `release/${version}`,
              base: 'main',
              body: `Release version ${version}\n\nChanges:\n- Updated version in Cargo.toml\n- Created release artifacts`
            });