@@ -1,33 +1,60 @@
11#! /usr/bin/env nix-shell
2−#! nix-shell -i bash -p coreutils gnused curl common-updater-scripts nuget-to-nix nix-prefetch-git jq dotnet-sdk_6
2+#! nix-shell -I nixpkgs=./. -i bash -p coreutils gnused curl common-updater-scripts nuget-to-nix nix-prefetch-git jq dotnet-sdk_6
33set -euo pipefail
44cd "$(dirname "${BASH_SOURCE[0]}")"
55
66DEPS_FILE="$(realpath "./deps.nix")"
77
8−RELEASE_JOB_DATA=$(
9− curl -s -H "Accept: application/vnd.github.v3+json" \
10− https://api.github.com/repos/Ryujinx/Ryujinx/actions/workflows |
11− jq -r '.workflows[] | select(.name == "Release job") | { id, path }'
12−)
13−RELEASE_JOB_ID=$(echo "$RELEASE_JOB_DATA" | jq -r '.id')
14−RELEASE_JOB_FILE=$(echo "$RELEASE_JOB_DATA" | jq -r '.path')
15−
16−BASE_VERSION=$(
17− curl -s "https://raw.githubusercontent.com/Ryujinx/Ryujinx/master/${RELEASE_JOB_FILE}" |
18− grep -Po 'RYUJINX_BASE_VERSION:.*?".*"' |
19− sed 's/RYUJINX_BASE_VERSION: "\(.*\)"/\1/'
20−)
21−
22−LATEST_RELEASE_JOB_DATA=$(
23− curl -s -H "Accept: application/vnd.github.v3+json" \
24− "https://api.github.com/repos/Ryujinx/Ryujinx/actions/workflows/${RELEASE_JOB_ID}/runs" |
25− jq -r '.workflow_runs[0] | { head_sha, run_number }'
26−)
27−COMMIT=$(echo "$LATEST_RELEASE_JOB_DATA" | jq -r '.head_sha')
28−PATCH_VERSION=$(echo "$LATEST_RELEASE_JOB_DATA" | jq -r '.run_number')
29−
30−NEW_VERSION="${BASE_VERSION}.${PATCH_VERSION}"
8+# provide a github token so you don't get rate limited
9+# if you use gh cli you can use:
10+# `export GITHUB_TOKEN="$(cat ~/.config/gh/config.yml | yq '.hosts."github.com".oauth_token' -r)"`
11+# or just set your token by hand:
12+# `read -s -p "Enter your token: " GITHUB_TOKEN; export GITHUB_TOKEN`
13+# (we use read so it doesn't show in our shell history and in secret mode so the token you paste isn't visible)
14+if [ -z "${GITHUB_TOKEN:-}" ]; then
15+ echo "no GITHUB_TOKEN provided - you could meet API request limiting" >&2
16+fi
17+
18+# or provide the new version manually
19+# manually modify and uncomment or export these env vars in your shell so they're accessable within the script
20+# make sure you don't commit your changes here
21+#
22+# NEW_VERSION=""
23+# COMMIT=""
24+
25+if [ -z ${NEW_VERSION+x} ] && [ -z ${COMMIT+x} ]; then
26+ RELEASE_JOB_DATA=$(
27+ curl -s -H "Accept: application/vnd.github.v3+json" \
28+ ${GITHUB_TOKEN:+ -H "Authorization: bearer $GITHUB_TOKEN"} \
29+ https://api.github.com/repos/Ryujinx/Ryujinx/actions/workflows
30+ )
31+ if [ -z "$RELEASE_JOB_DATA" ] || [[ $RELEASE_JOB_DATA =~ "rate limit exceeded" ]]; then
32+ echo "failed to get release job data" >&2
33+ exit 1
34+ fi
35+ RELEASE_JOB_ID=$(echo "$RELEASE_JOB_DATA" | jq -r '.workflows[] | select(.name == "Release job") | .id')
36+ RELEASE_JOB_FILE=$(echo "$RELEASE_JOB_DATA" | jq -r '.workflows[] | select(.name == "Release job") | .path')
37+
38+ LATEST_RELEASE_JOB_DATA=$(
39+ curl -s -H "Accept: application/vnd.github.v3+json" \
40+ ${GITHUB_TOKEN:+ -H "Authorization: bearer $GITHUB_TOKEN"} \
41+ "https://api.github.com/repos/Ryujinx/Ryujinx/actions/workflows/${RELEASE_JOB_ID}/runs"
42+ )
43+ if [ -z "$LATEST_RELEASE_JOB_DATA" ] || [[ $LATEST_RELEASE_JOB_DATA =~ "rate limit exceeded" ]]; then
44+ echo "failed to get latest release job data" >&2
45+ exit 1
46+ fi
47+ COMMIT=$(echo "$LATEST_RELEASE_JOB_DATA" | jq -r '.workflow_runs[0] | .head_sha')
48+ PATCH_VERSION=$(echo "$LATEST_RELEASE_JOB_DATA" | jq -r '.workflow_runs[0] | .run_number')
49+
50+ BASE_VERSION=$(
51+ curl -s "https://raw.githubusercontent.com/Ryujinx/Ryujinx/master/${RELEASE_JOB_FILE}" |
52+ grep -Po 'RYUJINX_BASE_VERSION:.*?".*"' |
53+ sed 's/RYUJINX_BASE_VERSION: "\(.*\)"/\1/'
54+ )
55+
56+ NEW_VERSION="${BASE_VERSION}.${PATCH_VERSION}"
57+fi
3158
3259OLD_VERSION="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)"
3360