mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-08 19:11:53 -07:00
Rework workflows and add devbuilds
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
export VERSION_TAG="$(python -c 'import fbt_options; print(fbt_options.DIST_SUFFIX, end="")')"
|
||||
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python
|
||||
import nextcloud_client
|
||||
import datetime as dt
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
|
||||
dev_share = os.environ["NC_HOST"] + "s/sGHsQB94a9x5CRs/download?path=/&files={files}"
|
||||
|
||||
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"XFW-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": "Devbuild infos:",
|
||||
"description": "",
|
||||
"url": "",
|
||||
"color": 16734443,
|
||||
"fields": [
|
||||
{
|
||||
"name": "Changes since last commit:",
|
||||
"value": f"[Compare {event['before']} to {event['after']}]({event['compare']})"
|
||||
},
|
||||
{
|
||||
"name": "Changes since last release:",
|
||||
"value": f"[Compare release to {event['after']}]({event['compare'].replace(event['before'], 'main')})"
|
||||
},
|
||||
{
|
||||
"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'])})"
|
||||
}
|
||||
],
|
||||
"author": {
|
||||
"name": "Build Succeeded!",
|
||||
"icon_url": "https://cdn.discordapp.com/emojis/1080005692485795930.png"
|
||||
},
|
||||
"footer": {
|
||||
"text": "Build go brrrr",
|
||||
"icon_url": "https://cdn.discordapp.com/emojis/1059798228725403719.png"
|
||||
},
|
||||
"timestamp": dt.datetime.utcnow().isoformat()
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
@@ -1,4 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
export VERSION_TAG="$(python -c 'import fbt_options; print(fbt_options.DIST_SUFFIX)')"
|
||||
export VERSION_TAG="$(python -c '''
|
||||
import datetime as dt
|
||||
with open(os.environ["GITHUB_EVENT_PATH"], "r") as f:
|
||||
event = json.load(f)
|
||||
version = int(event["pull_request"]["title"].removeprefix("V").removesuffix(" Release").removesuffix(" Hotfix"))
|
||||
date = dt.datetime.now().strftime("%d%m%Y")
|
||||
print(f"XFW-{version:04}_{date}", end="")
|
||||
''')"
|
||||
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV
|
||||
|
||||
+18
-27
@@ -24,47 +24,38 @@ jobs:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: "Read version tag"
|
||||
run: bash .github/workflow_data/commit.sh
|
||||
|
||||
- name: 'Build the firmware'
|
||||
run: |
|
||||
set -e
|
||||
for TARGET in ${TARGETS}; do
|
||||
TARGET_HW="$(echo "${TARGET}" | sed 's/f//')"; \
|
||||
./fbt TARGET_HW=$TARGET_HW updater_package
|
||||
./fbt TARGET_HW=$TARGET_HW DIST_SUFFIX=$VERSION_TAG updater_package
|
||||
done
|
||||
|
||||
- name: "Check for uncommitted changes"
|
||||
run: |
|
||||
git diff --exit-code
|
||||
|
||||
- name: 'Updater artifact'
|
||||
- name: 'Dist artifact'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: updater
|
||||
name: dist
|
||||
path: |
|
||||
dist/${{ env.DEFAULT_TARGET }}-*/
|
||||
|
||||
# - name: 'Find Previous Comment'
|
||||
# if: ${{ github.event.pull_request }}
|
||||
# uses: peter-evans/find-comment@v1
|
||||
# id: fc
|
||||
# with:
|
||||
# issue-number: ${{ github.event.pull_request.number }}
|
||||
# comment-author: 'github-actions[bot]'
|
||||
# body-includes: 'Compiled firmware:'
|
||||
- name: "Make tgz, zip and sdk"
|
||||
run: bash .github/workflow_data/package.sh
|
||||
|
||||
# - name: Artifact info
|
||||
# id: artifact-info
|
||||
# uses: dawidd6/action-download-artifact@v2
|
||||
# with:
|
||||
# dry_run: true
|
||||
|
||||
# - name: 'Create or update comment'
|
||||
# if: ${{ github.event.pull_request}}
|
||||
# uses: peter-evans/create-or-update-comment@v1
|
||||
# with:
|
||||
# comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||
# issue-number: ${{ github.event.pull_request.number }}
|
||||
# body: |
|
||||
# **Compiled firmware:**
|
||||
# - [📦 Update package](${{steps.artifact-info.outputs.artifacts[0].archive_download_url}})
|
||||
# edit-mode: replace
|
||||
- name: Send devbuild webhook
|
||||
if: "github.event_name == 'push' && endsWith(github.event.push.ref, '/dev')"
|
||||
env:
|
||||
NC_HOST: "https://cloud.cynthialabs.net/"
|
||||
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
|
||||
|
||||
@@ -31,21 +31,21 @@ jobs:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: "Read version tag"
|
||||
run: bash .github/workflow_data/version.sh
|
||||
|
||||
- name: 'Build the firmware'
|
||||
run: |
|
||||
set -e
|
||||
for TARGET in ${TARGETS}; do
|
||||
TARGET_HW="$(echo "${TARGET}" | sed 's/f//')"; \
|
||||
./fbt TARGET_HW=$TARGET_HW FORCE_NO_DIRTY=1 updater_package
|
||||
./fbt TARGET_HW=$TARGET_HW DIST_SUFFIX=$VERSION_TAG FORCE_NO_DIRTY=1 updater_package
|
||||
done
|
||||
|
||||
- name: "Check for uncommitted changes"
|
||||
run: |
|
||||
git diff --exit-code
|
||||
|
||||
- name: "Read version tag"
|
||||
run: bash .github/workflow_data/version.sh
|
||||
|
||||
- name: "Make tgz, zip and sdk"
|
||||
run: bash .github/workflow_data/package.sh
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
release:
|
||||
if: |
|
||||
github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name &&
|
||||
endsWith(github.event.pull_request.title, ' Release Candidate Changes') &&
|
||||
endsWith(github.event.pull_request.title, ' Release') &&
|
||||
github.event.review.author_association == 'OWNER' &&
|
||||
startsWith(github.event.pull_request.title, 'V') &&
|
||||
github.event.pull_request.base.ref == 'main' &&
|
||||
@@ -31,21 +31,21 @@ jobs:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: "Read version tag"
|
||||
run: bash .github/workflow_data/version.sh
|
||||
|
||||
- name: 'Build the firmware'
|
||||
run: |
|
||||
set -e
|
||||
for TARGET in ${TARGETS}; do
|
||||
TARGET_HW="$(echo "${TARGET}" | sed 's/f//')"; \
|
||||
./fbt TARGET_HW=$TARGET_HW FORCE_NO_DIRTY=1 updater_package
|
||||
./fbt TARGET_HW=$TARGET_HW DIST_SUFFIX=$VERSION_TAG FORCE_NO_DIRTY=1 updater_package
|
||||
done
|
||||
|
||||
- name: "Check for uncommitted changes"
|
||||
run: |
|
||||
git diff --exit-code
|
||||
|
||||
- name: "Read version tag"
|
||||
run: bash .github/workflow_data/version.sh
|
||||
|
||||
- name: "Make tgz, zip and sdk"
|
||||
run: bash .github/workflow_data/package.sh
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import posixpath
|
||||
import datetime
|
||||
|
||||
# For more details on these options, run 'fbt -h'
|
||||
|
||||
@@ -19,7 +19,7 @@ DEBUG = 0
|
||||
# If OS environment has DIST_SUFFIX set, it will be used instead
|
||||
|
||||
# How about we add the timestamp automatically. Solves some problems
|
||||
DIST_SUFFIX = f"XFW-0049_{datetime.datetime.today().strftime('%d%m%Y')}"
|
||||
DIST_SUFFIX = f"XFW-DEV_@{subprocess.check_output(['git', 'rev-parse', '--short=7', 'HEAD']).decode().strip().upper()}"
|
||||
|
||||
# Coprocessor firmware
|
||||
COPRO_OB_DATA = "scripts/ob.data"
|
||||
|
||||
+1
-6
@@ -1,6 +1,4 @@
|
||||
#!/usb/bin/env python3
|
||||
VERSION = "XFW-0049"
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
@@ -32,14 +30,11 @@ class GitVersion:
|
||||
# (set by CI)
|
||||
branch = (
|
||||
os.environ.get("WORKFLOW_BRANCH_OR_TAG", None)
|
||||
or VERSION
|
||||
or self._exec_git("rev-parse --abbrev-ref HEAD")
|
||||
or "unknown"
|
||||
)
|
||||
|
||||
branch_num = self._exec_git("rev-list --count HEAD") or "n/a"
|
||||
|
||||
version = os.environ.get("DIST_SUFFIX", None) or VERSION or "unknown"
|
||||
version = os.environ.get("DIST_SUFFIX", None).split("_")[0] or "unknown"
|
||||
|
||||
force_no_dirty = os.environ.get("FORCE_NO_DIRTY", None) or ""
|
||||
if force_no_dirty != "":
|
||||
|
||||
Reference in New Issue
Block a user