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