Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
theripper93 committed May 30, 2024
1 parent 4163167 commit 41e15ea
Show file tree
Hide file tree
Showing 11 changed files with 624 additions and 508 deletions.
46 changes: 46 additions & 0 deletions create_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import json
import zipfile

# Define selected folders
selected_folders = ['scripts', 'styles', 'assets', 'templates', 'languages', 'packs', 'storage']

def read_module_json():
with open(file, 'r', encoding='utf-8') as file:
data = json.load(file)
module_id = data['id']
module_version = data['version']
return module_id, module_version

def create_dist_folder():
if not os.path.exists('dist'):
os.makedirs('dist')

def add_folder_to_zip(zip_file, folder):
if os.path.exists(folder):
for root, dirs, files in os.walk(folder):
for file in files:
file_path = os.path.join(root, file)
relative_path = os.path.relpath(file_path, folder)
zip_file.write(file_path, os.path.join(folder, relative_path))
else:
print(f"Warning: {folder} is missing. Skipping.")

def create_zip(module_id, module_version, folders):
zip_filename = f'dist/{module_id}-{module_version}.zip'
with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zip_file:
zip_file.write('module.json')

for folder in folders:
add_folder_to_zip(zip_file, folder)

print(f"Zip file '{zip_filename}' created successfully.")

def main():
module_id, module_version = read_module_json()
create_dist_folder()

create_zip(module_id, module_version, selected_folders)

if __name__ == "__main__":
main()
97 changes: 97 additions & 0 deletions make_post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import os
import json
import subprocess
import requests

def get_git_repo_info():
try:
# Get the remote URL of the Git repository
remote_url = subprocess.check_output(['git', 'config', '--get', 'remote.origin.url']).decode('utf-8').strip()

# Extract the repository owner and name from the remote URL
repo_owner, repo_name = remote_url.split('/')[-2:]
repo_name = repo_name.rstrip('.git')

return repo_owner, repo_name
except subprocess.CalledProcessError:
print("Error: Not a Git repository or Git not installed.")
return None, None

def get_latest_release(repo_owner, repo_name, token):
url = f'https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(url, headers=headers)
data = response.json()
return data

def get_project_title_and_id():
with open('module.json', 'r', encoding='utf-8') as json_file:
data = json.load(json_file)
title = data.get('title', 'Project Title Not Found')
id = data.get('id', 'Project ID Not Found')
return title, id

def post_discord_webhook(webhook_url, embed_title, embed_description):
# Create the payload for the webhook
payload = {
'embeds': [
{
'title': embed_title,
'description': embed_description,
'color': 0x00ff00 # You can customize the color (hex) of the embed
}
]
}

# Make an HTTP POST request to the webhook URL
headers = {'Content-Type': 'application/json'}
response = requests.post(webhook_url, data=json.dumps(payload), headers=headers)

# Check if the request was successful
if response.status_code == 200 or response.status_code == 204:
print("Webhook posted successfully.")
else:
print(f"Failed to post webhook. Status code: {response.status_code}")

def load_secrets():
secrets_file_path = os.path.join(os.path.dirname(__file__), '..', 'SECRETS.json')

try:
with open(secrets_file_path, 'r') as secrets_file:
secrets = json.load(secrets_file)
return secrets
except FileNotFoundError:
print(f"SECRETS.json file not found at: {secrets_file_path}")
return {}
except json.JSONDecodeError:
print(f"Error decoding JSON in SECRETS.json file at: {secrets_file_path}")
return {}

if __name__ == "__main__":
# Get Git repository information
repo_owner, repo_name = get_git_repo_info()

if repo_owner and repo_name:
secrets = load_secrets()

# Get Discord webhook URL and GitHub token from secrets
discord_webhook_url = secrets.get('DISCORD_WEBHOOK_URL')
github_token = secrets.get('GITHUB_TOKEN')

# Get the latest release information from GitHub
latest_release = get_latest_release(repo_owner, repo_name, github_token)
version = latest_release.get('tag_name', 'Version Not Found')
description = latest_release.get('body', 'No description available for this release.')

project_title, id = get_project_title_and_id()
package_page_link = f"\n\n**Package Page**\n https://foundryvtt.com/packages/{id}"

description += package_page_link

# Get project title and id from module.json file


