|
| 1 | +# SPDX-FileCopyrightText: 2006 Istituto Nazionale di Fisica Nucleare |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +name: Dependency Updates |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + paths: |
| 10 | + - "pom.xml" |
| 11 | + pull_request: |
| 12 | + paths: |
| 13 | + - "pom.xml" |
| 14 | + |
| 15 | +jobs: |
| 16 | + check-dependencies: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout repo |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up Java |
| 24 | + uses: actions/setup-java@v4 |
| 25 | + with: |
| 26 | + distribution: temurin |
| 27 | + java-version: 17 |
| 28 | + |
| 29 | + - name: Check if pom.xml changed |
| 30 | + id: changes |
| 31 | + uses: dorny/paths-filter@v3 |
| 32 | + with: |
| 33 | + filters: | |
| 34 | + pom: |
| 35 | + - 'pom.xml' |
| 36 | +
|
| 37 | + - name: Run Maven (minor updates only) |
| 38 | + if: steps.changes.outputs.pom == 'true' |
| 39 | + run: | |
| 40 | + mvn versions:display-dependency-updates \ |
| 41 | + -DallowMajorUpdates=false \ |
| 42 | + -DprocessDependencyManagement=true \ |
| 43 | + | tee minor-updates.txt |
| 44 | +
|
| 45 | + - name: Run Maven (all updates) |
| 46 | + if: steps.changes.outputs.pom == 'true' |
| 47 | + run: | |
| 48 | + mvn versions:display-dependency-updates \ |
| 49 | + -DallowMajorUpdates=true \ |
| 50 | + -DprocessDependencyManagement=true \ |
| 51 | + | tee all-updates.txt |
| 52 | +
|
| 53 | + - name: Parse outputs and generate table |
| 54 | + if: steps.changes.outputs.pom == 'true' |
| 55 | + run: | |
| 56 | + echo "# Dependency Updates" > report.md |
| 57 | + echo "" >> report.md |
| 58 | +
|
| 59 | + parse_file () { |
| 60 | + FILE=$1 |
| 61 | + TITLE=$2 |
| 62 | +
|
| 63 | + echo "## $TITLE" >> report.md |
| 64 | + echo "" >> report.md |
| 65 | + echo "| GroupId | ArtifactId | Current | Latest |" >> report.md |
| 66 | + echo "|---------|------------|---------|--------|" >> report.md |
| 67 | +
|
| 68 | + grep " -> " $FILE | while read line; do |
| 69 | + # Example line format: |
| 70 | + # com.foo:bar .................... 1.0 -> 1.2 |
| 71 | + |
| 72 | + GROUP_ARTIFACT=$(echo $line | awk '{print $1}') |
| 73 | + CURRENT=$(echo $line | awk '{print $(NF-2)}') |
| 74 | + LATEST=$(echo $line | awk '{print $NF}') |
| 75 | +
|
| 76 | + GROUP=$(echo $GROUP_ARTIFACT | cut -d: -f1) |
| 77 | + ARTIFACT=$(echo $GROUP_ARTIFACT | cut -d: -f2) |
| 78 | +
|
| 79 | + echo "| $GROUP | $ARTIFACT | $CURRENT | $LATEST |" >> report.md |
| 80 | + done |
| 81 | +
|
| 82 | + echo "" >> report.md |
| 83 | + } |
| 84 | +
|
| 85 | + parse_file minor-updates.txt "Minor / Patch Updates Only" |
| 86 | + parse_file all-updates.txt "All Updates (Including Major)" |
| 87 | +
|
| 88 | + - name: Upload report |
| 89 | + if: steps.changes.outputs.pom == 'true' |
| 90 | + uses: actions/upload-artifact@v4 |
| 91 | + with: |
| 92 | + name: dependency-update-report |
| 93 | + path: report.md |
0 commit comments