Skip to content

Merge pull request #39 from SpyrosPsarras/fix/watchdog-timeout-on-usa… #59

Merge pull request #39 from SpyrosPsarras/fix/watchdog-timeout-on-usa…

Merge pull request #39 from SpyrosPsarras/fix/watchdog-timeout-on-usa… #59

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: [master]
workflow_dispatch:
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
with:
scandir: .
additional_files: get-claude-usage
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y jq
- name: Run tests
run: |
chmod +x tests/*.sh
for t in tests/test-*.sh; do bash "$t"; done
check-source-changes:
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'Bump version to ')
runs-on: ubuntu-latest
outputs:
has_source_changes: ${{ steps.changes.outputs.has_source_changes }}
version_changed: ${{ steps.changes.outputs.version_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check for source file changes
id: changes
run: |
if git diff --name-only HEAD~1 HEAD | grep -qE '^(get-claude-usage|.*\.qml|translations\.js|plugin\.json)$'; then
echo "has_source_changes=true" >> "$GITHUB_OUTPUT"
else
echo "has_source_changes=false" >> "$GITHUB_OUTPUT"
fi
if git diff --quiet HEAD~1 HEAD -- plugin.json; then
echo "version_changed=false" >> "$GITHUB_OUTPUT"
else
echo "version_changed=true" >> "$GITHUB_OUTPUT"
fi
version-bump:
needs: [shellcheck, tests, check-source-changes]
if: needs.check-source-changes.outputs.has_source_changes == 'true' && needs.check-source-changes.outputs.version_changed != 'true'
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Bump patch version and create PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current=$(jq -r '.version' plugin.json)
IFS='.' read -r major minor patch <<< "$current"
new_version="${major}.${minor}.$((patch + 1))"
branch="chore/bump-v${new_version}"
# Skip if a bump PR already exists for this version
if gh pr list --head "$branch" --json number --jq 'length' | grep -qv '^0$'; then
echo "PR for $branch already exists, skipping."
exit 0
fi
jq --arg v "$new_version" '.version = $v' plugin.json > plugin.json.tmp
mv plugin.json.tmp plugin.json
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$branch"
git add plugin.json
git commit -m "Bump version to ${new_version}"
git push -u origin "$branch"
gh pr create \
--title "Bump version to ${new_version}" \
--body "Automated patch version bump: \`${current}\` → \`${new_version}\`"
# Events created by GITHUB_TOKEN do not trigger other workflow runs.
# Dispatch CI explicitly so required checks attach to the bump commit.
gh workflow run ci.yml --ref "$branch"