mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Refactor release script to be more modular
This commit is contained in:
18
.github/workflow_data/package.sh
vendored
Normal file
18
.github/workflow_data/package.sh
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
export ARTIFACT_DIR="${VERSION_TAG}"
|
||||
|
||||
export ARTIFACT_TGZ="${VERSION_TAG}.tgz"
|
||||
export ARTIFACT_ZIP="${VERSION_TAG}.zip"
|
||||
cd dist/${DEFAULT_TARGET}-*
|
||||
mv ${DEFAULT_TARGET}-update-* ${ARTIFACT_DIR}
|
||||
tar --format=ustar -czvf ../../${ARTIFACT_TGZ} ${ARTIFACT_DIR}
|
||||
cd ${ARTIFACT_DIR}
|
||||
7z a ../../../${ARTIFACT_ZIP} .
|
||||
cd ../../..
|
||||
|
||||
python -m pip install pyncclient
|
||||
export ARTIFACT_WEB="$(NC_FILE=${ARTIFACT_TGZ} NC_PATH=XFW-Updater python .github/workflow_data/webupdater.py)"
|
||||
|
||||
echo "ARTIFACT_TGZ=${ARTIFACT_TGZ}" >> $GITHUB_ENV
|
||||
echo "ARTIFACT_WEB=${ARTIFACT_WEB}" >> $GITHUB_ENV
|
||||
echo "ARTIFACT_ZIP=${ARTIFACT_ZIP}" >> $GITHUB_ENV
|
||||
8
.github/workflow_data/release.md
vendored
8
.github/workflow_data/release.md
vendored
@@ -1,15 +1,15 @@
|
||||
## ⬇️ Download
|
||||
>### [🖥️ Web Updater (chrome)](https://lab.flipper.net/?url={webupdater_url}&channel=XFW-Updater&version={release_tag}) [recommended]
|
||||
>### [🖥️ Web Updater (chrome)](https://lab.flipper.net/?url={ARTIFACT_WEB}&channel=XFW-Updater&version={VERSION_TAG}) [recommended]
|
||||
|
||||
>### [🐬 qFlipper Package (.tgz)](https://github.com/ClaraCrazy/Flipper-Xtreme/releases/download/{release_tag}/{release_tag}.tgz)
|
||||
>### [🐬 qFlipper Package (.tgz)](https://github.com/ClaraCrazy/Flipper-Xtreme/releases/download/{VERSION_TAG}/{ARTIFACT_TGZ})
|
||||
|
||||
>### [📦 Zipped Archive (.zip)](https://github.com/ClaraCrazy/Flipper-Xtreme/releases/download/{release_tag}/{release_tag}.zip)
|
||||
>### [📦 Zipped Archive (.zip)](https://github.com/ClaraCrazy/Flipper-Xtreme/releases/download/{VERSION_TAG}/{ARTIFACT_ZIP})
|
||||
|
||||
**Remember to delete your `apps` folders before updating!**\
|
||||
**Check the [install guide](https://github.com/ClaraCrazy/Flipper-Xtreme#install) if you're not sure, or [join our Discord](https://discord.gg/flipper-xtreme) if you have questions or encounter issues!**
|
||||
|
||||
## 🚀 Changelog
|
||||
{changelog}
|
||||
{CHANGELOG}
|
||||
|
||||
## ❤️ Support
|
||||
If you like what you're seeing, **please consider donating to us**. We won't ever put this behind a paywall, but we'd still appreciate a few bucks!
|
||||
|
||||
19
.github/workflow_data/release.py
vendored
Normal file
19
.github/workflow_data/release.py
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
import json
|
||||
import os
|
||||
|
||||
if __name__ == "__main__":
|
||||
notes_path = '.github/workflow_data/release.md'
|
||||
with open(os.environ['GITHUB_EVENT_PATH']) as f:
|
||||
changelog = json.load(f.read())['pull_request']['body']
|
||||
with open(notes_path, "r") as f:
|
||||
template = f.read()
|
||||
notes = template.format(
|
||||
ARTIFACT_TGZ=os.environ['ARTIFACT_TGZ'],
|
||||
ARTIFACT_WEB=os.environ['ARTIFACT_WEB'],
|
||||
ARTIFACT_ZIP=os.environ['ARTIFACT_ZIP'],
|
||||
VERSION_TAG=os.environ['VERSION_TAG'],
|
||||
CHANGELOG=changelog
|
||||
)
|
||||
with open(notes_path, "w") as f:
|
||||
f.write(notes)
|
||||
4
.github/workflow_data/version.sh
vendored
Normal file
4
.github/workflow_data/version.sh
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
export VERSION_TAG="$(grep -o "DIST_SUFFIX = .*" fbt_options.py | cut -d'"' -f2)"
|
||||
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV
|
||||
12
.github/workflow_data/webupdater.py
vendored
Normal file
12
.github/workflow_data/webupdater.py
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import nextcloud_client
|
||||
import os
|
||||
|
||||
if __name__ == "__main__":
|
||||
client = nextcloud_client.Client(os.environ["NC_HOST"])
|
||||
client.login(os.environ["NC_USER"], os.environ["NC_PASS"])
|
||||
file = os.environ["NC_FILE"]
|
||||
path = os.environ["NC_PATH"] + file
|
||||
client.put_file(path, file)
|
||||
share_link = client.share_file_with_link(path).get_link()
|
||||
download_link = share_link.rstrip("/") + "/download/" + file
|
||||
print(download_link, end="")
|
||||
41
.github/workflows/release.yml
vendored
41
.github/workflows/release.yml
vendored
@@ -29,13 +29,7 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
|
||||
- name: "Read version number"
|
||||
run: |
|
||||
RELEASE_TAG="$(grep -o "DIST_SUFFIX = .*" fbt_options.py | cut -d'"' -f2)"
|
||||
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: 'Build the firmware'
|
||||
run: |
|
||||
@@ -45,21 +39,22 @@ jobs:
|
||||
./fbt TARGET_HW=$TARGET updater_package
|
||||
done
|
||||
|
||||
- name: "Make tgz, zip and webupdater"
|
||||
- name: "Check for uncommitted changes"
|
||||
run: |
|
||||
cd dist/${DEFAULT_TARGET}-*
|
||||
mv ${DEFAULT_TARGET}-update-* ${RELEASE_TAG}
|
||||
tar --format=ustar -czvf ../${RELEASE_TAG}.tgz ${RELEASE_TAG}
|
||||
cd ${RELEASE_TAG}
|
||||
7z a ../../${RELEASE_TAG}.zip .
|
||||
cd ../..
|
||||
python -m pip install pyncclient
|
||||
WEBUPDATER_URL="$(python -c "import nextcloud_client as n;c = n.Client('https://cloud.cynthialabs.net/');c.login('${{ secrets.NC_USER }}', '${{ secrets.NC_PASS }}');c.put_file('XFW-Updater/${RELEASE_TAG}.tgz', '${RELEASE_TAG}.tgz');print(c.share_file_with_link('XFW-Updater/${RELEASE_TAG}.tgz').get_link().rstrip('/') + '/download/${RELEASE_TAG}.tgz', end='')")"
|
||||
echo "WEBUPDATER_URL=${WEBUPDATER_URL}" >> $GITHUB_ENV
|
||||
git diff --exit-code
|
||||
|
||||
- name: "Read version tag"
|
||||
run: bash .github/workflow_data/version.sh
|
||||
|
||||
- name: "Make tgz, zip and webupdater"
|
||||
run: bash .github/workflow_data/package.sh
|
||||
env:
|
||||
NC_HOST: "https://cloud.cynthialabs.net/"
|
||||
NC_USER: "${{ secrets.NC_USER }}"
|
||||
NC_PASS: "${{ secrets.NC_PASS }}"
|
||||
|
||||
- name: "Update release notes"
|
||||
run: |
|
||||
python -c "import json, os;f = '.github/workflow_data/release.md';c = json.load(open(os.environ['GITHUB_EVENT_PATH']))['pull_request']['body'];f_ = open(f);n = f_.read().format(release_tag='${RELEASE_TAG}', webupdater_url='${WEBUPDATER_URL}', changelog=c);f_.close();f_ = open(f, 'w');f_.write(n);f_.close()"
|
||||
run: python .github/workflow_data/release.py
|
||||
|
||||
- name: "Merge pull request"
|
||||
uses: "pascalgn/automerge-action@v0.15.6"
|
||||
@@ -74,8 +69,8 @@ jobs:
|
||||
draft: false
|
||||
prerelease: false
|
||||
files: |
|
||||
dist/${{ env.RELEASE_TAG }}.tgz
|
||||
dist/${{ env.RELEASE_TAG }}.zip
|
||||
name: "${{ env.RELEASE_TAG }}"
|
||||
tag_name: "${{ env.RELEASE_TAG }}"
|
||||
dist/${{ env.ARTIFACT_TGZ }}
|
||||
dist/${{ env.ARTIFACT_ZIP }}
|
||||
name: "${{ env.VERSION_TAG }}"
|
||||
tag_name: "${{ env.VERSION_TAG }}"
|
||||
target_commitish: ${{ github.event.pull_request.base.ref }}
|
||||
|
||||
Reference in New Issue
Block a user