Check for Updates #90
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 Updates | |
| on: | |
| schedule: | |
| - cron: "0 8 * * *" # daily at 08:00 UTC | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Specific version to update to (without v prefix)" | |
| required: false | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| check-update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: cachix/install-nix-action@v31 | |
| with: | |
| nix_path: nixpkgs=channel:nixos-unstable | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
| allowUnfree = true | |
| env: | |
| NIX_FIRST_BUILD_UID: 400 | |
| - name: Check for new version | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| CURRENT_VERSION=$(grep 'version = "' package.nix | head -1 | sed 's/.*"\(.*\)".*/\1/') | |
| echo "Current version: $CURRENT_VERSION" | |
| if [ -n "${{ github.event.inputs.version }}" ]; then | |
| LATEST_VERSION="${{ github.event.inputs.version }}" | |
| else | |
| LATEST_VERSION=$(gh release view --repo parallel-web/parallel-web-tools --json tagName -q '.tagName' | sed 's/^v//') | |
| fi | |
| if [ -z "$LATEST_VERSION" ]; then | |
| echo "Could not determine latest version" | |
| exit 0 | |
| fi | |
| echo "Latest version: $LATEST_VERSION" | |
| if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | |
| echo "new_version=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "update_needed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "update_needed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Update version and hashes | |
| if: steps.check.outputs.update_needed == 'true' | |
| run: | | |
| NEW_VERSION="${{ steps.check.outputs.new_version }}" | |
| ./scripts/update.sh "$NEW_VERSION" | |
| - name: Verify build | |
| if: steps.check.outputs.update_needed == 'true' | |
| run: NIXPKGS_ALLOW_UNFREE=1 nix build .#parallel-cli --print-build-logs --impure | |
| - name: Create Pull Request | |
| if: steps.check.outputs.update_needed == 'true' | |
| id: create-pr | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "update parallel-cli to ${{ steps.check.outputs.new_version }}" | |
| title: "update parallel-cli to ${{ steps.check.outputs.new_version }}" | |
| body: | | |
| Updates parallel-cli from `${{ steps.check.outputs.current_version }}` to `${{ steps.check.outputs.new_version }}`. | |
| **Changes:** | |
| - Version bump in `package.nix` | |
| - Updated SHA256 hashes for all 4 platforms | |
| **Release:** https://github.com/parallel-web/parallel-web-tools/releases/tag/v${{ steps.check.outputs.new_version }} | |
| --- | |
| *Auto-generated by the update workflow.* | |
| branch: update/v${{ steps.check.outputs.new_version }} | |
| delete-branch: true | |
| labels: | | |
| dependencies | |
| automated | |
| - name: Enable auto-merge | |
| if: steps.check.outputs.update_needed == 'true' && steps.create-pr.outputs.pull-request-number | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash --delete-branch | |
| - name: Summary | |
| if: always() | |
| run: | | |
| echo "## Update Check" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ steps.check.outputs.update_needed }}" == "true" ]; then | |
| echo "- **Current:** ${{ steps.check.outputs.current_version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **New:** ${{ steps.check.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- PR created with auto-merge enabled" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "Already up to date." >> $GITHUB_STEP_SUMMARY | |
| fi |