1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cinny_ynh.git synced 2024-09-03 18:16:13 +02:00

Use tomlkit to read manifest

This commit is contained in:
Félix Piédallu 2023-03-30 10:00:12 +02:00
parent be7b241b2f
commit 271e356ef1
2 changed files with 22 additions and 5 deletions

View file

@ -11,9 +11,11 @@ You need to enable the action by removing `if ${{ false }}` in updater.yml!
import hashlib
import json
import tomlkit
import logging
import os
import re
from pathlib import Path
from subprocess import run, PIPE
import textwrap
from typing import List, Tuple, Any
@ -86,6 +88,12 @@ def write_github_env(proceed: bool, new_version: str, branch: str):
"""))
def main():
repository_path = Path(__file__).parent.parent.parent
manifest_toml = repository_path / "manifest.toml"
if manifest_toml.exists():
with open(manifest_toml, "r", encoding="utf-8") as manifest_file:
manifest = tomlkit.parse(manifest_file.read())
else:
with open("manifest.json", "r", encoding="utf-8") as manifest_file:
manifest = json.load(manifest_file)
repo = manifest["upstream"]["code"]
@ -115,6 +123,10 @@ def main():
handle_asset(asset)
manifest["version"] = f"{latest_version}~ynh1"
if manifest_toml.exists():
with open(manifest_toml, "w", encoding="utf-8") as manifest_file:
tomlkit.dump(manifest, manifest_file)
else:
with open("manifest.json", "w", encoding="utf-8") as manifest_file:
json.dump(manifest, manifest_file, indent=4, ensure_ascii=False)
manifest_file.write("\n")

View file

@ -23,6 +23,11 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
ref: testing
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: python3-tomlkit
version: 1.0
- name: Run the updater script
run: .github/workflows/updater.py