jao 0.3.4

Discover and run workspace scripts from a simple CLI
name: Jao release CI

on:
  push:
    branches:
      - release
  workflow_dispatch:

concurrency:
  group: release-${{ github.ref }}
  cancel-in-progress: true

jobs:
  verify:
    name: verify (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - windows-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Install cargo-hack
        uses: taiki-e/install-action@cargo-hack

      - name: Build all feature combinations
        run: cargo hack build --locked --each-feature

  docs:
    name: docs
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Generate docs
        run: bash scripts/gen.docs.sh

  publish-docker:
    name: publish docker
    runs-on: ubuntu-latest
    needs:
      - verify
      - docs
    env:
      IMAGE_REPOSITORY: ${{ vars.DOCKERHUB_REPOSITORY }}
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Validate Docker Hub configuration
        run: |
          test -n "${IMAGE_REPOSITORY}"
          test -n "${{ vars.DOCKERHUB_USERNAME }}"
          test -n "${{ secrets.DOCKERHUB_TOKEN }}"

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ vars.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Read package version
        id: package-version
        shell: bash
        run: |
          version="$(grep '^version = "' Cargo.toml | head -n1 | cut -d'"' -f2)"
          test -n "${version}"
          echo "value=${version}" >> "${GITHUB_OUTPUT}"

      - name: Build and push latest image
        uses: docker/build-push-action@v6
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: |
            ${{ env.IMAGE_REPOSITORY }}:latest
            ${{ env.IMAGE_REPOSITORY }}:${{ steps.package-version.outputs.value }}

      - name: Build and push latest-no-manifest image
        uses: docker/build-push-action@v6
        with:
          context: .
          file: ./Dockerfile
          build-args: |
            CARGO_BUILD_ARGS=--no-default-features
          push: true
          tags: |
            ${{ env.IMAGE_REPOSITORY }}:latest-no-manifest
            ${{ env.IMAGE_REPOSITORY }}:${{ steps.package-version.outputs.value }}-no-manifest

  publish-crate:
    name: publish crate
    runs-on: ubuntu-latest
    needs:
      - verify
      - docs
    env:
      CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Validate crates.io token
        run: test -n "${CARGO_REGISTRY_TOKEN}"

      - name: Publish crate
        run: bash scripts/publish.sh --execute