devtool 0.8.23

A CLI tool for development in update rustup toolchain, mise maintained tools and homebrew packages.
name: Publish to Crates.io

on:
  push:
    tags: ["v*"]

env:
  CARGO_TERM_COLOR: always

jobs:
  publish-crates:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
      contents: read
      actions: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: ~/.cargo/registry
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache cargo index
        uses: actions/cache@v4
        with:
          path: ~/.cargo/git
          key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

      - name: Run tests
        run: cargo test --verbose

      - name: Authenticate with crates.io
        uses: rust-lang/crates-io-auth-action@v1
        id: auth

      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

      - name: Trigger GitHub Release
        if: success()
        run: |
          echo "Triggering GitHub Release workflow..."
          echo "Repository: ${{ github.repository }}"
          echo "Ref: master"

          VERSION=${GITHUB_REF#refs/tags/v}
          echo "Triggering release for version: $VERSION"

          RESPONSE=$(curl -s -w "HTTPSTATUS:%{http_code}" -X POST \
            -H "Accept: application/vnd.github.v3+json" \
            -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
            -H "Content-Type: application/json" \
            https://api.github.com/repos/${{ github.repository }}/actions/workflows/release.yml/dispatches \
            -d "{\"ref\":\"master\",\"inputs\":{\"version\":\"$VERSION\"}}")

          HTTP_STATUS=$(echo $RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
          BODY=$(echo $RESPONSE | sed -e 's/HTTPSTATUS:.*//g')

          echo "HTTP Status: $HTTP_STATUS"
          echo "Response: $BODY"

          if [ $HTTP_STATUS -eq 204 ]; then
            echo "✅ Successfully triggered GitHub Release workflow"
          else
            echo "❌ Failed to trigger GitHub Release workflow"
            exit 1
          fi