π Check for Plugin Updates #192
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: π Check for Plugin Updates | |
| on: | |
| schedule: | |
| - cron: "0 2 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| check-updates: | |
| runs-on: ubuntu-latest | |
| env: | |
| VERSION_FILE: .github/dependency_versions.json | |
| steps: | |
| - name: π§° Checkout | |
| uses: actions/checkout@v4 | |
| - name: π¦ Install jq & gh | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y jq | |
| gh --version || sudo apt-get install -y gh | |
| - name: π Check for new releases | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| mapfile -t ROWS < <(jq -r ' | |
| to_entries[] | |
| | [ | |
| (.value.repo), | |
| (.value.message // "v0.0.0"), | |
| (.value.allow_prerelease // false) | |
| ] | |
| | @tsv | |
| ' "$VERSION_FILE") | |
| norm() { sed -E 's/^v//'; } | |
| for row in "${ROWS[@]}"; do | |
| repo="$(cut -f1 <<< "$row")" | |
| prev_tag="$(cut -f2 <<< "$row")" | |
| allow_pre_flag="$(cut -f3 <<< "$row")" | |
| echo "π Checking $repo (pinned: $prev_tag, allow_prerelease=$allow_pre_flag)" | |
| if [[ "$allow_pre_flag" == "true" ]]; then | |
| latest_tag="$(curl -s "https://api.github.com/repos/$repo/releases" \ | |
| | jq -r '[.[] | select(.draft==false) | .tag_name] | first // empty')" | |
| else | |
| latest_tag="$(curl -s "https://api.github.com/repos/$repo/releases/latest" \ | |
| | jq -r '.tag_name // empty')" | |
| fi | |
| if [[ -z "$latest_tag" ]]; then | |
| latest_tag=$(curl -s "https://api.github.com/repos/$repo/tags" \ | |
| | jq -r 'if type=="array" and length>0 then .[0].name else empty end') | |
| fi | |
| if [[ -z "$latest_tag" ]]; then | |
| latest_tag="v0.0.0" | |
| fi | |
| prev_norm="$(printf '%s' "$prev_tag" | norm)" | |
| latest_norm="$(printf '%s' "$latest_tag" | norm)" | |
| if [[ "$latest_norm" != "$prev_norm" && "$latest_tag" != "v0.0.0" ]]; then | |
| echo "New release detected for $repo: $prev_tag β $latest_tag" | |
| existing_number="$(gh issue list \ | |
| --state open \ | |
| --label dependencies \ | |
| --search "\"$repo\" \"$latest_tag\"" \ | |
| --json number 2>/dev/null \ | |
| | jq -r 'if type=="array" and length>0 then .[0].number else empty end' || true)" | |
| if [[ -n "$existing_number" ]]; then | |
| echo "Open issue #$existing_number already exists for $repo $latest_tag; skipping create" | |
| continue | |
| fi | |
| gh issue create \ | |
| --title "Incorporate $repo $latest_tag" \ | |
| --label dependencies \ | |
| --body "**Plugin**: \`$repo\` | |
| **Version**: \`$latest_tag\` | |
| Please update the DLL and modify the following files accordingly. | |
| \`.github/dependency_versions.json\` | |
| \`.github/badges/[plugin].json\` | |
| [Release notes](https://github.com/$repo/releases/tag/$latest_tag)" | |
| else | |
| echo "No update needed for $repo ($prev_tag)" | |
| fi | |
| done |