diff --git a/.github/workflows/check-versions.yaml b/.github/workflows/check-versions.yaml new file mode 100644 index 0000000..89b5f8a --- /dev/null +++ b/.github/workflows/check-versions.yaml @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: Louis Moureaux + +name: Check versions +on: + push: {} + pull_request: {} + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: sudo apt-get install curl jq + - run: sh check-versions.sh + diff --git a/check-versions.sh b/check-versions.sh new file mode 100644 index 0000000..119eb76 --- /dev/null +++ b/check-versions.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: Tobias Rehbein + +# Checks that the version numbers in the index file match those in the +# modpacks. + +IFS='|' +jq -r '.modpacks[] | "\(.name)|\(.version)|\(.url)"' index.json \ + | while read NAME VERSION URL; do + RVERSION=$({ if $(echo "$URL" | grep -q '^http'); then + curl -s "$URL" + else + cat "$URL" + fi } | jq -r '.info.version') + + [ "$VERSION" != "$RVERSION" ] \ + && echo "Version mismatch for \"$NAME\": index $VERSION; remote $RVERSION" + done +