# Post Discord webhook with the embed
post_discord_webhook(discord_webhook_url, f'{project_title} - Version {version}', description)
else:
print("Unable to retrieve Git repository information.")
174 changes: 88 additions & 86 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,87 +1,89 @@
{
"title": "Boss Bar",
"description": "Add a souls-like boss healthbar to the scene",
"version": "0.1",
"authors": [
{
"name": "theripper93",
"email": "[email protected]",
"url": "https://www.patreon.com/theripper93"
}
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
},
{
"lang": "es",
"name": "Español",
"path": "languages/es.json"
},
{
"lang": "pt",
"name": "Português",
"path": "languages/pt.json"
}, {
"lang": "pt-BR",
"name": "Português (Brasil)",
"path": "languages/pt-BR.json"
}, {
"lang": "pt-PT",
"name": "Português (Portugal)",
"path": "languages/pt-PT.json"
},
{
"lang": "de",
"name": "Deutsch",
"path": "languages/de.json"
},
{
"lang": "ja",
"name": "日本語",
"path": "languages/ja.json"
}
],
"scripts": [
"scripts/main.js",
"scripts/BossBar.js",
"scripts/cameraPan.js"
],
"styles": [
"styles/module.css"
],
"packs": [
{
"name": "bossbarmacros",
"label": "Boss Bar Macros",
"path": "packs/macros.db",
"type": "Macro",
"private": false
}
],
"url": "https://github.com/theripper93/Boss-Bar",
"manifest": "https://github.com/theripper93/Boss-Bar/releases/latest/download/module.json",
"download": "https://github.com/theripper93/Boss-Bar/releases/latest/download/module.zip",
"socket": true,
"id": "bossbar",
"relationships": {
"requires": [
{
"id": "socketlib",
"type": "module",
"compatibility": {}
},
{
"id": "colorsettings",
"type": "module",
"compatibility": {}
}
]
},
"compatibility": {
"minimum": "11",
"verified": "11"
}
{
"title": "Boss Bar",
"description": "Add a souls-like boss healthbar to the scene",
"version": "0.1",
"authors": [
{
"name": "theripper93",
"email": "[email protected]",
"url": "https://www.patreon.com/theripper93"
}
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
},
{
"lang": "es",
"name": "Español",
"path": "languages/es.json"
},
{
"lang": "pt",
"name": "Português",
"path": "languages/pt.json"
},
{
"lang": "pt-BR",
"name": "Português (Brasil)",
"path": "languages/pt-BR.json"
},
{
"lang": "pt-PT",
"name": "Português (Portugal)",
"path": "languages/pt-PT.json"
},
{
"lang": "de",
"name": "Deutsch",
"path": "languages/de.json"
},
{
"lang": "ja",
"name": "日本語",
"path": "languages/ja.json"
}
],
"scripts": [
"scripts/main.js",
"scripts/BossBar.js",
"scripts/cameraPan.js"
],
"styles": [
"styles/module.css"
],
"packs": [
{
"name": "bossbarmacros",
"label": "Boss Bar Macros",
"path": "packs/macros.db",
"type": "Macro",
"private": false
}
],
"url": "https://github.com/theripper93/Boss-Bar",
"manifest": "https://github.com/theripper93/Boss-Bar/releases/latest/download/module.json",
"download": "https://github.com/theripper93/Boss-Bar/releases/latest/download/module.zip",
"socket": true,
"id": "bossbar",
"relationships": {
"requires": [
{
"id": "socketlib",
"type": "module",
"compatibility": {}
},
{
"id": "colorsettings",
"type": "module",
"compatibility": {}
}
]
},
"compatibility": {
"minimum": "12",
"verified": "12"
}
}
Empty file removed packs/macros/000289.log
Empty file.
Binary file added packs/macros/000317.log
Binary file not shown.
2 changes: 1 addition & 1 deletion packs/macros/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000288
MANIFEST-000316
6 changes: 3 additions & 3 deletions packs/macros/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2023/11/13-01:46:59.714 af58 Recovering log #287
2023/11/13-01:46:59.718 af58 Delete type=0 #287
2023/11/13-01:46:59.718 af58 Delete type=3 #286
2024/05/30-13:41:09.648 27d0 Recovering log #314
2024/05/30-13:41:09.652 27d0 Delete type=0 #314
2024/05/30-13:41:09.652 27d0 Delete type=3 #312
11 changes: 8 additions & 3 deletions packs/macros/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2023/11/12-18:27:40.924 1884 Recovering log #285
2023/11/12-18:27:40.928 1884 Delete type=0 #285
2023/11/12-18:27:40.928 1884 Delete type=3 #284
2024/04/22-23:04:08.088 2c88 Recovering log #310
2024/04/22-23:04:08.091 2c88 Delete type=0 #310
2024/04/22-23:04:08.091 2c88 Delete type=3 #308
2024/04/22-23:07:38.383 52f8 Level-0 table #315: started
2024/04/22-23:07:38.383 52f8 Level-0 table #315: 0 bytes OK
2024/04/22-23:07:38.385 52f8 Delete type=0 #313
2024/04/22-23:07:38.390 52f8 Manual compaction at level-0 from '!macros!LD5Wc6K0vLQw0att' @ 72057594037927935 : 1 .. '!macros!iWwnlmoMWqNGJ54U' @ 0 : 0; will stop at (end)
2024/04/22-23:07:38.402 52f8 Manual compaction at level-1 from '!macros!LD5Wc6K0vLQw0att' @ 72057594037927935 : 1 .. '!macros!iWwnlmoMWqNGJ54U' @ 0 : 0; will stop at (end)
Binary file not shown.
Loading

0 comments on commit 41e15ea

Please sign in to comment.