amari 0.19.1

Advanced mathematical computing library with geometric algebra, tropical algebra, and automatic differentiation
Documentation
name: Release (Legacy - Disabled)

on:
  # Disabled to prevent conflicts with publish.yml
  # push:
  #   tags:
  #     - 'v*'
  workflow_dispatch:
    inputs:
      version:
        description: 'Version to release (e.g., 0.1.0)'
        required: true
        type: string

jobs:
  build-and-publish:
    name: Build and Publish to NPM
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Install Node.js
        uses: actions/setup-node@v6
        with:
          node-version: '18'
          registry-url: 'https://registry.npmjs.org'

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown

      - name: Install wasm-pack
        run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

      - name: Build WASM packages
        run: |
          cd amari-wasm
          # Build for different targets
          wasm-pack build --target web --out-dir pkg --scope amari
          wasm-pack build --target nodejs --out-dir pkg-node --scope amari
          wasm-pack build --target bundler --out-dir pkg-bundler --scope amari

      - name: Configure package version
        if: github.event_name == 'workflow_dispatch'
        run: |
          cd amari-wasm
          npm version ${{ github.event.inputs.version }} --no-git-tag-version

      - name: Publish to NPM
        run: |
          cd amari-wasm/pkg
          npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          files: |
            amari-wasm/pkg/*.wasm
            amari-wasm/pkg/*.js
            amari-wasm/pkg/*.d.ts
          generate_release_notes: true
          draft: false
          prerelease: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  publish-crates:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    needs: build-and-publish
    steps:
      - uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Login to crates.io
        run: cargo login ${{ secrets.CRATES_TOKEN }}

      - name: Publish crates in order
        run: |
          # Function to publish crates with proper error handling
          publish_crate() {
            CRATE=$1
            echo "Publishing $CRATE..."
            set +e
            OUTPUT=$(cargo publish -p "$CRATE" --allow-dirty 2>&1)
            STATUS=$?
            set -e
            if [ $STATUS -ne 0 ]; then
              echo "$OUTPUT" | grep -q "already uploaded" && echo "$CRATE already published, continuing..." || (echo "$OUTPUT" && exit $STATUS)
            fi
          }

          # Publish in dependency order
          publish_crate amari-core
          sleep 10
          publish_crate amari-tropical
          publish_crate amari-dual
          publish_crate amari-info-geom
          sleep 10
          publish_crate amari-gpu
          publish_crate amari-fusion
          publish_crate amari-wasm
          publish_crate amari-automata