shieldcontract 0.2.0

Advanced security analysis for blockchain platforms
Documentation
name: Release

on:
  push:
    tags:
      - 'v*'

permissions:
  contents: write

jobs:
  create-release:
    name: Create Release
    runs-on: ubuntu-latest
    outputs:
      release_id: ${{ steps.create_release.outputs.id }}
      upload_url: ${{ steps.create_release.outputs.upload_url }}
    steps:
      - uses: actions/checkout@v4
      
      - name: Create Release
        id: create_release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ github.ref_name }}
          name: ShieldContract ${{ github.ref_name }}
          draft: false
          prerelease: false
          generate_release_notes: true
          body: |
            ## ShieldContract ${{ github.ref_name }}
            
            ### What's New
            - See [CHANGELOG.md](https://github.com/KoushikGavini/ShieldContract/blob/main/CHANGELOG.md) for details
            
            ### Installation
            
            #### Pre-built binaries
            Download the appropriate binary for your platform from the assets below.
            
            #### From source
            ```bash
            cargo install --git https://github.com/KoushikGavini/ShieldContract --tag ${{ github.ref_name }}
            ```
            
            ### Checksums
            See `checksums.txt` in the release assets.

  build-release:
    name: Build Release
    needs: create-release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            binary: shieldcontract
            archive: tar.gz
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
            binary: shieldcontract
            archive: tar.gz
          - os: macos-latest
            target: x86_64-apple-darwin
            binary: shieldcontract
            archive: tar.gz
          - os: macos-latest
            target: aarch64-apple-darwin
            binary: shieldcontract
            archive: tar.gz
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Z3 (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt-get install -y z3 libz3-dev
          echo "Z3_SYS_Z3_HEADER=/usr/include/z3.h" >> $GITHUB_ENV
          if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-musl" ]]; then
            sudo apt-get install -y musl-tools
          fi
      
      - name: Install Z3 (macOS)
        if: matrix.os == 'macos-latest'
        run: |
          brew install z3
          echo "Z3_SYS_Z3_HEADER=$(brew --prefix)/include/z3.h" >> $GITHUB_ENV
      
      - name: Install Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: 1.82.0
          targets: ${{ matrix.target }}
      
      - name: Build
        run: cargo build --release --target ${{ matrix.target }}
      
      - name: Create archive
        run: |
          mkdir -p shieldcontract-${{ github.ref_name }}-${{ matrix.target }}
          cp target/${{ matrix.target }}/release/${{ matrix.binary }} shieldcontract-${{ github.ref_name }}-${{ matrix.target }}/
          cp README.md LICENSE shieldcontract-${{ github.ref_name }}-${{ matrix.target }}/
          tar czf shieldcontract-${{ github.ref_name }}-${{ matrix.target }}.tar.gz shieldcontract-${{ github.ref_name }}-${{ matrix.target }}
          echo "ASSET=shieldcontract-${{ github.ref_name }}-${{ matrix.target }}.tar.gz" >> $GITHUB_ENV
      
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.ASSET }}
          path: ${{ env.ASSET }}
      
      - name: Upload to release
        uses: softprops/action-gh-release@v2
        with:
          files: ${{ env.ASSET }}

  checksums:
    name: Generate Checksums
    needs: [create-release, build-release]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: ./artifacts
      
      - name: Move artifacts to root
        run: |
          find ./artifacts -name "*.tar.gz" | xargs -I {} mv {} ./
      
      - name: Generate checksums
        run: |
          sha256sum shieldcontract-*.tar.gz > checksums.txt || echo "No files to checksum"
          cat checksums.txt
      
      - name: Upload checksums to release
        uses: softprops/action-gh-release@v2
        with:
          files: checksums.txt