Created
February 14, 2023 19:30
-
-
Save QueenOfSquiggles/15a74afe6f4aec78653d226623055ae1 to your computer and use it in GitHub Desktop.
A script for pushing game release builds to Itch IO automatically. Supports a variety of game engines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import configparser | |
import os | |
""" | |
A script for automatically pushing released builds to a game project, using information from a configuration file. | |
The configuration file is hard coded to be named 'builds_config.cfg' and be in the same directory as this script, as well as the folders and archives for release. | |
The folder/ZIP must be named the intended release channel. See Butler documentation for recommended naming. | |
After initial publishing, you can change settings for each channel from the project edit page on Itch IO. | |
Configuration File: | |
--------- | |
[Meta] | |
author = <author username> | |
game = <game page name> | |
[Game] | |
version = <custom version, or 'auto' for automatic versioning> | |
""" | |
DEBUG = False | |
def RunCommand(cmd : str): | |
result = subprocess.run(cmd, shell=True) | |
if DEBUG: | |
print(result) | |
def ProcessChannel(path : str): | |
print(f"Processing channel for: {path}") | |
channel = path | |
if channel.endswith(".zip"): | |
channel = channel.removesuffix(".zip") | |
cmd = f'butler push {path} {author}/{game}:{channel}' | |
if version != 'auto': | |
cmd += f' --userversion {version}' | |
print(cmd) | |
RunCommand(cmd) | |
# Load configuration file | |
cfg = configparser.RawConfigParser() | |
cfg.read_file(open(r'builds_config.cfg')) | |
author = cfg.get('Meta', 'author') | |
game = cfg.get('Meta', 'game') | |
version = cfg.get('Game', 'version') | |
print(f'Running release for {author}\'s game "{game}". Version numbering: {version}') | |
dir_obj = os.scandir(r'.') | |
for entry in dir_obj: | |
if entry.is_dir(): | |
ProcessChannel(entry.name) | |
if entry.is_file() and entry.name.endswith("zip"): | |
ProcessChannel(entry.name) | |
print("All recognized channels have been released") | |
# RunCommand(f'echo "hello there, {author}"') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: this script does require butler to be on your system path. Read more about butler here: https://itch.io/docs/butler/