dvm 1.9.3

Deno Version Manager - Easy way to manage multiple active deno versions.
name: ci

on: [push, pull_request]

jobs:
  build:
    name: ${{ matrix.kind }} ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
          - macOS-13  # Intel
          - macOS-latest  # Apple Silicon
          - windows-latest

    env:
      CARGO_INCREMENTAL: 0
      RUST_BACKTRACE: full
      CARGO_TERM_COLOR: always

    steps:
      - name: Clone repository
        uses: actions/checkout@v3

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          components: rustfmt, clippy

      - name: Install rust
        uses: hecrj/setup-rust-action@v1

      - name: Install clippy and rustfmt
        run: |
          rustup component add clippy
          rustup component add rustfmt

      - name: Log versions
        run: |
          rustc --version
          cargo --version

      - name: Cache
        uses: actions/cache@v3
        with:
          path: |-
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/*/.*
            target/*/build
            target/*/deps
          key:
            ${{ matrix.config.os }}-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ matrix.config.os }}-

      - name: Run cargo fmt
        run: cargo fmt --all -- --check

      - name: Run cargo check
        run: cargo check --locked

      - name: Run cargo clippy
        run: cargo clippy -- -D warnings

      - name: Build release
        run: cargo build --release --locked

      - name: Run cargo test
        run: cargo test --locked

      - name: Test install from local file (bash)
        if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macOS')
        run: ./install.sh ./target/release/dvm

      - name: Pre-release (linux)
        if: startsWith(matrix.os, 'ubuntu')
        run: zip -r dvm-x86_64-unknown-linux-gnu.zip dvm
        working-directory: target/release

      - name: Pre-release (linux-aarch64)
        if: startsWith(matrix.os, 'ubuntu')
        run: zip -r dvm-aarch64-unknown-linux-gnu.zip dvm
        working-directory: target/release

      - name: Pre-release (mac)
        if: matrix.os == 'macOS-13'
        run: zip -r dvm-x86_64-apple-darwin.zip dvm
        working-directory: target/release

      - name: Pre-release (aarch64-apple-darwin)
        if: matrix.os == 'macOS-latest'
        run: zip -r dvm-aarch64-apple-darwin.zip dvm
        working-directory: target/release

      - name: Pre-release (windows)
        if: startsWith(matrix.os, 'windows')
        run: |
          Compress-Archive -CompressionLevel Optimal -Force -Path target/release/dvm.exe -DestinationPath target/release/dvm-x86_64-pc-windows-msvc.zip

      - name: Release
        uses: softprops/action-gh-release@v1
        if: |
          startsWith(github.repository, 'justjavac') &&
          startsWith(github.ref, 'refs/tags/')
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          files: |
            target/release/dvm-x86_64-pc-windows-msvc.zip
            target/release/dvm-x86_64-unknown-linux-gnu.zip
            target/release/dvm-x86_64-apple-darwin.zip
            target/release/dvm-aarch64-apple-darwin.zip
            target/release/dvm-aarch64-unknown-linux-gnu.zip
          draft: true

      - name: Release DVM
        uses: justjavac/action-dvm-release@v1
        if: |
          startsWith(github.repository, 'justjavac') &&
          startsWith(github.ref, 'refs/tags/')
        env:
          GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
        with:
          files: |
            target/release/dvm-x86_64-pc-windows-msvc.zip
            target/release/dvm-x86_64-unknown-linux-gnu.zip
            target/release/dvm-x86_64-apple-darwin.zip
            target/release/dvm-aarch64-apple-darwin.zip
            target/release/dvm-aarch64-unknown-linux-gnu.zip

      - name: Publish
        if: |
          startsWith(matrix.os, 'ubuntu') &&
          startsWith(github.repository, 'justjavac') &&
          startsWith(github.ref, 'refs/tags/')
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          cargo publish