Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update generate json to new format #266

Merged
merged 13 commits into from
Jan 16, 2024
52 changes: 35 additions & 17 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -293,7 +311,7 @@ jobs:
uses: robinraju/[email protected]
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
Expand Down
5 changes: 5 additions & 0 deletions config/armbian/bananapim2zero
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions config/armbian/default
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions config/armbian/orangepi3lts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions config/armbian/orangepi4lts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 14 additions & 0 deletions config/default
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions config/orangepi/default
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions config/orangepi/orangepi_zero2
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 9 additions & 0 deletions config/raspberry/default
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions config/raspberry/rpi32
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions config/raspberry/rpi64
Original file line number Diff line number Diff line change
Expand Up @@ -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"