From 27cb986e8ea55143f13bc407fa06dcdcfeedfbed Mon Sep 17 00:00:00 2001 From: bgme Date: Wed, 23 Aug 2023 17:45:43 +0800 Subject: [PATCH] update caddy-bgme lilac.py --- repo/caddy-bgme/lilac.py | 41 ++++++++++++++++++++++++++++++++++++++ repo/caddy-bgme/lilac.yaml | 6 +++--- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 repo/caddy-bgme/lilac.py diff --git a/repo/caddy-bgme/lilac.py b/repo/caddy-bgme/lilac.py new file mode 100644 index 0000000..7c08978 --- /dev/null +++ b/repo/caddy-bgme/lilac.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +from lilaclib import * + + +def get_caddy_latest_release_tag(): + resp = s.get( + 'https://api.github.com/repos/caddyserver/caddy/releases/latest' + ) + body = resp.json() + return body["tag_name"] + + +def get_caddy_dist_commit_by_tag(tag): + resp = s.get( + 'https://api.github.com/repos/caddyserver/dist/tags' + ) + body = resp.json() + + _dist_commit = list(filter(lambda x: x["name"] == tag, body)) + if len(_dist_commit) == 1: + dist_commit = _dist_commit[0] + return dist_commit["commit"]["sha"] + else: + raise OSError("Not Found {} dist commit".format(tag)) + + +def pre_build(): + caddy_tag = get_caddy_latest_release_tag() + dist_commit = get_caddy_dist_commit_by_tag(caddy_tag) + + pkgver = caddy_tag.lstrip('v') + + for line in edit_file('PKGBUILD'): + if line.startswith('_gitcommit='): + line = '_gitcommit={}'.format(caddy_tag) + if line.startswith('_distcommit='): + line = '_distcommit={}'.format(dist_commit) + print(line) + + update_pkgver_and_pkgrel(pkgver) diff --git a/repo/caddy-bgme/lilac.yaml b/repo/caddy-bgme/lilac.yaml index 80d7ff5..cb961b9 100644 --- a/repo/caddy-bgme/lilac.yaml +++ b/repo/caddy-bgme/lilac.yaml @@ -4,9 +4,9 @@ maintainers: build_prefix: extra-x86_64 -pre_build: vcs_update - post_build: git_pkgbuild_commit update_on: - - source: vcs + - source: github + github: caddyserver/caddy + use_latest_release: true