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:
parent
be7b241b2f
commit
271e356ef1
2 changed files with 22 additions and 5 deletions
12
.github/workflows/updater.py
vendored
12
.github/workflows/updater.py
vendored
|
@ -11,9 +11,11 @@ You need to enable the action by removing `if ${{ false }}` in updater.yml!
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
import tomlkit
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from pathlib import Path
|
||||||
from subprocess import run, PIPE
|
from subprocess import run, PIPE
|
||||||
import textwrap
|
import textwrap
|
||||||
from typing import List, Tuple, Any
|
from typing import List, Tuple, Any
|
||||||
|
@ -86,6 +88,12 @@ def write_github_env(proceed: bool, new_version: str, branch: str):
|
||||||
"""))
|
"""))
|
||||||
|
|
||||||
def main():
|
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:
|
with open("manifest.json", "r", encoding="utf-8") as manifest_file:
|
||||||
manifest = json.load(manifest_file)
|
manifest = json.load(manifest_file)
|
||||||
repo = manifest["upstream"]["code"]
|
repo = manifest["upstream"]["code"]
|
||||||
|
@ -115,6 +123,10 @@ def main():
|
||||||
handle_asset(asset)
|
handle_asset(asset)
|
||||||
|
|
||||||
manifest["version"] = f"{latest_version}~ynh1"
|
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:
|
with open("manifest.json", "w", encoding="utf-8") as manifest_file:
|
||||||
json.dump(manifest, manifest_file, indent=4, ensure_ascii=False)
|
json.dump(manifest, manifest_file, indent=4, ensure_ascii=False)
|
||||||
manifest_file.write("\n")
|
manifest_file.write("\n")
|
||||||
|
|
5
.github/workflows/updater.yml
vendored
5
.github/workflows/updater.yml
vendored
|
@ -23,6 +23,11 @@ jobs:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
ref: testing
|
ref: testing
|
||||||
|
|
||||||
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
|
with:
|
||||||
|
packages: python3-tomlkit
|
||||||
|
version: 1.0
|
||||||
|
|
||||||
- name: Run the updater script
|
- name: Run the updater script
|
||||||
run: .github/workflows/updater.py
|
run: .github/workflows/updater.py
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue