Update PyPI Packages #169
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update PyPI Packages | |
| on: | |
| schedule: | |
| # Runs daily at 9:00 AM UTC | |
| - cron: '0 9 * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| update-packages: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Check PyPI for updates | |
| id: check | |
| run: | | |
| # Fetch latest versions from PyPI | |
| MAID_RUNNER_PYPI=$(curl -s https://pypi.org/pypi/maid-runner/json | jq -r '.info.version') | |
| MAID_LSP_PYPI=$(curl -s https://pypi.org/pypi/maid-lsp/json | jq -r '.info.version') | |
| # Get current tracked PyPI versions from dependencies.json | |
| MAID_RUNNER_TRACKED=$(jq -r '.["maid-runner"] // "0.0.0"' plugins/maid-runner/dependencies.json 2>/dev/null || echo "0.0.0") | |
| MAID_LSP_TRACKED=$(jq -r '.["maid-lsp"] // "0.0.0"' plugins/maid-lsp/dependencies.json 2>/dev/null || echo "0.0.0") | |
| # Get current plugin versions | |
| MAID_RUNNER_PLUGIN_VERSION=$(jq -r '.version' plugins/maid-runner/plugin.json) | |
| MAID_LSP_PLUGIN_VERSION=$(jq -r '.version' plugins/maid-lsp/plugin.json) | |
| echo "maid_runner_pypi=$MAID_RUNNER_PYPI" >> $GITHUB_OUTPUT | |
| echo "maid_runner_tracked=$MAID_RUNNER_TRACKED" >> $GITHUB_OUTPUT | |
| echo "maid_runner_plugin_version=$MAID_RUNNER_PLUGIN_VERSION" >> $GITHUB_OUTPUT | |
| echo "maid_lsp_pypi=$MAID_LSP_PYPI" >> $GITHUB_OUTPUT | |
| echo "maid_lsp_tracked=$MAID_LSP_TRACKED" >> $GITHUB_OUTPUT | |
| echo "maid_lsp_plugin_version=$MAID_LSP_PLUGIN_VERSION" >> $GITHUB_OUTPUT | |
| # Check which plugins need updates | |
| MAID_RUNNER_NEEDS_UPDATE="false" | |
| MAID_LSP_NEEDS_UPDATE="false" | |
| NEEDS_UPDATE="false" | |
| if [ "$MAID_RUNNER_PYPI" != "$MAID_RUNNER_TRACKED" ]; then | |
| MAID_RUNNER_NEEDS_UPDATE="true" | |
| NEEDS_UPDATE="true" | |
| fi | |
| if [ "$MAID_LSP_PYPI" != "$MAID_LSP_TRACKED" ]; then | |
| MAID_LSP_NEEDS_UPDATE="true" | |
| NEEDS_UPDATE="true" | |
| fi | |
| echo "maid_runner_needs_update=$MAID_RUNNER_NEEDS_UPDATE" >> $GITHUB_OUTPUT | |
| echo "maid_lsp_needs_update=$MAID_LSP_NEEDS_UPDATE" >> $GITHUB_OUTPUT | |
| echo "needs_update=$NEEDS_UPDATE" >> $GITHUB_OUTPUT | |
| echo "maid-runner PyPI: $MAID_RUNNER_TRACKED -> $MAID_RUNNER_PYPI (update: $MAID_RUNNER_NEEDS_UPDATE)" | |
| echo "maid-lsp PyPI: $MAID_LSP_TRACKED -> $MAID_LSP_PYPI (update: $MAID_LSP_NEEDS_UPDATE)" | |
| - name: Bump plugin versions | |
| if: steps.check.outputs.needs_update == 'true' | |
| id: bump | |
| run: | | |
| # Function to bump patch version | |
| bump_patch() { | |
| local version=$1 | |
| local major minor patch | |
| IFS='.' read -r major minor patch <<< "$version" | |
| patch=$((patch + 1)) | |
| echo "${major}.${minor}.${patch}" | |
| } | |
| MAID_RUNNER_NEW_VERSION="${{ steps.check.outputs.maid_runner_plugin_version }}" | |
| MAID_LSP_NEW_VERSION="${{ steps.check.outputs.maid_lsp_plugin_version }}" | |
| # Bump maid-runner plugin version if PyPI updated | |
| if [ "${{ steps.check.outputs.maid_runner_needs_update }}" == "true" ]; then | |
| MAID_RUNNER_NEW_VERSION=$(bump_patch "${{ steps.check.outputs.maid_runner_plugin_version }}") | |
| # Update plugin.json version | |
| jq --arg v "$MAID_RUNNER_NEW_VERSION" '.version = $v' plugins/maid-runner/plugin.json > tmp.json && mv tmp.json plugins/maid-runner/plugin.json | |
| # Update or create dependencies.json | |
| echo '{"maid-runner": "${{ steps.check.outputs.maid_runner_pypi }}"}' | jq '.' > plugins/maid-runner/dependencies.json | |
| # Update marketplace.json | |
| jq --arg v "$MAID_RUNNER_NEW_VERSION" ' | |
| .plugins |= map(if .name == "maid-runner" then .version = $v else . end) | |
| ' .claude-plugin/marketplace.json > tmp.json && mv tmp.json .claude-plugin/marketplace.json | |
| fi | |
| # Bump maid-lsp plugin version if PyPI updated | |
| if [ "${{ steps.check.outputs.maid_lsp_needs_update }}" == "true" ]; then | |
| MAID_LSP_NEW_VERSION=$(bump_patch "${{ steps.check.outputs.maid_lsp_plugin_version }}") | |
| # Update plugin.json version | |
| jq --arg v "$MAID_LSP_NEW_VERSION" '.version = $v' plugins/maid-lsp/plugin.json > tmp.json && mv tmp.json plugins/maid-lsp/plugin.json | |
| # Update or create dependencies.json | |
| echo '{"maid-lsp": "${{ steps.check.outputs.maid_lsp_pypi }}"}' | jq '.' > plugins/maid-lsp/dependencies.json | |
| # Update marketplace.json | |
| jq --arg v "$MAID_LSP_NEW_VERSION" ' | |
| .plugins |= map(if .name == "maid-lsp" then .version = $v else . end) | |
| ' .claude-plugin/marketplace.json > tmp.json && mv tmp.json .claude-plugin/marketplace.json | |
| fi | |
| echo "maid_runner_new_version=$MAID_RUNNER_NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "maid_lsp_new_version=$MAID_LSP_NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Create Pull Request | |
| if: steps.check.outputs.needs_update == 'true' | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "chore(deps): bump plugin versions for PyPI dependency updates" | |
| title: "chore(deps): bump plugin versions for PyPI dependency updates" | |
| body: | | |
| Automated plugin version bump triggered by PyPI dependency updates. | |
| ## Plugin Version Changes | |
| - **maid-runner**: ${{ steps.check.outputs.maid_runner_plugin_version }} → ${{ steps.bump.outputs.maid_runner_new_version }} | |
| - **maid-lsp**: ${{ steps.check.outputs.maid_lsp_plugin_version }} → ${{ steps.bump.outputs.maid_lsp_new_version }} | |
| ## PyPI Dependency Updates (trigger) | |
| - **maid-runner**: ${{ steps.check.outputs.maid_runner_tracked }} → ${{ steps.check.outputs.maid_runner_pypi }} | |
| - **maid-lsp**: ${{ steps.check.outputs.maid_lsp_tracked }} → ${{ steps.check.outputs.maid_lsp_pypi }} | |
| --- | |
| *This PR was automatically created by the update-packages workflow.* | |
| *Plugin versions are independent of PyPI package versions.* | |
| branch: chore/update-packages | |
| delete-branch: true | |
| labels: | | |
| dependencies | |
| automated |