mirror of
https://github.com/armbian/actions.git
synced 2026-01-06 10:36:19 -08:00
80 lines
3.0 KiB
YAML
80 lines
3.0 KiB
YAML
name: "Make JSON from releases"
|
|
author: "Igor Pecovnik"
|
|
description: "Make JSON from releases"
|
|
inputs:
|
|
owner:
|
|
description: Owner
|
|
required: true
|
|
repository:
|
|
description: Repository
|
|
required: true
|
|
filename:
|
|
description: Filename
|
|
required: false
|
|
grep:
|
|
description: grep
|
|
required: false
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
|
|
- name: Checkout build repository
|
|
uses: actions/checkout@v3.1.0
|
|
with:
|
|
fetch-depth: 1
|
|
repository: armbian/build
|
|
path: build
|
|
clean: false
|
|
|
|
- name: Checkout ${{ inputs.repository }} repository
|
|
if: ${{ inputs.repository != 'build' }}
|
|
uses: actions/checkout@v3.1.0
|
|
with:
|
|
fetch-depth: 1
|
|
repository: ${{ inputs.owner }}/${{ inputs.repository }}
|
|
path: ${{ inputs.repository }}
|
|
clean: false
|
|
|
|
- name: Install dependencies
|
|
shell: bash
|
|
run: |
|
|
|
|
function enable_extension()
|
|
{
|
|
return 0
|
|
}
|
|
|
|
mkdir -p json
|
|
sudo npm install --location=global json || true
|
|
PARA1=$(echo ${{ inputs.grep }} | cut -d" " -f1)
|
|
PARA2=$(echo ${{ inputs.grep }} | cut -d" " -f2)
|
|
[[ $PARA1 == $PARA2 ]] && unset PARA1
|
|
[[ -n "${{ inputs.grep }}" ]] && GREP=" | grep $PARA1 \""$(echo $PARA2 | sed 's/,/\\|/g')"\""
|
|
[[ -z "${{ inputs.filename }}" ]] && FILENAME="${{ inputs.repository }}" || FILENAME="${{ inputs.filename }}"
|
|
|
|
truncate json/${FILENAME}.json --size=0 || true
|
|
truncate json/${FILENAME}.md --size=0 || true
|
|
|
|
COMMAND="gh release view --json assets --repo github.com/${{ inputs.owner }}/\${{ inputs.repository }} 2>/dev/null | python3 -mjson.tool | sed '1,2d;\$d' | json -ga name url size updatedAt -d, | sort $GREP "
|
|
|
|
eval $COMMAND | (while read -r line; do
|
|
name=$(echo $line | cut -d"," -f1 | awk '{print tolower($0)}')
|
|
url=$(echo $line | cut -d"," -f2)
|
|
size=$(echo $line | cut -d"," -f3)
|
|
updated=$(echo $line | cut -d"," -f4)
|
|
if [[ "${name: -3}" == ".xz" ]]; then
|
|
board_name=$(echo $name | cut -d"_" -f3)
|
|
source build/config/boards/$board_name.*
|
|
out_release=$(echo $name | cut -d"_" -f4)
|
|
out_branch=$(echo $name | cut -d"_" -f5)
|
|
out_kernel=$(echo $name | cut -d"_" -f6-7 | cut -d"." -f1-3 | cut -d"_" -f1)
|
|
out_desktop=$(echo $name | cut -d"_" -f7- | cut -d"." -f1 | cut -d"_" -f1)
|
|
out_size=$(echo "scale=0; $size/1024/1024" | bc -l)"M"
|
|
echo -ne "${board_name}/${out_release^}_${out_branch}$([[ -n "${out_desktop}" ]] && echo "_")${out_desktop}_nightly|$url|"$(date -d $updated +"%s")"|$out_size|\n" \
|
|
>> json/${FILENAME}.json
|
|
out_desktop=${out_desktop:-cli}
|
|
echo -ne "| [$BOARD_NAME]($url#$board_name) | [:file_folder:]($url".asc") | [:file_folder:]($url".sha") | $out_release | $out_branch | $out_desktop | $out_size | $out_kernel |\n" \
|
|
>> json/${FILENAME}.md
|
|
fi
|
|
done)
|