|
| 1 | +name: Rebuild on Imageflow Release |
| 2 | + |
| 3 | +on: |
| 4 | + # Trigger manually or via repository_dispatch from imageflow repo |
| 5 | + repository_dispatch: |
| 6 | + types: [imageflow-release] |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + imageflow_tag: |
| 10 | + description: 'Imageflow release tag (e.g. v2.3.0-rc01). Leave blank to use latest.' |
| 11 | + required: false |
| 12 | + schedule: |
| 13 | + # Check weekly for new imageflow releases |
| 14 | + - cron: '0 9 * * 1' |
| 15 | + |
| 16 | +jobs: |
| 17 | + check-and-rebuild: |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + permissions: |
| 20 | + contents: write |
| 21 | + pull-requests: write |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Get current imageflow tag |
| 26 | + id: current |
| 27 | + run: | |
| 28 | + tag=$(grep -oP 'tag = "\K[^"]+' native/Cargo.toml | head -1) |
| 29 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 30 | + echo "Current tag: $tag" |
| 31 | +
|
| 32 | + - name: Get latest imageflow release tag |
| 33 | + id: latest |
| 34 | + run: | |
| 35 | + if [[ -n "${{ github.event.inputs.imageflow_tag }}" ]]; then |
| 36 | + tag="${{ github.event.inputs.imageflow_tag }}" |
| 37 | + elif [[ -n "${{ github.event.client_payload.tag }}" ]]; then |
| 38 | + tag="${{ github.event.client_payload.tag }}" |
| 39 | + else |
| 40 | + tag=$(gh api repos/imazen/imageflow/releases/latest --jq '.tag_name' 2>/dev/null || echo "") |
| 41 | + fi |
| 42 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 43 | + echo "Latest tag: $tag" |
| 44 | + env: |
| 45 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Check if update needed |
| 48 | + id: check |
| 49 | + run: | |
| 50 | + if [[ -z "${{ steps.latest.outputs.tag }}" ]]; then |
| 51 | + echo "No latest tag found, skipping" |
| 52 | + echo "needed=false" >> "$GITHUB_OUTPUT" |
| 53 | + elif [[ "${{ steps.current.outputs.tag }}" == "${{ steps.latest.outputs.tag }}" ]]; then |
| 54 | + echo "Already on latest (${{ steps.current.outputs.tag }}), skipping" |
| 55 | + echo "needed=false" >> "$GITHUB_OUTPUT" |
| 56 | + else |
| 57 | + echo "Update needed: ${{ steps.current.outputs.tag }} -> ${{ steps.latest.outputs.tag }}" |
| 58 | + echo "needed=true" >> "$GITHUB_OUTPUT" |
| 59 | + fi |
| 60 | +
|
| 61 | + - name: Update Cargo.toml tag |
| 62 | + if: steps.check.outputs.needed == 'true' |
| 63 | + run: | |
| 64 | + sed -i "s/tag = \"${{ steps.current.outputs.tag }}\"/tag = \"${{ steps.latest.outputs.tag }}\"/g" native/Cargo.toml |
| 65 | + echo "Updated native/Cargo.toml:" |
| 66 | + grep 'tag =' native/Cargo.toml |
| 67 | +
|
| 68 | + - name: Setup Rust |
| 69 | + if: steps.check.outputs.needed == 'true' |
| 70 | + uses: dtolnay/rust-toolchain@stable |
| 71 | + |
| 72 | + - name: Verify it builds |
| 73 | + if: steps.check.outputs.needed == 'true' |
| 74 | + working-directory: native |
| 75 | + run: cargo check |
| 76 | + |
| 77 | + - name: Create PR |
| 78 | + if: steps.check.outputs.needed == 'true' |
| 79 | + run: | |
| 80 | + branch="deps/imageflow-${{ steps.latest.outputs.tag }}" |
| 81 | + git checkout -b "$branch" |
| 82 | + git add native/Cargo.toml |
| 83 | + git config user.name "github-actions[bot]" |
| 84 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 85 | + git commit -m "deps: update imageflow to ${{ steps.latest.outputs.tag }}" |
| 86 | + git push origin "$branch" |
| 87 | + gh pr create \ |
| 88 | + --title "deps: update imageflow to ${{ steps.latest.outputs.tag }}" \ |
| 89 | + --body "Automatic update from ${{ steps.current.outputs.tag }} to ${{ steps.latest.outputs.tag }}." \ |
| 90 | + --label dependencies |
| 91 | + env: |
| 92 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments