From 15e5dd42db2420d81345cedec4d65ef538f58c0a Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Thu, 4 Jan 2024 18:31:11 +0100 Subject: [PATCH] Add a workflow to check versions in the modpack index See #5. --- .github/workflows/check-versions.yaml | 19 +++++++++++++++++++ check-versions.sh | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/check-versions.yaml create mode 100644 check-versions.sh 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..46aadff --- /dev/null +++ b/check-versions.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: blabber + +# 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 +