Skip to content

Commit

Permalink
Devbuild embed (?)
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Mar 10, 2024
1 parent 61471a6 commit 20e873f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 43 deletions.
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": 11761899,
"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
23 changes: 10 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ jobs:
mkdir artifacts
cp dist/${TARGET}-*/flipper-z-${TARGET}-{update,sdk}-* artifacts/
cd dist/${TARGET}-*/${TARGET}-update-*/
artifact="$(basename "$(realpath .)")"
7z a ../../../artifacts/flipper-z-${artifact}.zip .
ARTIFACT_TAG=flipper-z-"$(basename "$(realpath .)")"
7z a ../../../artifacts/${ARTIFACT_TAG}.zip .
echo "ARTIFACT_TAG=$ARTIFACT_TAG" >> $GITHUB_ENV
- name: "Upload artifacts to update server"
if: ${{ !github.event.pull_request.head.repo.fork }}
Expand All @@ -95,14 +96,10 @@ jobs:
${FILES[@]} \
"${{ secrets.INDEXER_URL }}"/firmware/uploadfiles
# - name: Send devbuild webhook
# if: "github.event_name == 'push' && github.ref_name == 'dev' && !contains(github.event.head_commit.message, '--nobuild')"
# env:
# NC_HOST: "https://cloud.cynthialabs.net/"
# NC_USERAGENT: "${{ secrets.NC_USERAGENT }}"
# NC_USER: "${{ secrets.NC_USER }}"
# NC_PASS: "${{ secrets.NC_PASS }}"
# BUILD_WEBHOOK: ${{ secrets.BUILD_WEBHOOK }}
# run: |
# python -m pip install pyncclient
# python .github/workflow_data/devbuild.py
- name: Send devbuild webhook
if: "github.event_name == 'push' && github.ref_name == 'dev' && !contains(github.event.head_commit.message, '--nobuild')"
env:
INDEXER_URL: ${{ secrets.INDEXER_URL }}
BUILD_WEBHOOK: ${{ secrets.BUILD_WEBHOOK }}
run: |
python .github/workflow_data/devbuild.py

0 comments on commit 20e873f

Please sign in to comment.