mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-30 21:58:55 -07:00
New release workflow
This commit is contained in:
@@ -22,7 +22,7 @@ if __name__ == "__main__":
|
||||
"title": "New Devbuild!",
|
||||
"description": "",
|
||||
"url": "",
|
||||
"color": 11761899,
|
||||
"color": 16751147,
|
||||
"fields": [
|
||||
{
|
||||
"name": "Changes since last commit:",
|
||||
|
||||
@@ -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!**
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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": [],
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
name: "Post-release hooks"
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [prereleased, released]
|
||||
|
||||
jobs:
|
||||
reindex:
|
||||
name: "Post-release hooks"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: "Trigger reindex"
|
||||
run: |
|
||||
curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \
|
||||
"${{ secrets.INDEXER_URL }}"/firmware/reindex;
|
||||
|
||||
# - name: "Send release notification"
|
||||
# if: ${{ github.event.action == 'released' }}
|
||||
# run: |
|
||||
# echo '${{ secrets.FIREBASE_TOKEN }}' > firebase-token.json;
|
||||
# python3 -m pip install firebase-admin==6.4.0;
|
||||
# python3 scripts/send_firebase_notification.py \
|
||||
# "--version=${{ github.event.release.name }}" \
|
||||
# "--token=firebase-token.json";
|
||||
@@ -0,0 +1,47 @@
|
||||
name: "Release"
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- released
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: "Update release notes"
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
run: python .github/workflow_data/release.py
|
||||
|
||||
- name: "Download release assets from tag build"
|
||||
run: |
|
||||
set -e
|
||||
wget "${{ secrets.INDEXER_URL }}"/firmware/${{ github.event.release.tag_name }}/flipper-z-f7-update-${{ github.event.release.tag_name }}.tgz
|
||||
wget "${{ secrets.INDEXER_URL }}"/firmware/${{ github.event.release.tag_name }}/flipper-z-f7-update-${{ github.event.release.tag_name }}.zip
|
||||
wget "${{ secrets.INDEXER_URL }}"/firmware/${{ github.event.release.tag_name }}/flipper-z-f7-sdk-${{ github.event.release.tag_name }}.zip
|
||||
|
||||
- name: "Update release with assets and notes"
|
||||
uses: "softprops/action-gh-release@v1"
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
with:
|
||||
body_path: .github/workflow_data/release.md
|
||||
files: |
|
||||
flipper-z-f7-update-${{ github.event.release.tag_name }}.tgz
|
||||
flipper-z-f7-update-${{ github.event.release.tag_name }}.zip
|
||||
flipper-z-f7-sdk-${{ github.event.release.tag_name }}.zip
|
||||
|
||||
- name: "Trigger reindex"
|
||||
run: |
|
||||
curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \
|
||||
"${{ secrets.INDEXER_URL }}"/firmware/reindex;
|
||||
|
||||
- name: "Send release notification"
|
||||
env:
|
||||
RELEASE_WEBHOOK: ${{ secrets.RELEASE_WEBHOOK }}
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
run: python .github/workflow_data/webhook.py
|
||||
@@ -2,9 +2,6 @@ name: "Webhook"
|
||||
|
||||
on:
|
||||
push:
|
||||
release:
|
||||
types:
|
||||
- "published"
|
||||
workflow_run:
|
||||
workflows:
|
||||
- "Build"
|
||||
|
||||
Reference in New Issue
Block a user