Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#! /usr/bin/env nix-shell 2#! nix-shell -i bash -p curl jq 3set -euo pipefail 4 5nixpkgs="$(git rev-parse --show-toplevel)" 6castopod_nix="$nixpkgs/pkgs/applications/audio/castopod/default.nix" 7 8# https://www.meetup.com/api/guide/#p02-querying-section 9query=' 10query allReleases($fullPath: ID!, $first: Int, $last: Int, $before: String, $after: String, $sort: ReleaseSort) { 11 project(fullPath: $fullPath) { 12 id 13 releases( 14 first: $first 15 last: $last 16 before: $before 17 after: $after 18 sort: $sort 19 ) { 20 nodes { 21 ...Release 22 __typename 23 } 24 __typename 25 } 26 __typename 27 } 28} 29 30fragment Release on Release { 31 id 32 name 33 tagName 34 releasedAt 35 createdAt 36 upcomingRelease 37 historicalRelease 38 assets { 39 links { 40 nodes { 41 id 42 name 43 url 44 directAssetUrl 45 linkType 46 __typename 47 } 48 __typename 49 } 50 __typename 51 } 52 __typename 53} 54' 55variables='{ 56 "fullPath": "adaures/castopod", 57 "first": 1, 58 "sort": "RELEASED_AT_DESC" 59}' 60 61post=$(cat <<EOF 62{"query": "$(echo $query)", "variables": $(echo $variables)} 63EOF 64) 65 66json="$(curl -s -X POST https://code.castopod.org/api/graphql \ 67 -H 'Content-Type: application/json' \ 68 -d "$post")" 69 70echo "$json" 71TAG=$(echo $json | jq -r '.data.project.releases.nodes[].tagName') 72ASSET_URL=$(echo $json | jq -r '.data.project.releases.nodes[].assets.links.nodes[].url' | grep .tar.gz$) 73 74CURRENT_VERSION=$(nix eval -f "$nixpkgs" --raw castopod.version) 75VERSION=${TAG:1} 76 77if [[ "$CURRENT_VERSION" == "$VERSION" ]]; then 78 echo "castopod is up-to-date: ${CURRENT_VERSION}" 79 exit 0 80fi 81 82SHA256=$(nix-prefetch-url "$ASSET_URL") 83 84URL=$(echo $ASSET_URL | sed -e 's/[\/&]/\\&/g') 85 86sed -e "s/version =.*;/version = \"$VERSION\";/g" \ 87 -e "s/url =.*;/url = \"$URL\";/g" \ 88 -e "s/sha256 =.*;/sha256 = \"$SHA256\";/g" \ 89 -i "$castopod_nix"