Skip to content

Commit

Permalink
chore: update generate json to new format
Browse files Browse the repository at this point in the history
Signed-off-by: Stephan Wendel <[email protected]>
  • Loading branch information
KwadFan committed Jan 12, 2024
1 parent 9e52bb8 commit 939bce3
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 15 deletions.
61 changes: 46 additions & 15 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,41 +219,72 @@ 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
pretty_name=${JSON_PRETTY_NAME}
if [[ -n "${BASE_ARCH}" ]]; then
type="64bit"
else
type="32bit"
fi
name="${pretty_name}"
name="${name} ${{ github.event.inputs.version }}"
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
read -a SBC_ARRAY <<< "${JSON_SUPPORTED_SBC}"
json_array="["
for sbc in "${SBC_ARRAY[@]}""; do
json_array+="\"${sbc}\""
if [[ $sbc != ${SBC_ARRAY[-1]} ]]; then
json_array+=","
fi
done
json_array+="]"
echo "supported_sbc=${json_array}" >> $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 }}"
name: "${{ steps.json-data.outputs.pretty_name }}"
description: "${{ steps.json-data.outputs.description }}"
icon: "${{ steps.json-data.outputs.icon_url }}"
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 }}"
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 }}"
devices: "${{ 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'
let { name, description, type, sbc, url, icon, init_format, release_date, extract_size, extract_sha256, image_download_size } = 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
})
fs.writeFileSync("./${{ steps.move-image.outputs.image }}.json", 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 snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_SUPPORTED_SBC="bananapim2zero-64bit"
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 snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_DESCRIPTION="A port of Armbian with preinstalled 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 snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_SUPPORTED_SBC="orangepi3lts-64bit"
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 snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_SUPPORTED_SBC="orangepi4lts-64bit"
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 snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_PRETTY_NAME="Mainsail OS"
# shellcheck disable=SC2034
# JSON_DESCRIPTION="!" # <- moved to SBC specific default file
# shellcheck disable=SC2034
JSON_ICON_URL="https://os.mainsail.xyz/rpi-imager.png"
# shellcheck disable=SC2034
JSON_INIT_FORMAT="systemd"
### NOTE: Move line below according to your images! This is only an example!
# # shellcheck disable=SC2034
# 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 snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_DESCRIPTION="A port of Orange Pi OS with preinstalled 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 snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_SUPPORTED_SBC="orangepizero2-64bit"
5 changes: 5 additions & 0 deletions config/raspberry/default
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ export BASE_IMAGE_ENLARGEROOT
export BASE_IMAGE_RESIZEROOT
export BASE_RELEASE_COMPRESS
export MODULES

### JSON snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_DESCRIPTION="A port of Raspberry Pi OS with preinstalled Mainsail for 3D printers"
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 snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_SUPPORTED_SBC="pi1-32bit pi2-32bit pi3-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 snipplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_SUPPORTED_SBC="pi3-64bit pi4-64bit"

0 comments on commit 939bce3

Please sign in to comment.