Joe Stanley
78ecefbf07
All checks were successful
Potlatch Loggers Organization/ComputerKeeper/pipeline/head This commit looks good
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
################################################################################
|
|
"""
|
|
Publish the EXE as a package to Gitea.
|
|
"""
|
|
################################################################################
|
|
|
|
import os
|
|
import requests
|
|
|
|
OWNER = "Potlatch-Loggers"
|
|
PKG_NAME = "ComputerKeeper-BUILD"
|
|
PKG_VERSION = "latest"
|
|
FILE_NAME = "main.exe"
|
|
|
|
AUTH_USER = os.getenv("GITEA_USER")
|
|
AUTH_PASS = os.getenv("GITEA_PASS")
|
|
|
|
HOST = "https://gitea.stanleysolutionsnw.com"
|
|
|
|
def main():
|
|
"""Attempt Deleting the Package, then Add the New Package with File."""
|
|
s = requests.Session()
|
|
s.auth = (AUTH_USER, AUTH_PASS)
|
|
# Delete Package
|
|
try:
|
|
print("Deleting...")
|
|
result = s.delete(
|
|
f"{HOST}/api/packages/{OWNER}/generic/{PKG_NAME}/{PKG_VERSION}"
|
|
)
|
|
result.raise_for_status()
|
|
except Exception:
|
|
# Intentionally Overlook Issues Here
|
|
print("No package to delete.")
|
|
# Add New Package
|
|
print("Adding new package...")
|
|
result = s.put(
|
|
(
|
|
f"{HOST}/api/packages/{OWNER}/generic/{PKG_NAME}/{PKG_VERSION}/" +
|
|
FILE_NAME
|
|
),
|
|
data=open(f"dist/{FILE_NAME}", 'rb').read(),
|
|
)
|
|
result.raise_for_status()
|
|
|
|
if __name__ == "__main__":
|
|
main() |