|
| 1 | +# SPDX-License-Identifier: MIT |
| 2 | +# SPDX-FileCopyrightText: 2025 py7zz contributors |
| 3 | + |
| 4 | +name: Check Upstream 7zz |
| 5 | + |
| 6 | +on: |
| 7 | + schedule: |
| 8 | + - cron: '30 0 * * *' # Run daily at 00:30 UTC (avoiding midnight congestion) |
| 9 | + workflow_dispatch: # Allow manual trigger |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + check-and-update: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 # Fetch all history for git describe |
| 22 | + |
| 23 | + - name: Check for updates |
| 24 | + id: check |
| 25 | + run: | |
| 26 | + chmod +x scripts/get_7zz.sh |
| 27 | +
|
| 28 | + # Get latest version from online (with error handling) |
| 29 | + echo "Detecting latest 7zz version from upstream..." |
| 30 | + if ! LATEST_ONLINE=$(./scripts/get_7zz.sh --detect-latest 2>&1); then |
| 31 | + echo "::error::Failed to detect latest 7zz version from upstream" |
| 32 | + echo "Output: $LATEST_ONLINE" |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | +
|
| 36 | + # Validate version format (should be like "25.01") |
| 37 | + if ! [[ "$LATEST_ONLINE" =~ ^[0-9]+\.[0-9]+$ ]]; then |
| 38 | + echo "::error::Invalid version format detected: '$LATEST_ONLINE'" |
| 39 | + exit 1 |
| 40 | + fi |
| 41 | +
|
| 42 | + # Get current bundled version (with error handling) |
| 43 | + echo "Reading current bundled version..." |
| 44 | + if ! CURRENT_BUNDLED=$(./scripts/get_7zz.sh --get-current 2>&1); then |
| 45 | + echo "::error::Failed to read current bundled version" |
| 46 | + echo "Output: $CURRENT_BUNDLED" |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | +
|
| 50 | + echo "Latest online 7zz: $LATEST_ONLINE" |
| 51 | + echo "Current bundled 7zz: $CURRENT_BUNDLED" |
| 52 | +
|
| 53 | + # Compare versions |
| 54 | + if dpkg --compare-versions "$LATEST_ONLINE" gt "$CURRENT_BUNDLED"; then |
| 55 | + echo "✨ Update found: $CURRENT_BUNDLED -> $LATEST_ONLINE" |
| 56 | + echo "update_needed=true" >> $GITHUB_OUTPUT |
| 57 | + echo "new_version=$LATEST_ONLINE" >> $GITHUB_OUTPUT |
| 58 | + else |
| 59 | + echo "✅ Up to date" |
| 60 | + echo "update_needed=false" >> $GITHUB_OUTPUT |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Prepare 7zz version bump |
| 64 | + if: steps.check.outputs.update_needed == 'true' |
| 65 | + run: | |
| 66 | + set -euo pipefail |
| 67 | +
|
| 68 | + NEW_VERSION="${{ steps.check.outputs.new_version }}" |
| 69 | + CURRENT_VERSION=$(cat py7zz/7zz_version.txt | tr -d '[:space:]') |
| 70 | +
|
| 71 | + echo "$NEW_VERSION" > py7zz/7zz_version.txt |
| 72 | +
|
| 73 | + # Verify the new version can be downloaded (no artifacts committed; bin is gitignored) |
| 74 | + if ! ./scripts/get_7zz.sh --version "$NEW_VERSION"; then |
| 75 | + echo "::error::Failed to verify 7zz $NEW_VERSION download" |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | +
|
| 79 | + echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV |
| 80 | +
|
| 81 | + - name: Create PR for 7zz Update |
| 82 | + if: steps.check.outputs.update_needed == 'true' |
| 83 | + uses: peter-evans/create-pull-request@v6 |
| 84 | + with: |
| 85 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + branch: chore/update-7zz |
| 87 | + delete-branch: true |
| 88 | + base: main |
| 89 | + title: "chore: bump bundled 7zz to ${{ steps.check.outputs.new_version }}" |
| 90 | + commit-message: "chore: bump bundled 7zz to ${{ steps.check.outputs.new_version }}" |
| 91 | + labels: dependencies, automated, chore |
| 92 | + add-paths: py7zz/7zz_version.txt |
| 93 | + body: | |
| 94 | + ## Summary |
| 95 | + Detected a new 7-Zip release: **${{ steps.check.outputs.new_version }}**. |
| 96 | +
|
| 97 | + This PR updates the bundled 7zz version. Release and tagging remain manual so branch protection stays intact. |
| 98 | +
|
| 99 | + ## Changes |
| 100 | + - Update `py7zz/7zz_version.txt`: ${{ env.CURRENT_VERSION }} → ${{ steps.check.outputs.new_version }} |
| 101 | +
|
| 102 | + ## Changelog Category |
| 103 | + - chore (dependency maintenance) |
| 104 | +
|
| 105 | + ## Next Steps |
| 106 | + - Review and merge this PR when ready |
| 107 | + - Owner can run release workflow after merging to publish a new py7zz version |
| 108 | +
|
| 109 | + Generated by [Check Upstream 7zz workflow](https://github.com/${{ github.repository }}/actions/workflows/check-upstream.yml) |
0 commit comments