Unverified Commit 8d3051e0 authored by Kenichi Kamiya's avatar Kenichi Kamiya
Browse files

lichess-bot: add updateScript

parent fe08782f
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@
  python3Packages,
  fetchFromGitHub,
  versionCheckHook,
  writeShellApplication,
  curl,
  jq,
  common-updater-scripts,
}:

python3Packages.buildPythonApplication {
@@ -50,6 +54,30 @@ python3Packages.buildPythonApplication {
  versionCheckProgramArg = "--disable_auto_logging";
  doInstallCheck = true;

  passthru = {
    updateScript = lib.getExe (writeShellApplication {
      name = "lichess-bot-update-script";

      runtimeInputs = [
        curl
        jq
        common-updater-scripts
      ];

      text = ''
        commit_msg='^Auto update version to (?<ver>[0-9.]+)$'
        commit="$(
          curl -s 'https://api.github.com/repos/lichess-bot-devs/lichess-bot/commits?path=lib/versioning.yml' | \
          jq -c "map(select(.commit.message | test(\"$commit_msg\"))) | first"
        )"
        rev="$(jq -r '.sha' <<< "$commit")"
        version="$(jq -r ".commit.message | capture(\"$commit_msg\") | .ver" <<< "$commit")"

        update-source-version lichess-bot "$version" --rev="$rev"
      '';
    });
  };

  meta = {
    description = "Bridge between lichess.org and bots";
    homepage = "https://github.com/lichess-bot-devs/lichess-bot";