proc-cli 2.0.2

Semantic CLI tool for process management. Target by port, PID, name or path.
Documentation
name: Docker

on:
  push:
    tags:
      - 'v*'

env:
  REGISTRY: docker.io
  IMAGE_NAME: yazeed/proc-cli
  # The image's original name. Docker Hub can't rename repositories, so the
  # same build is pushed here too and existing `docker pull yazeed/proc` users
  # keep getting updates.
  LEGACY_IMAGE_NAME: yazeed/proc
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
  docker:
    name: Build and Push
    runs-on: ubuntu-latest
    permissions:
      contents: read

    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

      # The image is tagged with the git tag's version, so a tag that doesn't
      # match Cargo.toml would publish an image under the wrong version
      - name: Check the tag matches Cargo.toml
        run: |
          want=$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -1)
          if [ "${GITHUB_REF_NAME#v}" != "$want" ]; then
            echo "::error::tag $GITHUB_REF_NAME doesn't match Cargo.toml's version $want"
            exit 1
          fi

      - name: Set up QEMU
        uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0

      - name: Log in to Docker Hub
        uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Extract version from tag
        id: version
        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

      - name: Build and push
        uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: |
            ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}
            ${{ env.IMAGE_NAME }}:latest
            ${{ env.LEGACY_IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}
            ${{ env.LEGACY_IMAGE_NAME }}:latest
          cache-from: type=gha
          cache-to: type=gha,mode=max

      - name: Update Docker Hub description
        uses: peter-evans/dockerhub-description@432a30c9e07499fd01da9f8a49f0faf9e0ca5b77 # v4.0.2
        continue-on-error: true
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
          repository: ${{ env.IMAGE_NAME }}
          short-description: "Semantic CLI tool for process management. Target by port, PID, name or path."
          readme-filepath: ./README.md

      - name: Update Docker Hub description (original image name)
        uses: peter-evans/dockerhub-description@432a30c9e07499fd01da9f8a49f0faf9e0ca5b77 # v4.0.2
        continue-on-error: true
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
          repository: ${{ env.LEGACY_IMAGE_NAME }}
          short-description: "Now published as yazeed/proc-cli (same image). Semantic CLI tool for process management."
          readme-filepath: ./README.md