Skip to content

Commit

Permalink
Modify workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhaopudark committed Oct 20, 2023
1 parent d2bdcfb commit 180def0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto_self_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
git config --global user.name ${Env:GIT_USER_NAME}
git add .
git commit -m "Auto push $((Get-Date).ToString("yyyy-MM-dd HH:mm:ss"))"
git push
git push --set-upstream origin main
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/build_on_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,4 @@ jobs:
shell: pwsh
run: |
sudo apt install fontforge
$hash = Get-FileHash -Path ./Output/JetBrainsMonoNerdFont-Regular.ttf -Algorithm MD5
. "./build.ps1"
$newHash = Get-FileHash -Path ./Output/JetBrainsMonoNerdFont-Regular.ttf -Algorithm MD5
if ($hash.Hash -eq $newHash.Hash) {
Write-Host "MD5 hash of font file unchanged, no changes detected."
Write-Host "The MD5 is $($hash.Hash)"
}else{
Write-Host "MD5 hash of font file changed, pushing to repository..."
Write-Host "The old MD5 is $($hash.Hash)"
Write-Host "The new MD5 is $($newHash.Hash)"
}
11 changes: 1 addition & 10 deletions .github/workflows/build_on_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,8 @@ jobs:
Import-Module PSComputerManagementZp
choco install fontforge --yes --limitoutput --force
Add-PathToCurrentProcessEnvPath -Path "C:\Program Files (x86)\FontForgeBuilds\bin"
$hash = Get-FileHash -Path ./Output/JetBrainsMonoNerdFont-Regular.ttf -Algorithm MD5
. ".\build.ps1"
$newHash = Get-FileHash -Path ./Output/JetBrainsMonoNerdFont-Regular.ttf -Algorithm MD5
if ($hash.Hash -eq $newHash.Hash) {
Write-Host "MD5 hash of font file unchanged, no changes detected."
Write-Host "The MD5 is $($hash.Hash)"
}else{
Write-Host "MD5 hash of font file changed, pushing to repository..."
Write-Host "The old MD5 is $($hash.Hash)"
Write-Host "The new MD5 is $($newHash.Hash)"
}
Expand Down
69 changes: 37 additions & 32 deletions auto_update.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import pathlib
import subprocess
import json
Expand Down Expand Up @@ -28,42 +29,46 @@ def local_build_test(build_script_path:str,build_output_path:str):
return False

def main(json_info_path:str):
with open(json_info_path, 'r+', encoding='utf-8') as json_file:
with open(json_info_path, 'r', encoding='utf-8') as json_file:
parsed_dict = json.load(json_file)
jbm_version_old = version.parse(parsed_dict["JetBrainsMono"]["version"])
jbm_version_new = get_latest_stable_version(
user_name=parsed_dict["JetBrainsMono"]["user_name"],
repo_name=parsed_dict["JetBrainsMono"]["repo_name"],
timeout=10,
defalut_version=parsed_dict["JetBrainsMono"]["defalut_version"]
)
nf_version_old = version.parse(parsed_dict["nerd-fonts"]["version"])
nf_version_new = get_latest_stable_version(
user_name=parsed_dict["nerd-fonts"]["user_name"],
repo_name=parsed_dict["nerd-fonts"]["repo_name"],
timeout=10,
defalut_version=parsed_dict["nerd-fonts"]["defalut_version"]
)
if ((jbm_version_new > jbm_version_old) and (nf_version_new > nf_version_old)):
if local_build_test(
build_script_path=parsed_dict["self"]["build_script_path"],
build_output_path=parsed_dict["self"]["build_output_path"]):
self_version = version.parse(parsed_dict['self']['version'])
self_version = version.parse(f"v{self_version.major}.{self_version.minor+1}")
parsed_dict['self']['version'] = f"v{self_version}"
parsed_dict["JetBrainsMono"]["version"] = f"v{jbm_version_new}"
parsed_dict["nerd-fonts"]["version"] = f"v{nf_version_new}"
json_file.seek(0)
json_file.truncate() # clear all contents

jbm_version_old = version.parse(parsed_dict["JetBrainsMono"]["version"])
jbm_version_new = get_latest_stable_version(
user_name=parsed_dict["JetBrainsMono"]["user_name"],
repo_name=parsed_dict["JetBrainsMono"]["repo_name"],
timeout=10,
defalut_version=parsed_dict["JetBrainsMono"]["defalut_version"]
)
nf_version_old = version.parse(parsed_dict["nerd-fonts"]["version"])
nf_version_new = get_latest_stable_version(
user_name=parsed_dict["nerd-fonts"]["user_name"],
repo_name=parsed_dict["nerd-fonts"]["repo_name"],
timeout=10,
defalut_version=parsed_dict["nerd-fonts"]["defalut_version"]
)
if ((jbm_version_new > jbm_version_old) and (nf_version_new > nf_version_old)):

if local_build_test(
build_script_path=parsed_dict["self"]["build_script_path"],
build_output_path=parsed_dict["self"]["build_output_path"]):
self_version = version.parse(parsed_dict['self']['version'])
self_version = version.parse(f"v{self_version.major}.{self_version.minor+1}")
parsed_dict['self']['version'] = f"v{self_version}"
parsed_dict["JetBrainsMono"]["version"] = f"v{jbm_version_new}"
parsed_dict["nerd-fonts"]["version"] = f"v{nf_version_new}"
with open(json_info_path, 'w', encoding='utf-8') as json_file:
json.dump(parsed_dict, json_file)
print("Local build success. File updated.")
else:
print("Local build failed. Nothing changed.")
print("Local build success. File updated.")
else:
print("The object is the latest version and there is no need to compile and upload it.")
print("Local build failed. Nothing changed.")
sys.exit(1) # return failed code (non-zero) to shell
else:
print("The object is the latest version and there is no need to compile and upload it.")



if __name__ == "__main__":
script_root = pathlib.Path(__file__).parent.absolute()
main(json_info_path=f"{script_root}/basicinfo.json")
main(json_info_path=f"{script_root}/basicinfo.json")


0 comments on commit 180def0

Please sign in to comment.