-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Fansana:master' into Tilkku's-Toys
- Loading branch information
Showing
6 changed files
with
82 additions
and
125 deletions.
There are no files selected for viewing
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import requests | ||
import os | ||
import subprocess | ||
|
||
GITHUB_TOKEN = os.environ["GITHUB_TOKEN"] | ||
PUBLISH_TOKEN = os.environ["PUBLISH_TOKEN"] | ||
ARTIFACT_ID = os.environ["ARTIFACT_ID"] | ||
GITHUB_REPOSITORY = os.environ["GITHUB_REPOSITORY"] | ||
VERSION = os.environ['GITHUB_SHA'] | ||
|
||
# | ||
# CONFIGURATION PARAMETERS | ||
# Forks should change these to publish to their own infrastructure. | ||
# | ||
ROBUST_CDN_URL = "http://floofstation.com:27690/" | ||
FORK_ID = "floofstation-main" | ||
|
||
def main(): | ||
print("Fetching artifact URL from API...") | ||
artifact_url = get_artifact_url() | ||
print(f"Artifact URL is {artifact_url}, publishing to Robust.Cdn") | ||
|
||
data = { | ||
"version": VERSION, | ||
"engineVersion": get_engine_version(), | ||
"archive": artifact_url | ||
} | ||
headers = { | ||
"Authorization": f"Bearer {PUBLISH_TOKEN}", | ||
"Content-Type": "application/json" | ||
} | ||
resp = requests.post(f"{ROBUST_CDN_URL}fork/{FORK_ID}/publish", json=data, headers=headers) | ||
resp.raise_for_status() | ||
print("Publish succeeded!") | ||
|
||
def get_artifact_url() -> str: | ||
headers = { | ||
"Authorization": f"Bearer {GITHUB_TOKEN}", | ||
"X-GitHub-Api-Version": "2022-11-28" | ||
} | ||
resp = requests.get(f"https://api.github.com/repos/{GITHUB_REPOSITORY}/actions/artifacts/{ARTIFACT_ID}/zip", allow_redirects=False, headers=headers) | ||
resp.raise_for_status() | ||
|
||
return resp.headers["Location"] | ||
|
||
def get_engine_version() -> str: | ||
proc = subprocess.run(["git", "describe","--tags", "--abbrev=0"], stdout=subprocess.PIPE, cwd="RobustToolbox", check=True, encoding="UTF-8") | ||
tag = proc.stdout.strip() | ||
assert tag.startswith("v") | ||
return tag[1:] # Cut off v prefix. | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |