261 lines
9.8 KiB
YAML
261 lines
9.8 KiB
YAML
#
|
|
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304>
|
|
#
|
|
# This is free software, licensed under the MIT License.
|
|
# See /LICENSE for more information.
|
|
#
|
|
|
|
name: Custom Build
|
|
on:
|
|
issues:
|
|
types:
|
|
- labeled
|
|
|
|
jobs:
|
|
build:
|
|
if: github.event.label.name == 'custom'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@main
|
|
|
|
- name: Init Env
|
|
run: |
|
|
git config --global user.email "info@auxxxilium.tech"
|
|
git config --global user.name "AuxXxilium"
|
|
sudo timedatectl set-timezone "Europe/Berlin"
|
|
|
|
sudo apt update
|
|
sudo apt install -y jq gawk cpio gettext libelf-dev qemu-utils busybox dialog curl sed
|
|
sudo snap install yq
|
|
|
|
- name: Check Custom
|
|
shell: python
|
|
run: |
|
|
# -*- coding: utf-8 -*-
|
|
import json, subprocess
|
|
def set_output(name, value):
|
|
subprocess.call(["echo '{}={}' >> $GITHUB_ENV".format(name, value)], shell=True)
|
|
|
|
issuetitle = ${{ toJSON(github.event.issue.title) }};
|
|
issuebody = ${{ toJSON(github.event.issue.body) }};
|
|
|
|
iscustom = 'false'
|
|
|
|
MODEL = ''
|
|
PRODUCTVER = ''
|
|
ADDONS = ''
|
|
FORMAT = ''
|
|
try:
|
|
if issuetitle.lower().startswith('custom'):
|
|
jsonbody = json.loads(issuebody)
|
|
iscustom = 'true'
|
|
MODEL = jsonbody.get('model', '')
|
|
PRODUCTVER = jsonbody.get('version', '')
|
|
ADDONS = jsonbody.get('addons', '')
|
|
FORMAT = jsonbody.get('format', '')
|
|
except ValueError as e:
|
|
pass
|
|
|
|
set_output("iscustom", iscustom)
|
|
|
|
set_output("MODEL", MODEL)
|
|
set_output("PRODUCTVER", PRODUCTVER)
|
|
set_output("ADDONS", ADDONS)
|
|
set_output("FORMAT", FORMAT)
|
|
|
|
# calculates the version number and push
|
|
- name: Calculate Version
|
|
run: |
|
|
# Calculate Version
|
|
VERSION="`date +'%y.%-m.%-d'`-custom"
|
|
|
|
echo "Version: ${VERSION}"
|
|
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
|
|
|
if [ -n "${VERSION}" ]; then
|
|
# Modify Source File
|
|
echo "${VERSION}" >VERSION
|
|
echo "${VERSION}" >files/p1/ARC-VERSION
|
|
sed 's/^ARC_VERSION=.*/ARC_VERSION="'${VERSION}'"/' -i files/initrd/opt/arc/include/consts.sh
|
|
fi
|
|
|
|
- name: Update Comment Building
|
|
if: env.iscustom == 'true'
|
|
id: comment
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: 'create-comment'
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
body: |
|
|
Hi @${{ github.event.issue.user.login }}.
|
|
arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }} is being build and package and will be sent to your email later..
|
|
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
----
|
|
|
|
# Get extractor, LKM, Addons, Modules and Configs
|
|
- name: Get extractor, LKM, Addons, Extensions, Modules and Configs
|
|
run: |
|
|
. scripts/func.sh
|
|
|
|
getExtractor "files/p3/extractor"
|
|
getLKMs "files/p3/lkms"
|
|
getAddons "files/p3/addons"
|
|
getModules "files/p3/modules"
|
|
getConfigs "files/p3/configs"
|
|
getPatches "files/p3/patches"
|
|
|
|
echo "OK"
|
|
|
|
# Build incremental
|
|
- name: Build image
|
|
run: |
|
|
. scripts/func.sh
|
|
|
|
echo "Create Arc Image"
|
|
IMAGE_FILE="arc.img"
|
|
gzip -dc "files/initrd/opt/arc/grub.img.gz" >"${IMAGE_FILE}"
|
|
fdisk -l "${IMAGE_FILE}"
|
|
|
|
LOOPX=$(sudo losetup -f)
|
|
sudo losetup -P "${LOOPX}" "${IMAGE_FILE}"
|
|
|
|
echo "Mounting image file"
|
|
mkdir -p "/tmp/p1"
|
|
mkdir -p "/tmp/p3"
|
|
sudo mount ${LOOPX}p1 "/tmp/p1"
|
|
sudo mount ${LOOPX}p3 "/tmp/p3"
|
|
|
|
echo "Get Buildroot"
|
|
getBuildroot "2023.08.x" "br"
|
|
[ ! -f "br/bzImage-arc" ] || [ ! -f "br/initrd-arc" ] && return 1
|
|
|
|
echo "Repack initrd"
|
|
cp -f "br/bzImage-arc" "files/p3/bzImage-arc"
|
|
repackInitrd "br/initrd-arc" "files/initrd" "files/p3/initrd-arc"
|
|
|
|
echo "Set Custom Config"
|
|
sudo echo "model: ${{ env.MODEL }}" >"/tmp/p1/preset-config"
|
|
sudo echo "productver: ${{ env.PRODUCTVER }}" >>"/tmp/p1/preset-config"
|
|
sudo echo "addons:" >>"/tmp/p1/preset-config"
|
|
for ADDON in ${{ env.ADDONS }}; do
|
|
sudo echo "addons.${ADDON}" >>"/tmp/p1/preset-config"
|
|
done
|
|
sudo echo "${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}" >"/tmp/p3/.automated"
|
|
echo "Copying files"
|
|
sudo cp -Rf "files/p1/"* "/tmp/p1"
|
|
sudo cp -Rf "files/p3/"* "/tmp/p3"
|
|
sudo cp -f "files/p1/preset-config" "/tmp/p1/preset-config"
|
|
sync
|
|
|
|
echo "Unmount image file"
|
|
sudo umount "/tmp/p1"
|
|
sudo umount "/tmp/p3"
|
|
rmdir "/tmp/p1"
|
|
rmdir "/tmp/p3"
|
|
|
|
sudo losetup --detach ${LOOPX}
|
|
|
|
if [ "${{ env.FORMAT }}" = "dyn" ]; then
|
|
echo "Image Converter -> dyn"
|
|
qemu-img convert -O vmdk arc.img arc-dyn.vmdk
|
|
elif [ "${{ env.FORMAT }}" = "flat" ]; then
|
|
echo "Image Converter -> flat"
|
|
qemu-img convert -O vmdk -o adapter_type=lsilogic arc.img -o subformat=monolithicFlat arc.vmdk
|
|
fi
|
|
|
|
# Zip image and generate checksum
|
|
- name: Pack
|
|
run: |
|
|
if [ "${{ env.FORMAT }}" = "img" ]; then
|
|
zip -9 "arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}.img.zip" arc.img
|
|
UPLOAD="$(curl -k -F "file=@arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}.img.zip" "https://file.io")"
|
|
if ! echo "${UPLOAD}" | grep -oP '"link":\s*"\K[^"]+'; then
|
|
echo "Upload failed"
|
|
exit 1
|
|
fi
|
|
elif [ "${{ env.FORMAT }}" = "dyn" ]; then
|
|
zip -9 "arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}.vmdk-dyn.zip" arc-dyn.vmdk
|
|
UPLOAD="$(curl -k -F "file=@arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}.vmdk-dyn.zip" "https://file.io")"
|
|
if ! echo "${UPLOAD}" | grep -oP '"link":\s*"\K[^"]+'; then
|
|
echo "Upload failed"
|
|
exit 1
|
|
fi
|
|
elif [ "${{ env.FORMAT }}" = "flat" ]; then
|
|
zip -9 "arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}.vmdk-flat.zip" arc.vmdk arc-flat.vmdk
|
|
UPLOAD="$(curl -k -F "file=@arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}.vmdk-flat.zip" "https://file.io")"
|
|
if ! echo "${UPLOAD}" | grep -oP '"link":\s*"\K[^"]+'; then
|
|
echo "Upload failed"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
EMAIL=$(curl -s -H "Authorization: token ${{ secrets.ACTION }}" "https://api.github.com/users/${{ github.event.issue.user.login }}" | jq -r '.email')
|
|
FIOURL="$(echo "${UPLOAD}" | grep -oP '"link":\s*"\K[^"]+')"
|
|
echo "EMAIL=${EMAIL}" >> $GITHUB_ENV
|
|
echo "FIOURL=${FIOURL}" >> $GITHUB_ENV
|
|
|
|
- name: Send mail
|
|
if: env.iscustom == 'true' && success() && env.EMAIL != 'null'
|
|
uses: dawidd6/action-send-mail@v3
|
|
with:
|
|
server_address: smtp.gmail.com
|
|
server_port: 587
|
|
username: ${{ secrets.MAIL_USERNAME }}
|
|
password: ${{ secrets.MAIL_PASSWORD }}
|
|
subject: arc-${{ env.model }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}
|
|
to: ${{ env.EMAIL }}
|
|
from: ${{ secrets.MAIL_USERNAME }}
|
|
body: |
|
|
${{ env.TTDLURL }}
|
|
|
|
- name: Update Comment Success
|
|
if: env.iscustom == 'true' && success() && env.EMAIL != 'null'
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: 'update-comment'
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
comment-id: ${{ steps.comment.outputs.comment-id }}
|
|
update-mode: replace
|
|
body: |
|
|
Hi @${{ github.event.issue.user.login }}.
|
|
arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }} has been sent to your email.
|
|
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
----
|
|
|
|
- name: Update Comment Success
|
|
if: env.iscustom == 'true' && success() && env.EMAIL == 'null'
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: 'update-comment'
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
comment-id: ${{ steps.comment.outputs.comment-id }}
|
|
update-mode: replace
|
|
body: |
|
|
Hi @${{ github.event.issue.user.login }}.
|
|
${{ env.FIOURL }}
|
|
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
----
|
|
|
|
- name: Close Issues
|
|
if: env.iscustom == 'true' && success()
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: 'close-issue'
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
|
|
- name: Update Comment Fail
|
|
if: env.iscustom == 'true' && failure()
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: 'update-comment'
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
comment-id: ${{ steps.comment.outputs.comment-id }}
|
|
update-mode: replace
|
|
body: |
|
|
Hi @${{ github.event.issue.user.login }}.
|
|
arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }} failed to build and package, please try again.
|
|
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
---- |