|
| 1 | +name: Update C2PA core SDK version |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Check for new releases every 6 hours |
| 6 | + - cron: '0 */6 * * *' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + check-and-update: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 18 | + |
| 19 | + - name: Get latest c2pa-rs release |
| 20 | + id: get_release |
| 21 | + run: | |
| 22 | + # Get the latest release tag from c2pa-rs that matches the pattern c2pa-c-ffi-v* |
| 23 | + LATEST_TAG=$(curl -s "https://api.github.com/repos/contentauth/c2pa-rs/releases" | \ |
| 24 | + jq -r '.[].tag_name | select(test("^c2pa-c-ffi-v"))' | \ |
| 25 | + head -1) |
| 26 | + |
| 27 | + if [ -z "$LATEST_TAG" ]; then |
| 28 | + echo "No matching tags found" |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | + |
| 32 | + # Extract version from the tag (remove c2pa-c-ffi- prefix) |
| 33 | + VERSION=$(echo "$LATEST_TAG" | sed 's/^c2pa-c-ffi-//') |
| 34 | + |
| 35 | + echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT |
| 36 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + echo "Latest matching tag: $LATEST_TAG" |
| 39 | + echo "Extracted version: $VERSION" |
| 40 | + |
| 41 | + - name: Get current version from Makefile |
| 42 | + id: current_version |
| 43 | + run: | |
| 44 | + CURRENT_VERSION=$(grep '^C2PA_VERSION := ' Makefile | cut -d' ' -f3) |
| 45 | + echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT |
| 46 | + echo "Current version: $CURRENT_VERSION" |
| 47 | + |
| 48 | + - name: Check if update is needed |
| 49 | + id: check_update |
| 50 | + run: | |
| 51 | + if [ "${{ steps.get_release.outputs.version }}" != "${{ steps.current_version.outputs.current_version }}" ]; then |
| 52 | + echo "needs_update=true" >> $GITHUB_OUTPUT |
| 53 | + echo "Update needed: ${{ steps.current_version.outputs.current_version }} -> ${{ steps.get_release.outputs.version }}" |
| 54 | + else |
| 55 | + echo "needs_update=false" >> $GITHUB_OUTPUT |
| 56 | + echo "No update needed, versions match: ${{ steps.current_version.outputs.current_version }}" |
| 57 | + fi |
| 58 | + |
| 59 | + - name: Update Makefile |
| 60 | + if: steps.check_update.outputs.needs_update == 'true' |
| 61 | + run: | |
| 62 | + # Update the C2PA_VERSION variable in Makefile |
| 63 | + sed -i "s/^C2PA_VERSION := .*/C2PA_VERSION := ${{ steps.get_release.outputs.version }}/" Makefile |
| 64 | + |
| 65 | + # Verify the change |
| 66 | + echo "Updated Makefile:" |
| 67 | + grep '^C2PA_VERSION := ' Makefile |
| 68 | + |
| 69 | + - name: Create pull request |
| 70 | + if: steps.check_update.outputs.needs_update == 'true' |
| 71 | + uses: peter-evans/create-pull-request@v5 |
| 72 | + with: |
| 73 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + commit-message: "Update core C2PA SDK to ${{ steps.get_release.outputs.version }}" |
| 75 | + title: "Update core C2PA SDK to ${{ steps.get_release.outputs.version }}" |
| 76 | + body: | |
| 77 | + This PR updates C2PA_VERSION in the Makefile to use the latest c2pa-rs release. |
| 78 | + |
| 79 | + - **Previous version**: ${{ steps.current_version.outputs.current_version }} |
| 80 | + - **New version**: ${{ steps.get_release.outputs.version }} |
| 81 | + - **Release tag**: ${{ steps.get_release.outputs.latest_tag }} |
| 82 | + |
| 83 | + This update was automatically generated by the update-c2pa-core-sdk workflow. |
| 84 | + |
| 85 | + Please review and merge if the changes look correct. |
| 86 | + branch: update-c2pa-version-${{ steps.get_release.outputs.version }} |
| 87 | + delete-branch: true |
0 commit comments