New release workflow

This commit is contained in:
Willy-JL
2024-03-10 12:45:49 +00:00
parent c0ed5bcd85
commit ed08b194e5
7 changed files with 73 additions and 84 deletions

View File

@@ -22,7 +22,7 @@ if __name__ == "__main__":
"title": "New Devbuild!",
"description": "",
"url": "",
"color": 11761899,
"color": 16751147,
"fields": [
{
"name": "Changes since last commit:",

View File

@@ -1,9 +1,9 @@
## ⬇️ Download
>### [🖥️ Web Updater (chrome)](https://momentum-fw.dev/update) [recommended]
>### [🐬 qFlipper Package (.tgz)](https://github.com/Next-Flip/Momentum-Firmware/releases/download/{VERSION_TAG}/{ARTIFACT_TGZ})
>### [🐬 qFlipper Package (.tgz)](https://github.com/Next-Flip/Momentum-Firmware/releases/download/{VERSION_TAG}/flipper-z-f7-update-{VERSION_TAG}.tgz)
>### [📦 Zipped Archive (.zip)](https://github.com/Next-Flip/Momentum-Firmware/releases/download/{VERSION_TAG}/{ARTIFACT_ZIP})
>### [📦 Zipped Archive (.zip)](https://github.com/Next-Flip/Momentum-Firmware/releases/download/{VERSION_TAG}/flipper-z-f7-update-{VERSION_TAG}.zip)
**Check the [install guide](https://github.com/Next-Flip/Momentum-Firmware#install) if you're not sure, or [join our Discord](https://discord.gg/momentum) if you have questions or encounter issues!**

View File

@@ -1,20 +1,27 @@
#!/usr/bin/env python
import requests
import json
import os
if __name__ == "__main__":
with open(os.environ["GITHUB_EVENT_PATH"], "r") as f:
event = json.load(f)
release = requests.get(
event["release"]["url"],
headers={
"Accept": "application/vnd.github.v3+json",
"Authorization": f"token {os.environ['GITHUB_TOKEN']}"
}
).json()
version_tag = release["tag_name"]
changelog = release["body"]
notes_path = '.github/workflow_data/release.md'
with open(os.environ['GITHUB_EVENT_PATH'], "r") as f:
changelog = json.load(f)['pull_request']['body']
with open(notes_path, "r") as f:
template = f.read()
notes = template.format(
ARTIFACT_TGZ=os.environ['ARTIFACT_TGZ'],
ARTIFACT_ZIP=os.environ['ARTIFACT_ZIP'],
VERSION_TAG=os.environ['VERSION_TAG'],
VERSION_TAG=version_tag,
CHANGELOG=changelog
)
with open(notes_path, "w") as f:
f.write(notes)
with open(os.environ["ARTIFACT_TGZ"].removesuffix(".tgz") + ".md", "w") as f:
f.write(changelog.strip() + "\n\n")

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env python
import datetime as dt
import requests
import json
import sys
@@ -44,50 +45,13 @@ if __name__ == "__main__":
color = 16723712 if event["forced"] else 3669797
case "release":
match event["action"]:
case "published":
webhook = "RELEASE_WEBHOOK"
color = 13845998
title = f"New Release published: {event['name']}"
desc += f"Changelog:"
changelog = "".join(
event["body"]
.split("Changelog")[1]
.split("<!---")[0]
.split("###")
)
downloads = [
option
for option in [
Type.replace("\n\n>", "")
for Type in event["body"]
.split("Download\n>")[1]
.split("### ")[:3]
]
if option
]
for category in changelog:
group = category.split(":")[0].replace(" ", "")
data = category.split(":")[1:].join(":")
fields.append(
{
"name": {group},
"value": {
(data[:2045] + "...") if len(data) > 2048 else data
},
}
)
fields.append(
{
"name": "Downloads:",
"value": "\n".join(downloads),
"inline": True,
}
)
case _:
sys.exit(1)
webhook = "RELEASE_WEBHOOK"
color = 9471191
version_tag = event['release']['tag_name']
title = f"New Release: `{version_tag}`"
desc += f"> 💻 [**Web Installer**](https://momentum-fw.dev/update)\n\n"
desc += f"> 🐬 [**Changelog & Download**](https://github.com/Next-Flip/Momentum-Firmware/releases/tag/{version_tag})\n\n"
desc += f"> 🛞 [**Project Page**](https://github.com/Next-Flip/Momentum-Firmware)"
case "workflow_run":
run = event["workflow_run"]
@@ -148,6 +112,7 @@ if __name__ == "__main__":
"url": event["sender"]["html_url"],
"icon_url": event["sender"]["avatar_url"],
},
"timestamp": dt.datetime.utcnow().isoformat()
}
],
"attachments": [],