jvr 0.3.2

A simple and easy-to-use Java version manager (registry: jvr), similar to Node.js's nvm, but it does not follow nvm's naming convention. Otherwise, it would be named 'jvm', which could cause command conflicts or ambiguity.
Documentation
name: Cross-platform Release

on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'
      - 'v[0-9]+.[0-9]+.[0-9]+.[0-9]+'

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      matrix:
        include:
          # Linux
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            use-cross: true
          - os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
            use-cross: true
          # macOS
          - os: macos-latest
            target: x86_64-apple-darwin
            use-cross: false
          - os: macos-latest
            target: aarch64-apple-darwin
            use-cross: false
          # Windows
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            use-cross: false

    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Install cross (for Linux cross-compilation)
        if: ${{ matrix.use-cross }}
        uses: taiki-e/install-action@v2
        with:
          tool: cross

      - name: Get crate info (name & version)
        id: crate_info
        shell: bash
        run: |
          NAME=$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].name')
          VERSION=$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')
          echo "name=$NAME" >> "$GITHUB_OUTPUT"
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"

      - name: Build binary
        shell: bash
        run: |
          if ${{ matrix.use-cross }}; then
            cross build --target ${{ matrix.target }} --release
          else
            cargo build --target ${{ matrix.target }} --release
          fi

      - name: Package binary with standard naming
        shell: bash
        env:
          CRATE_NAME: ${{ steps.crate_info.outputs.name }}
          VERSION: ${{ steps.crate_info.outputs.version }}
          TARGET: ${{ matrix.target }}
        run: |
          set -e
          cd target/${TARGET}/release

          BINARY_NAME="$CRATE_NAME"
          if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
            BINARY_NAME="${BINARY_NAME}.exe"
          fi

          FILENAME="${CRATE_NAME}-${VERSION}-${TARGET}"
          if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
            7z a "../../../${FILENAME}.zip" "$BINARY_NAME"
          else
            tar czf "../../../${FILENAME}.tar.gz" "$BINARY_NAME"
          fi

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: release-${{ matrix.target }}
          path: |
            ${{ steps.crate_info.outputs.name }}-${{ steps.crate_info.outputs.version }}-${{ matrix.target }}.tar.gz
            ${{ steps.crate_info.outputs.name }}-${{ steps.crate_info.outputs.version }}-${{ matrix.target }}.zip

  publish:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: ./artifacts

      - name: Flatten artifacts directory (optional but cleaner)
        run: |
          mkdir -p release-assets
          find ./artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} ./release-assets/ \;

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: ./release-assets/*