kimspect 0.0.45

The missing utility in kubectl to help you inspect container images on your pods and nodes.
Documentation
name: release
on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+"

jobs:
  check_version:
    name: Check Cargo.toml version matches Git tag
    runs-on: ubuntu-latest
    outputs:
      tag_version: ${{ steps.get_version.outputs.TAG_VERSION }}
      cargo_version: ${{ steps.get_version.outputs.CARGO_VERSION }}
    steps:
      - uses: actions/checkout@v6
      - name: Install toml-cli
        run: cargo install toml-cli@0.2.3
      - name: Get versions
        id: get_version
        run: |
          TAG_VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
          CARGO_VERSION=$(toml get Cargo.toml package.version | tr -d '"')
          echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_OUTPUT
          echo "CARGO_VERSION=$CARGO_VERSION" >> $GITHUB_OUTPUT
      - name: Verify versions match
        run: |
          echo "Git tag version: ${{ steps.get_version.outputs.tag_version }}"
          echo "Cargo.toml version: ${{ steps.get_version.outputs.cargo_version }}"
          if [ "${{ steps.get_version.outputs.tag_version }}" != "${{ steps.get_version.outputs.cargo_version }}" ]; then
            echo "Error: Git tag version (${{ steps.get_version.outputs.tag_version }}) does not match Cargo.toml version (${{ steps.get_version.outputs.cargo_version }})."
            echo "Please run 'scripts/cargo_release.sh' to update the cargo version before generating tag."
            exit 1
          fi
  build:
    name: Build multi-platform binaries
    needs: check_version
    strategy:
      fail-fast: false
      matrix:
        platform:
          - { os: ubuntu-latest, target: x86_64-unknown-linux-musl }
          - { os: macos-latest, target: x86_64-apple-darwin }
          - { os: macos-latest, target: aarch64-apple-darwin }
          - { os: windows-latest, target: x86_64-pc-windows-msvc }
    runs-on: ${{ matrix.platform.os }}
    steps:
      - uses: actions/checkout@v6
      - name: Building ${{ matrix.platform.os }}-${{ matrix.platform.target }}
        uses: ./.github/actions/build-cli
        with:
          runner_os: ${{ matrix.platform.os }}
          target_platform: ${{ matrix.platform.target }}
      - name: Create compressed binary for krew on Windows environment
        if: matrix.platform.os == 'windows-latest'
        run: |
          Copy-Item -Path LICENSE -Destination target/${{ matrix.platform.target }}/release/
          Compress-Archive -Path target/${{ matrix.platform.target }}/release/kimspect.exe, target/${{ matrix.platform.target }}/release/LICENSE -DestinationPath target/${{ matrix.platform.target }}/release/kimspect-${{ matrix.platform.target }}.zip -Update
          Move-Item -Path target/${{ matrix.platform.target }}/release/kimspect.exe -Destination target/${{ matrix.platform.target }}/release/kimspect-${{ matrix.platform.target }}.exe -Force

      - name: Create compressed binary for krew on Unix-like environments
        if: matrix.platform.os != 'windows-latest'
        run: |
          cp LICENSE target/${{ matrix.platform.target }}/release/
          tar -czvf target/${{ matrix.platform.target }}/release/kimspect-${{ matrix.platform.target }}.tar.gz -C target/${{ matrix.platform.target }}/release kimspect LICENSE
          mv target/${{ matrix.platform.target }}/release/kimspect target/${{ matrix.platform.target }}/release/kimspect-${{ matrix.platform.target }}
      - name: Upload Build Artifact
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.platform.target }}
          path: |
            target/${{ matrix.platform.target }}/release/kimspect-${{ matrix.platform.target }}
            target/${{ matrix.platform.target }}/release/*.zip
            target/${{ matrix.platform.target }}/release/*.exe
            target/${{ matrix.platform.target }}/release/*.tar.gz

  release-github-homebrew-and-krew:
    name: Create github release, update Homebrew & Krew
    runs-on: ubuntu-latest
    needs: build
    permissions:
      contents: write
    concurrency:
      group: release-github-krew-and-homebrew
      cancel-in-progress: false
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
      - name: Download All Build Artifacts
        uses: actions/download-artifact@v8
        with:
          path: dist/
      - name: List downloaded files
        run: ls -lahR dist/

      - name: Create GitHub Release and Upload Assets
        id: create_release
        uses: softprops/action-gh-release@v3
        with:
          files: dist/**/*
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Update Homebrew Tap
        uses: ./.github/actions/update-homebrew
        with:
          tap_repo: koithos/homebrew-cli
          release_tag: ${{ github.ref_name }}
          repository: ${{ github.repository }}
          amd64_artifact_name: kimspect-x86_64-apple-darwin
          arm64_artifact_name: kimspect-aarch64-apple-darwin
          amd64_artifact_path: dist/x86_64-apple-darwin/kimspect-x86_64-apple-darwin
          arm64_artifact_path: dist/aarch64-apple-darwin/kimspect-aarch64-apple-darwin
          tap_token: ${{ secrets.HOMEBREW_TAP_TOKEN }}

      - name: Update new version for kimspect in krew-index
        uses: rajatjindal/krew-release-bot@v0.0.51
        with:
          krew_template_file: .krew/kimspect.yml

  release-cargo:
    name: Release to cargo.io
    runs-on: ubuntu-latest
    needs: [release-github-homebrew-and-krew]
    permissions:
      contents: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
      - name: Publish to crates.io
        uses: actions-rs/cargo@v1
        with:
          command: publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}