-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- automating everything... at least trying to...
- Loading branch information
Showing
12 changed files
with
340 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
load('cirrus', 'env', 'http') | ||
|
||
|
||
def on_build_completed(_ctx): | ||
completed_release(_ctx) | ||
|
||
|
||
def on_build_failed(_ctx): | ||
failed_release(_ctx) | ||
|
||
|
||
def failed_release(_ctx): | ||
if env.get("CIRRUS_TAG") != None: | ||
delete_current_release() | ||
|
||
|
||
def completed_release(_ctx): | ||
if env.get("CIRRUS_TAG") != None: | ||
finish_current_release() | ||
|
||
|
||
def repo_path(): | ||
return "/repos/bodand/cg3" | ||
|
||
|
||
def delete_current_release(): | ||
"""Deletes the current release.""" | ||
rel_id = get_current_release() | ||
print("deleting release with id {}".format(rel_id)) | ||
delete_release(rel_id) | ||
|
||
|
||
def finish_current_release(): | ||
"""Updates the current release from draft to complete release.""" | ||
rel_id = get_current_release() | ||
print("finishing release with id {}".format(rel_id)) | ||
return finish_release(rel_id) | ||
|
||
|
||
def get_current_release(): | ||
releases = github_get(repo_path() + "/releases").json() | ||
for rel in releases: | ||
if rel["draft"]: | ||
print("found draft for tag: '{}', id: '{}'".format(rel["tag_name"], rel["id"])) | ||
return "{}".format(rel["id"]) | ||
return None | ||
|
||
def delete_release(id): | ||
github_delete(repo_path() + "/releases/" + id) | ||
|
||
|
||
def finish_release(id): | ||
github_patch(repo_path() + "/releases/" + id, {"draft": False}) | ||
|
||
|
||
def get_github_token(): | ||
return env.get("GITHUB_TOKEN") | ||
|
||
|
||
def github_delete(url): | ||
hdrs = { | ||
"Accept": "application/vnd.github+json", | ||
"Authorization": "Bearer " + get_github_token(), | ||
"X-GitHub-Api-Version": "2022-11-28" | ||
} | ||
http.delete("https://api.github.com" + url, headers=hdrs) | ||
|
||
|
||
def github_get(url): | ||
hdrs = { | ||
"Accept": "application/vnd.github+json", | ||
"Authorization": "Bearer " + get_github_token(), | ||
"X-GitHub-Api-Version": "2022-11-28" | ||
} | ||
return http.get("https://api.github.com" + url, headers=hdrs) | ||
|
||
|
||
def github_patch(url, body): | ||
hdrs = { | ||
"Accept": "application/vnd.github+json", | ||
"Authorization": "Bearer " + get_github_token(), | ||
"X-GitHub-Api-Version": "2022-11-28" | ||
} | ||
return http.patch("https://api.github.com" + url, headers=hdrs, json_body=body) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Cg3 v0.2.2 changelog | ||
|
||
## Internal changes | ||
|
||
- WIP releases should now be created only as Drafts | ||
- Automate upgrading completed draft releases to complete releases using Starlark | ||
- Automate deleting incomplete releases using Starlark | ||
- Extract all logic from .cirrus.yml into external shell scripts | ||
- Write Windows specific batch/powershell scripts for CI/CD | ||
- Windows CI | ||
- Windows CD | ||
- Releases now contain Windows MSI installers |
Oops, something went wrong.