Skip to content
Latchkey

Release on Version Change workflow (ArcadeAI/arcade-mcp)

The Release on Version Change workflow from ArcadeAI/arcade-mcp, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: ArcadeAI/arcade-mcp.github/workflows/release-on-version-change.ymlLicense MITView source

What it does

This is the Release on Version Change workflow from the ArcadeAI/arcade-mcp repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
# This workflow is used to release packages to PyPI when its
# pyproject.toml version is changed or a new package is added.

name: Release on Version Change

on:
  push:
    branches:
      - main

jobs:
  detect-version-changes:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
      has-changes: ${{ steps.set-matrix.outputs.has-changes }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
        with:
          files: |
            **/pyproject.toml
          files_ignore: |
            examples/**
            libs/tests/**

      - name: Check for version changes or new packages
        id: check-versions
        if: steps.changed-files.outputs.any_changed == 'true'
        run: |
          ./.github/scripts/check-version-changes.sh "${{ steps.changed-files.outputs.all_changed_files }}"

      - name: Set matrix
        id: set-matrix
        run: |
          packages='${{ steps.check-versions.outputs.packages }}'
          if [ -z "$packages" ] || [ "$packages" = "[]" ]; then
            echo "has-changes=false" >> $GITHUB_OUTPUT
            echo "matrix={\"include\":[]}" >> $GITHUB_OUTPUT
          else
            echo "has-changes=true" >> $GITHUB_OUTPUT
            # Create matrix with package directories
            matrix=$(echo "$packages" | jq -c '{include: [.[] | {package: .}]}')
            echo "matrix=$matrix" >> $GITHUB_OUTPUT
            echo "Matrix: $matrix"
          fi

  build-and-test:
    needs: detect-version-changes
    if: needs.detect-version-changes.outputs.has-changes == 'true'
    runs-on: ubuntu-latest
    strategy:
      matrix: ${{ fromJson(needs.detect-version-changes.outputs.matrix) }}
    permissions:
      contents: write
      packages: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - name: Extract package name and version
        working-directory: ${{ matrix.package }}
        run: |
          # Extract package name
          PACKAGE_NAME=$(grep -m1 '^name = ' pyproject.toml | cut -d'"' -f2)
          echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV

          # Extract version
          VERSION=$(grep -m1 '^version = ' pyproject.toml | cut -d'"' -f2)
          echo "VERSION=$VERSION" >> $GITHUB_ENV

          echo "Building $PACKAGE_NAME version $VERSION"

      - name: Set up the environment
        uses: ./.github/actions/setup-uv-env
        with:
          python-version: "3.10"

      - name: Run tests
        working-directory: ${{ matrix.package }}
        run: |
          # Run tests if they exist
          if [ -f "Makefile" ] && grep -q "^test:" Makefile; then
            make test
          elif [ -f "../Makefile" ] && grep -q "^test:" ../Makefile; then
            cd .. && make test
          else
            echo "No tests found, skipping test step"
          fi

      - name: Build release distributions
        working-directory: ${{ matrix.package }}
        run: |
          uv build --out-dir dist | tee build.log

          # Validate wheel archives: PyPI rejects duplicate filenames in wheels
          python - <<'PY'
          from __future__ import annotations

          from pathlib import Path
          import sys
          import zipfile

          dist = Path("dist")
          wheels = sorted(dist.glob("*.whl"))
          if not wheels:
            print("No wheels found in dist/, skipping wheel validation.")
            raise SystemExit(0)

          for whl in wheels:
            with zipfile.ZipFile(whl) as zf:
              names = zf.namelist()

            seen: set[str] = set()
            dupes: set[str] = set()
            for name in names:
              if name in seen:
                dupes.add(name)
              else:
                seen.add(name)

            if dupes:
              print(f"ERROR: {whl} contains duplicate paths (PyPI will reject this wheel):", file=sys.stderr)
              for name in sorted(dupes):
                print(f"  - {name}", file=sys.stderr)
              raise SystemExit(1)

          print("Wheel validation OK (no duplicate filenames).")
          PY

          # Verify build artifacts
          ls -la dist/
          echo "Built artifacts for ${{ env.PACKAGE_NAME }} v${{ env.VERSION }}"

      - name: Upload release distributions
        uses: actions/upload-artifact@v7
        with:
          name: release-dists-${{ env.PACKAGE_NAME }}-${{ env.VERSION }}
          path: ${{ matrix.package }}/dist/

  pypi-publish:
    needs: [detect-version-changes, build-and-test]
    if: needs.detect-version-changes.outputs.has-changes == 'true'
    runs-on: ubuntu-latest
    strategy:
      matrix: ${{ fromJson(needs.detect-version-changes.outputs.matrix) }}
    permissions:
      id-token: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - name: Extract package name and version
        working-directory: ${{ matrix.package }}
        run: |
          PACKAGE_NAME=$(grep -m1 '^name = ' pyproject.toml | cut -d'"' -f2)
          echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV

          VERSION=$(grep -m1 '^version = ' pyproject.toml | cut -d'"' -f2)
          echo "VERSION=$VERSION" >> $GITHUB_ENV

      - name: Retrieve release distributions
        uses: actions/download-artifact@v8
        with:
          name: release-dists-${{ env.PACKAGE_NAME }}-${{ env.VERSION }}
          path: dist/

      - name: Publish release distributions to PyPI
        uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1

      - name: Send status to Slack
        if: always()
        uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
        with:
          webhook: ${{ secrets.PACKAGE_RELEASE_SLACK_WEBHOOK_URL }}
          webhook-type: webhook-trigger
          payload: |
            {
              "status": "${{ (job.status == 'failure' || job.status == 'cancelled') && 'Failed' || 'Success' }}",
              "package": "${{ env.PACKAGE_NAME }}",
              "version": "${{ env.VERSION }}",
              "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
            }

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

# This workflow is used to release packages to PyPI when its
# pyproject.toml version is changed or a new package is added.
 
name: Release on Version Change
 
on:
  push:
    branches:
      - main
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  detect-version-changes:
    timeout-minutes: 30
    runs-on: latchkey-small
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
      has-changes: ${{ steps.set-matrix.outputs.has-changes }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v7
        with:
          fetch-depth: 0
 
      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
        with:
          files: |
            **/pyproject.toml
          files_ignore: |
            examples/**
            libs/tests/**
 
      - name: Check for version changes or new packages
        id: check-versions
        if: steps.changed-files.outputs.any_changed == 'true'
        run: |
          ./.github/scripts/check-version-changes.sh "${{ steps.changed-files.outputs.all_changed_files }}"
 
      - name: Set matrix
        id: set-matrix
        run: |
          packages='${{ steps.check-versions.outputs.packages }}'
          if [ -z "$packages" ] || [ "$packages" = "[]" ]; then
            echo "has-changes=false" >> $GITHUB_OUTPUT
            echo "matrix={\"include\":[]}" >> $GITHUB_OUTPUT
          else
            echo "has-changes=true" >> $GITHUB_OUTPUT
            # Create matrix with package directories
            matrix=$(echo "$packages" | jq -c '{include: [.[] | {package: .}]}')
            echo "matrix=$matrix" >> $GITHUB_OUTPUT
            echo "Matrix: $matrix"
          fi
 
  build-and-test:
    timeout-minutes: 30
    needs: detect-version-changes
    if: needs.detect-version-changes.outputs.has-changes == 'true'
    runs-on: latchkey-small
    strategy:
      matrix: ${{ fromJson(needs.detect-version-changes.outputs.matrix) }}
    permissions:
      contents: write
      packages: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v7
        with:
          fetch-depth: 0
 
      - name: Extract package name and version
        working-directory: ${{ matrix.package }}
        run: |
          # Extract package name
          PACKAGE_NAME=$(grep -m1 '^name = ' pyproject.toml | cut -d'"' -f2)
          echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
 
          # Extract version
          VERSION=$(grep -m1 '^version = ' pyproject.toml | cut -d'"' -f2)
          echo "VERSION=$VERSION" >> $GITHUB_ENV
 
          echo "Building $PACKAGE_NAME version $VERSION"
 
      - name: Set up the environment
        uses: ./.github/actions/setup-uv-env
        with:
          python-version: "3.10"
 
      - name: Run tests
        working-directory: ${{ matrix.package }}
        run: |
          # Run tests if they exist
          if [ -f "Makefile" ] && grep -q "^test:" Makefile; then
            make test
          elif [ -f "../Makefile" ] && grep -q "^test:" ../Makefile; then
            cd .. && make test
          else
            echo "No tests found, skipping test step"
          fi
 
      - name: Build release distributions
        working-directory: ${{ matrix.package }}
        run: |
          uv build --out-dir dist | tee build.log
 
          # Validate wheel archives: PyPI rejects duplicate filenames in wheels
          python - <<'PY'
          from __future__ import annotations
 
          from pathlib import Path
          import sys
          import zipfile
 
          dist = Path("dist")
          wheels = sorted(dist.glob("*.whl"))
          if not wheels:
            print("No wheels found in dist/, skipping wheel validation.")
            raise SystemExit(0)
 
          for whl in wheels:
            with zipfile.ZipFile(whl) as zf:
              names = zf.namelist()
 
            seen: set[str] = set()
            dupes: set[str] = set()
            for name in names:
              if name in seen:
                dupes.add(name)
              else:
                seen.add(name)
 
            if dupes:
              print(f"ERROR: {whl} contains duplicate paths (PyPI will reject this wheel):", file=sys.stderr)
              for name in sorted(dupes):
                print(f"  - {name}", file=sys.stderr)
              raise SystemExit(1)
 
          print("Wheel validation OK (no duplicate filenames).")
          PY
 
          # Verify build artifacts
          ls -la dist/
          echo "Built artifacts for ${{ env.PACKAGE_NAME }} v${{ env.VERSION }}"
 
      - name: Upload release distributions
        uses: actions/upload-artifact@v7
        with:
          name: release-dists-${{ env.PACKAGE_NAME }}-${{ env.VERSION }}
          path: ${{ matrix.package }}/dist/
 
  pypi-publish:
    timeout-minutes: 30
    needs: [detect-version-changes, build-and-test]
    if: needs.detect-version-changes.outputs.has-changes == 'true'
    runs-on: latchkey-small
    strategy:
      matrix: ${{ fromJson(needs.detect-version-changes.outputs.matrix) }}
    permissions:
      id-token: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v7
        with:
          fetch-depth: 0
 
      - name: Extract package name and version
        working-directory: ${{ matrix.package }}
        run: |
          PACKAGE_NAME=$(grep -m1 '^name = ' pyproject.toml | cut -d'"' -f2)
          echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
 
          VERSION=$(grep -m1 '^version = ' pyproject.toml | cut -d'"' -f2)
          echo "VERSION=$VERSION" >> $GITHUB_ENV
 
      - name: Retrieve release distributions
        uses: actions/download-artifact@v8
        with:
          name: release-dists-${{ env.PACKAGE_NAME }}-${{ env.VERSION }}
          path: dist/
 
      - name: Publish release distributions to PyPI
        uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
 
      - name: Send status to Slack
        if: always()
        uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
        with:
          webhook: ${{ secrets.PACKAGE_RELEASE_SLACK_WEBHOOK_URL }}
          webhook-type: webhook-trigger
          payload: |
            {
              "status": "${{ (job.status == 'failure' || job.status == 'cancelled') && 'Failed' || 'Success' }}",
              "package": "${{ env.PACKAGE_NAME }}",
              "version": "${{ env.VERSION }}",
              "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
            }
 

What changed

This workflow runs 3 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow