From 93d71e4828ab1333eec21d4fe20e053e1a4793f9 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:36:03 +0100 Subject: [PATCH] chore: update generate json to new format (#266) * chore: update generate json to new format Signed-off-by: Stephan Wendel * fix: fix process.env Signed-off-by: Stephan Wendel * fix: fix typo and fix globbing Signed-off-by: Stephan Wendel * fix: fix json output Signed-off-by: Stephan Wendel * fix: fix variable typo Signed-off-by: Stephan Wendel * fix: convert json to string Signed-off-by: Stephan Wendel * fix: fix json array output Signed-off-by: Stephan Wendel * ci(release): fix syntax to generate json Signed-off-by: Stefan Dej * ci(release): fix output name in json Signed-off-by: Stefan Dej * ci(release): build rpi-imager.json with all json files Signed-off-by: Stefan Dej * ci(release): fix typo in generate json Signed-off-by: Stefan Dej * ci(release): remove empty strings from devices array Signed-off-by: Stefan Dej * chore: remove rpi3 from json list Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel Signed-off-by: Stefan Dej Co-authored-by: Stefan Dej --- .github/workflows/Release.yml | 52 +++++++++++++++++++++++----------- config/armbian/bananapim2zero | 5 ++++ config/armbian/default | 5 ++++ config/armbian/orangepi3lts | 5 ++++ config/armbian/orangepi4lts | 5 ++++ config/default | 14 +++++++++ config/orangepi/default | 5 ++++ config/orangepi/orangepi_zero2 | 5 ++++ config/raspberry/default | 9 ++++++ config/raspberry/rpi32 | 5 ++++ config/raspberry/rpi64 | 5 ++++ 11 files changed, 98 insertions(+), 17 deletions(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index d4d800c46..0a11af780 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -219,41 +219,59 @@ jobs: echo "filesize-image: ${{ steps.filesizes.outputs.image }}" echo "filesize-zip: ${{ steps.filesizes.outputs.zip }}" + - name: Get JSON data + id: json-data + shell: bash + run: | + source repository/src/config + + if [[ -n "${BASE_ARCH}" ]]; then + type="64-bit" + else + type="32-bit" + fi + + name="${JSON_PRETTY_NAME} ${{ github.event.inputs.version }}" + name="${name} - ${JSON_PRETTY_SBC_NAME}" + name="${name} (${type})" + + echo "pretty_name=${name}" >> $GITHUB_OUTPUT + echo "description=${JSON_DESCRIPTION}" >> $GITHUB_OUTPUT + echo "icon_url=${JSON_ICON_URL}" >> $GITHUB_OUTPUT + echo "init_format=${JSON_INIT_FORMAT}" >> $GITHUB_OUTPUT + echo "supported_sbc=${JSON_SUPPORTED_SBC}" >> $GITHUB_OUTPUT + - name: Generate JSON id: json uses: actions/github-script@v6 env: - name: "Mainsail OS ${{ github.event.inputs.version }}" - description: "Type: ${{ steps.build.outputs.type }}, SBC: ${{ steps.build.outputs.sbc }}" - type: "${{ steps.build.outputs.type }}" - sbc: "${{ steps.build.outputs.sbc }}" - url: "https://github.com/mainsail-crew/MainsailOS/releases/download/${{ github.event.inputs.version }}/${{ steps.move-image.outputs.image }}.img.xz" - icon: "https://os.mainsail.xyz/rpi-imager.png" - init_format: "systemd" - release_date: "${{ needs.release.outputs.date }}" + name: "${{ steps.json-data.outputs.pretty_name }}" + description: "${{ steps.json-data.outputs.description }}" + icon: "${{ steps.json-data.outputs.icon_url }}" + url: "https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.version }}/${{ steps.move-image.outputs.image }}.img.xz" extract_size: ${{ steps.filesizes.outputs.image }} extract_sha256: "${{ steps.checksums.outputs.image }}" image_download_size: ${{ steps.filesizes.outputs.zip }} - image_download_sha256: "${{ steps.checksums.outputs.zip }}" + release_date: "${{ needs.release.outputs.date }}" + init_format: "${{ steps.json-data.outputs.init_format }}" + supported_sbc: ${{ steps.json-data.outputs.supported_sbc }} with: result-encoding: string script: | const fs = require('fs') - let { name, description, type, sbc, url, icon, init_format, release_date, extract_size, extract_sha256, image_download_size, image_download_sha256 } = process.env - if (sbc === 'rpi32') name += ' 32-Bit (recommend)' - else if (sbc === 'rpi64') name += ' 64-Bit' + const { name, description, icon, url, extract_size, extract_sha256, image_download_size, release_date, init_format, supported_sbc } = process.env const json = JSON.stringify({ name, description, - url, icon, - init_format, - release_date, + url, extract_size: parseInt(extract_size), extract_sha256, image_download_size: parseInt(image_download_size), - image_download_sha256 + release_date, + init_format, + devices: supported_sbc.split(" ").filter((item) => item != '') }) fs.writeFileSync("./${{ steps.move-image.outputs.image }}.json", json) @@ -293,7 +311,7 @@ jobs: uses: robinraju/release-downloader@v1.6 with: tag: ${{ github.event.inputs.version }} - fileName: "${{ needs.build.outputs.base_name }}-raspberry-*.json" + fileName: "${{ needs.build.outputs.base_name }}-*.json" out-file-path: "downloads" - name: Combine JSON diff --git a/config/armbian/bananapim2zero b/config/armbian/bananapim2zero index e22a42b26..118ee9e36 100644 --- a/config/armbian/bananapim2zero +++ b/config/armbian/bananapim2zero @@ -10,3 +10,8 @@ DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-bananapi_m2_zero_bullseye.img.x export BASE_ARCH export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_PRETTY_SBC_NAME="Banana Pi M2 Zero" diff --git a/config/armbian/default b/config/armbian/default index bd7d28436..151b69826 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -37,3 +37,8 @@ export BASE_IMAGE_ENLARGEROOT export BASE_IMAGE_RESIZEROOT export BASE_RELEASE_COMPRESS export MODULES + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_DESCRIPTION="A port of Armbian with preinstalled Klipper/Moonraker/Mainsail for 3D printers" diff --git a/config/armbian/orangepi3lts b/config/armbian/orangepi3lts index 8fd06d0a1..03a262498 100644 --- a/config/armbian/orangepi3lts +++ b/config/armbian/orangepi3lts @@ -12,3 +12,8 @@ DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts_bullseye.img.xz" export BASE_ARCH export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_PRETTY_SBC_NAME="Orange Pi 3 LTS" diff --git a/config/armbian/orangepi4lts b/config/armbian/orangepi4lts index 5b0a312c8..5628ef2ce 100644 --- a/config/armbian/orangepi4lts +++ b/config/armbian/orangepi4lts @@ -12,3 +12,8 @@ DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz" export BASE_ARCH export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_PRETTY_SBC_NAME="Orange Pi 4 LTS" diff --git a/config/default b/config/default index 385d177a5..b472fb84a 100644 --- a/config/default +++ b/config/default @@ -30,3 +30,17 @@ DIST_NAME="MainsailOS" export DIST_NAME export DIST_VERSION export BASE_ZIP_IMG + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_PRETTY_NAME="Mainsail OS" +# shellcheck disable=SC2034 +JSON_DESCRIPTION="A OS image with Klipper/Moonraker/Mainsail preinstalled for your 3D printers" +# shellcheck disable=SC2034 +JSON_ICON_URL="https://os.mainsail.xyz/rpi-imager.png" +# shellcheck disable=SC2034 +JSON_INIT_FORMAT="none" +# shellcheck disable=SC2034 +JSON_SUPPORTED_SBC="" +# JSON_SUPPORTED_SBC="pi1-32bit pi2-32bit pi3-32bit pi3-64bit pi4-32bit pi4-64bit pi5-64bit" diff --git a/config/orangepi/default b/config/orangepi/default index 8cfe3ad87..6fbaafaac 100644 --- a/config/orangepi/default +++ b/config/orangepi/default @@ -37,3 +37,8 @@ export BASE_IMAGE_ENLARGEROOT export BASE_IMAGE_RESIZEROOT export BASE_RELEASE_COMPRESS export MODULES + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_DESCRIPTION="A port of Orange Pi OS with preinstalled Klipper/Moonraker/Mainsail for 3D printers" diff --git a/config/orangepi/orangepi_zero2 b/config/orangepi/orangepi_zero2 index c149d83f2..aa171209c 100644 --- a/config/orangepi/orangepi_zero2 +++ b/config/orangepi/orangepi_zero2 @@ -12,3 +12,8 @@ DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2_bullseye.img.xz export BASE_ARCH export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_PRETTY_SBC_NAME="Orange Pi Zero2" diff --git a/config/raspberry/default b/config/raspberry/default index 7ec32ad79..0fd604202 100644 --- a/config/raspberry/default +++ b/config/raspberry/default @@ -16,3 +16,12 @@ export BASE_IMAGE_ENLARGEROOT export BASE_IMAGE_RESIZEROOT export BASE_RELEASE_COMPRESS export MODULES + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_DESCRIPTION="A port of Raspberry Pi OS with preinstalled Klipper/Moonraker/Mainsail for 3D printers" +# shellcheck disable=SC2034 +JSON_INIT_FORMAT="systemd" +# shellcheck disable=SC2034 +JSON_PRETTY_SBC_NAME="Raspberry Pi" diff --git a/config/raspberry/rpi32 b/config/raspberry/rpi32 index ab7d9f6d4..8239ff3c7 100644 --- a/config/raspberry/rpi32 +++ b/config/raspberry/rpi32 @@ -14,3 +14,8 @@ DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.com/raspios_oldstable_lite_arm export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_SUPPORTED_SBC="pi1-32bit pi2-32bit" diff --git a/config/raspberry/rpi64 b/config/raspberry/rpi64 index 7cee4dd60..01c486d33 100644 --- a/config/raspberry/rpi64 +++ b/config/raspberry/rpi64 @@ -19,3 +19,8 @@ DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.com/raspios_oldstable_lite_arm export BASE_ARCH export DOWNLOAD_URL_CHECKSUM export DOWNLOAD_URL_IMAGE + +### JSON sniplet Setup +### NOTE: Please see all config files for setup variables!!! +# shellcheck disable=SC2034 +JSON_SUPPORTED_SBC="pi3-64bit pi4-64bit"