ci: add custom commits for updates

This commit is contained in:
matt1432 2023-03-16 17:57:09 -04:00
parent 78b1806e6c
commit 0e37f7ad67
3 changed files with 23 additions and 3 deletions

View file

@ -8,7 +8,7 @@ steps:
entrypoint: [ "/bin/bash" ]
commands:
- apt update
- apt install -y --no-install-recommends pipx python3-venv python3.9 python3-pip
- apt install -y --no-install-recommends pipx python3-venv python3.9 python3-pip git
- cd updater
- pipx install pipenv
- pipx ensurepath
@ -22,8 +22,6 @@ steps:
settings:
branch: main
remote: git@git.nelim.org:matt1432/android_vendor_mulchwebview.git
commit: true
commit_message: "Update APK"
ssh_key:
from_secret: ssh

16
updater/git.py Normal file
View file

@ -0,0 +1,16 @@
import subprocess
user_name = 'Updater Robot'
user_email = 'robot@nowhere.invalid'
def add_commit(directory: str, message: str):
diff = subprocess.run(['git', 'diff', '--cached', '--exit-code'], capture_output=True, text=True)
if diff.returncode != 0:
status = subprocess.run(['git', 'status'], capture_output=True, text=True)
raise Exception('Unknown staged changes found: {}'.format(status.stdout))
subprocess.run(['git', 'add', '--all', directory], check=True)
subprocess.run(['git', '-c', 'user.name={}'.format(user_name), '-c', 'user.email={}'.format(user_email),
'commit', '--message', message])

View file

@ -2,6 +2,7 @@ import urllib.request
from os import path
import certificates
import git
from sources import ApkRelease, fdroid_recommended_release
@ -27,6 +28,11 @@ def update_if_needed(module: str, release: ApkRelease):
version_code_file.truncate()
version_code_file.close()
print('commit...')
git.add_commit(module_dir, 'Update {} to {}'.format(module, release.version_name))
elif version_code > release.version_code:
print('{} ahead of suggested version ({} > {})'.format(module, version_code, release.version_code))
elif version_code == release.version_code: