Check Package Versions #9
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 Package Versions | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # Daily at 6 AM UTC | |
| workflow_dispatch: | |
| inputs: | |
| package: | |
| description: 'Specific package to check (leave empty for all)' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| check-versions: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Hyprland ecosystem (all use GitHub releases) | |
| - package: hyprutils | |
| repo: hyprwm/hyprutils | |
| version_source: release | |
| - package: hyprlang | |
| repo: hyprwm/hyprlang | |
| version_source: release | |
| - package: hyprwayland-scanner | |
| repo: hyprwm/hyprwayland-scanner | |
| version_source: release | |
| - package: hyprgraphics | |
| repo: hyprwm/hyprgraphics | |
| version_source: release | |
| - package: hyprcursor | |
| repo: hyprwm/hyprcursor | |
| version_source: release | |
| - package: hyprland-protocols | |
| repo: hyprwm/hyprland-protocols | |
| version_source: release | |
| - package: aquamarine | |
| repo: hyprwm/aquamarine | |
| version_source: release | |
| - package: hyprland-qt-support | |
| repo: hyprwm/hyprland-qt-support | |
| version_source: release | |
| - package: hyprland | |
| repo: hyprwm/Hyprland | |
| version_source: release | |
| - package: hyprlock | |
| repo: hyprwm/hyprlock | |
| version_source: release | |
| - package: hypridle | |
| repo: hyprwm/hypridle | |
| version_source: release | |
| - package: hyprpaper | |
| repo: hyprwm/hyprpaper | |
| version_source: release | |
| - package: xdg-desktop-portal-hyprland | |
| repo: hyprwm/xdg-desktop-portal-hyprland | |
| version_source: release | |
| - package: hyprpolkitagent | |
| repo: hyprwm/hyprpolkitagent | |
| version_source: release | |
| - package: hyprtoolkit | |
| repo: hyprwm/hyprtoolkit | |
| version_source: release | |
| - package: hyprland-guiutils | |
| repo: hyprwm/hyprland-guiutils | |
| version_source: release | |
| # CLI tools | |
| - package: eza | |
| repo: eza-community/eza | |
| version_source: release | |
| - package: starship | |
| repo: starship/starship | |
| version_source: release | |
| - package: lazygit | |
| repo: jesseduffield/lazygit | |
| version_source: release | |
| - package: wifitui | |
| repo: shazow/wifitui | |
| version_source: release | |
| # Other | |
| - package: glaze | |
| repo: stephenberry/glaze | |
| version_source: release | |
| - package: uwsm | |
| repo: Vladimir-csp/uwsm | |
| version_source: tag | |
| - package: quickshell | |
| repo: quickshell-mirror/quickshell | |
| version_source: tag | |
| - package: regreet | |
| repo: rharish101/ReGreet | |
| version_source: release | |
| # livesys-scripts uses our fork, skip auto-update | |
| # - package: livesys-scripts | |
| # repo: binarypie-dev/livesys-scripts | |
| # version_source: tag | |
| steps: | |
| - name: Check if should run | |
| id: should-run | |
| run: | | |
| if [ -n "${{ inputs.package }}" ] && [ "${{ inputs.package }}" != "${{ matrix.package }}" ]; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Checkout | |
| if: steps.should-run.outputs.skip != 'true' | |
| uses: actions/checkout@v4 | |
| - name: Get upstream version | |
| if: steps.should-run.outputs.skip != 'true' | |
| id: upstream | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| VERSION_SOURCE="${{ matrix.version_source }}" | |
| RESULT="" | |
| if [ "$VERSION_SOURCE" = "tag" ]; then | |
| # Use tags API directly | |
| echo "Checking tags for ${{ matrix.repo }}..." | |
| RESULT=$(gh api repos/${{ matrix.repo }}/tags --jq '.[0].name' 2>/dev/null) || RESULT="" | |
| else | |
| # Use releases API (default) | |
| echo "Checking releases for ${{ matrix.repo }}..." | |
| RESULT=$(gh api repos/${{ matrix.repo }}/releases/latest --jq '.tag_name' 2>/dev/null) || RESULT="" | |
| fi | |
| # Check if we got a valid response (not empty and not an error message) | |
| if [ -z "$RESULT" ] || echo "$RESULT" | grep -q "Not Found\|message"; then | |
| echo "Could not determine upstream version for ${{ matrix.package }}" | |
| echo "version=" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Strip 'v' prefix if present | |
| VERSION="${RESULT#v}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Upstream version: $VERSION" | |
| - name: Get spec version | |
| if: steps.should-run.outputs.skip != 'true' | |
| id: spec | |
| run: | | |
| SPEC_FILE="packages/${{ matrix.package }}/${{ matrix.package }}.spec" | |
| if [ ! -f "$SPEC_FILE" ]; then | |
| echo "Spec file not found: $SPEC_FILE" | |
| echo "version=" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Extract version from spec file | |
| VERSION=$(grep "^Version:" "$SPEC_FILE" | awk '{print $2}') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Spec version: $VERSION" | |
| - name: Compare versions | |
| if: steps.should-run.outputs.skip != 'true' | |
| id: compare | |
| run: | | |
| UPSTREAM="${{ steps.upstream.outputs.version }}" | |
| SPEC="${{ steps.spec.outputs.version }}" | |
| if [ -z "$UPSTREAM" ]; then | |
| echo "Could not determine upstream version" | |
| echo "needs_update=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| if [ -z "$SPEC" ]; then | |
| echo "Could not determine spec version" | |
| echo "needs_update=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| if [ "$UPSTREAM" != "$SPEC" ]; then | |
| echo "Version mismatch: upstream=$UPSTREAM, spec=$SPEC" | |
| echo "needs_update=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Versions match: $SPEC" | |
| echo "needs_update=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check for existing PR | |
| if: steps.should-run.outputs.skip != 'true' && steps.compare.outputs.needs_update == 'true' | |
| id: existing-pr | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # Check if a PR already exists for this package update | |
| BRANCH="pkg-update/${{ matrix.package }}-${{ steps.upstream.outputs.version }}" | |
| EXISTING=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null) || EXISTING="" | |
| if [ -n "$EXISTING" ]; then | |
| echo "PR #$EXISTING already exists for ${{ matrix.package }} ${{ steps.upstream.outputs.version }}" | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "No existing PR found" | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Update spec file | |
| if: steps.should-run.outputs.skip != 'true' && steps.compare.outputs.needs_update == 'true' && steps.existing-pr.outputs.exists != 'true' | |
| run: | | |
| SPEC_FILE="packages/${{ matrix.package }}/${{ matrix.package }}.spec" | |
| OLD_VERSION="${{ steps.spec.outputs.version }}" | |
| NEW_VERSION="${{ steps.upstream.outputs.version }}" | |
| # Update Version field | |
| sed -i "s/^Version:.*$/Version: $NEW_VERSION/" "$SPEC_FILE" | |
| # Update Release back to 1 for new version | |
| sed -i "s/^Release:.*$/Release: 1%{?dist}/" "$SPEC_FILE" | |
| # Update changelog with new entry | |
| DATE=$(date "+%a %b %d %Y") | |
| CHANGELOG_ENTRY="* $DATE Hypercube <hypercube@binarypie.dev> - $NEW_VERSION-1\n- Update to $NEW_VERSION" | |
| # Insert new changelog entry after %changelog line | |
| sed -i "/%changelog/a\\$CHANGELOG_ENTRY" "$SPEC_FILE" | |
| echo "Updated ${{ matrix.package }} from $OLD_VERSION to $NEW_VERSION" | |
| - name: Create Pull Request | |
| if: steps.should-run.outputs.skip != 'true' && steps.compare.outputs.needs_update == 'true' && steps.existing-pr.outputs.exists != 'true' | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "pkg(${{ matrix.package }}): update to ${{ steps.upstream.outputs.version }}" | |
| title: "pkg(${{ matrix.package }}): update to ${{ steps.upstream.outputs.version }}" | |
| body: | | |
| Updates **${{ matrix.package }}** from `${{ steps.spec.outputs.version }}` to `${{ steps.upstream.outputs.version }}` | |
| **Upstream release:** https://github.com/${{ matrix.repo }}/releases/tag/v${{ steps.upstream.outputs.version }} | |
| --- | |
| *This PR was automatically created by the package version checker.* | |
| branch: "pkg-update/${{ matrix.package }}-${{ steps.upstream.outputs.version }}" | |
| delete-branch: true | |
| labels: | | |
| dependencies | |
| package-update |