Skip to content

Commit

Permalink
Merge branch 'Next-Flip:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Spooks4576 authored Mar 10, 2024
2 parents e677556 + 1577bbc commit 19f5f42
Show file tree
Hide file tree
Showing 54 changed files with 1,242 additions and 677 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @Willy-JL @Sil333033
* @Willy-JL @Sil333033 @HaxSam @MatthewKuKanich
4 changes: 0 additions & 4 deletions .github/workflow_data/commit.sh

This file was deleted.

38 changes: 8 additions & 30 deletions .github/workflow_data/devbuild.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,42 @@
#!/usr/bin/env python
import nextcloud_client
import datetime as dt
import requests
import json
import os

dev_share_id = ""
dev_share = os.environ["NC_HOST"] + f"s/{dev_share_id}/download?path=/&files={{files}}"
artifact_tgz = f"{os.environ['INDEXER_URL']}/firmware/dev/{os.environ['ARTIFACT_TAG']}.tgz"
artifact_sdk = f"{os.environ['INDEXER_URL']}/firmware/dev/{os.environ['ARTIFACT_TAG'].replace('update', 'sdk')}.zip"


if __name__ == "__main__":
with open(os.environ["GITHUB_EVENT_PATH"], "r") as f:
event = json.load(f)

client = nextcloud_client.Client(os.environ["NC_HOST"])
client.login(os.environ["NC_USER"], os.environ["NC_PASS"])

for file in (
os.environ["ARTIFACT_TGZ"],
os.environ["ARTIFACT_SDK"],
):
path = f"MNTM-Dev/{file}"
# try:
# client.delete(path)
# except Exception:
# pass
client.put_file(path, file)

requests.post(
os.environ["BUILD_WEBHOOK"],
headers={"Accept": "application/json", "Content-Type": "application/json"},
json={
"content": None,
"embeds": [
{
"title": "New Devbuild:",
"title": "New Devbuild!",
"description": "",
"url": "",
"color": 16734443,
"color": 16751147,
"fields": [
{
"name": "Changes since last commit:",
"value": f"[Compare {event['before'][:7]} to {event['after'][:7]}]({event['compare']})"
},
{
"name": "Changes since last release:",
"value": f"[Compare release to {event['after'][:7]}]({event['compare'].rsplit('/', 1)[0] + '/main...' + event['after']})"
"value": f"[Compare release to {event['after'][:7]}]({event['compare'].rsplit('/', 1)[0] + '/release...' + event['after']})"
},
{
"name": "Firmware download:",
"value": f"- [Download SDK for development]({dev_share.format(files=os.environ['ARTIFACT_SDK'])})\n- [Download Firmware TGZ]({dev_share.format(files=os.environ['ARTIFACT_TGZ'])})"
"name": "Download artifacts:",
"value": f"- [Download Firmware TGZ]({artifact_tgz})\n- [SDK (for development)]({artifact_sdk})"
}
],
"author": {
"name": "Build Succeeded!",
# "icon_url": ""
},
# "footer": {
# "text": "Build go brrrr",
# "icon_url": ""
# },
"timestamp": dt.datetime.utcnow().isoformat()
}
],
Expand Down
18 changes: 0 additions & 18 deletions .github/workflow_data/package.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflow_data/release.md
Original file line number Diff line number Diff line change
@@ -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!**

Expand Down
21 changes: 14 additions & 7 deletions .github/workflow_data/release.py
Original file line number Diff line number Diff line change
@@ -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")
13 changes: 0 additions & 13 deletions .github/workflow_data/version.sh

This file was deleted.

99 changes: 10 additions & 89 deletions .github/workflow_data/webhook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import datetime as dt
import requests
import json
import sys
Expand Down Expand Up @@ -41,97 +42,16 @@
desc = desc.rsplit("\n", 1)[0] + f"\n+ {count - i} more commits"
break
url = event["compare"]
color = 16723712 if event["forced"] else 3669797

# case "pull_request":
# pr = event["pull_request"]
# url = pr["html_url"]
# branch = pr["base"]["ref"] + (
# ""
# if pr["base"]["repo"]["full_name"] != pr["head"]["repo"]["full_name"]
# else f" <- {pr['head']['ref']}"
# )
# name = pr["title"][:50] + ("..." if len(pr["title"]) > 50 else "")
# title = f"Pull Request {event['action'].title()} ({branch}): {name}"
# match event["action"]:
# case "opened":
# desc = (pr["body"][:2045] + "...") if len(pr["body"]) > 2048 else pr["body"]
# color = 3669797

# fields.append(
# {
# "name": "Changed Files:",
# "value": str(pr["changed_files"]),
# "inline": True,
# }
# )
# fields.append(
# {
# "name": "Added:",
# "value": "+" + str(pr["additions"]),
# "inline": True,
# }
# )
# fields.append(
# {
# "name": "Removed:",
# "value": "-" + str(pr["deletions"]),
# "inline": True,
# }
# )

# case "closed":
# color = 16723712
# case "reopened":
# color = 16751872
# case _:
# sys.exit(1)
color = 16723712 if event["forced"] else 11761899

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"]
Expand Down Expand Up @@ -192,6 +112,7 @@
"url": event["sender"]["html_url"],
"icon_url": event["sender"]["avatar_url"],
},
"timestamp": dt.datetime.utcnow().isoformat()
}
],
"attachments": [],
Expand Down
36 changes: 0 additions & 36 deletions .github/workflow_data/webupdater.py

This file was deleted.

Loading

0 comments on commit 19f5f42

Please sign in to comment.