update caddy-bgme lilac.py

This commit is contained in:
bgme 2023-08-23 17:45:43 +08:00
parent cb59a4451a
commit 27cb986e8e
2 changed files with 44 additions and 3 deletions

41
repo/caddy-bgme/lilac.py Normal file
View file

@ -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)

View file

@ -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