diff --git a/.github/workflows/validate-dependency-snapshots.yml b/.github/workflows/validate-dependency-snapshots.yml new file mode 100644 index 0000000000..a62cbbb174 --- /dev/null +++ b/.github/workflows/validate-dependency-snapshots.yml @@ -0,0 +1,46 @@ +name: Validate Dependency Snapshots + +on: + pull_request: + branches: [ master, release-* ] + merge_group: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + validate-dependency-snapshots: + runs-on: [ default ] + defaults: + run: + working-directory: android + if: github.event_name != 'merge_group' + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Search for Snapshot Dependencies + run: | + SNAPSHOT_REGEX="navi-.*=[ ]*\"[0-9]+\.[0-9]+\.[0-9]+-[0-9]{8}\.[0-9]{6}-[0-9]+\"" + + SNAPSHOT_DEPS=$(grep -E "$SNAPSHOT_REGEX" gradle/libs.versions.toml || true) + + if [[ -n "$SNAPSHOT_DEPS" ]]; then + echo "Snapshot version found in the following navi-* dependencies:" + echo "$SNAPSHOT_DEPS" + + SUMMARY_TABLE="| Search Location | Gradle Dependency | Snapshot Version |\n| :---: | :---: | :---: |" + while read -r line; do + DEP_NAME=$(echo "$line" | cut -d'=' -f1 | xargs) + DEP_VERSION=$(echo "$line" | cut -d'=' -f2 | xargs | tr -d '"') + SUMMARY_TABLE="$SUMMARY_TABLE\n| libs.versions.toml | $DEP_NAME | $DEP_VERSION |" + done <<< "$SNAPSHOT_DEPS" + + echo -e "$SUMMARY_TABLE" >> $GITHUB_STEP_SUMMARY + + echo -e "\nPlease use release versions instead of snapshot versions for the dependencies mentioned above." >> $GITHUB_STEP_SUMMARY + + exit 1 + else + echo "No snapshot versions found in navi-* dependencies." + fi