Skip to content

Commit

Permalink
.github: add updaterelease workflow and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
asac committed Aug 17, 2024
1 parent bc4432b commit 3c769cf
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 1 deletion.
104 changes: 104 additions & 0 deletions .github/scripts/makecommit
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/sh

git add .github/configs/release/
set -x

changed=`git diff HEAD | lsdiff | sed 's/.\///'`

if [ -z "$changed" ]; then
echo "NO changes"
exit 0
fi

echo "Changes: $changed"

gitdirs=$PWD/.github/git-dirs/
mkdir -p $gitdirs

commitmsg=`mktemp -t commitmsg.XXXXXXX`

echo "" > $commitmsg

echo_cm(){
echo "$@" >> $commitmsg
}

for change in $changed; do
original=$change.orig
git diff HEAD -- $change | patch -f -R -p1 -s -o $original
removed=
if [ -f $change ]; then
repos=`cat $change | yq ".repos | keys()[]"`
else
repos=`cat $original | yq ".repos | keys()[]"`
removed=yes
fi

change_listed=

for repo in $repos; do
repourl=null
repocommit=null
if [ -f $change ]; then
repourl=`cat $change | yq ".repos.$repo.url"`
repocommit=`cat $change | yq ".repos.$repo.commit"`
fi
repourlorig=null
repocommitorig=null
if [ -f $original ]; then
repourlorig=`cat $original | yq ".repos.$repo.url"`
repocommitorig=`cat $original | yq ".repos.$repo.commit"`
fi

if [ -n "$repocommit" -a "$repocommit" = "$repocommitorig" ]; then
echo "$change/$repo: no change"
continue
fi
set -x
if [ -z "$change_listed" ]; then
echo_cm "== $change${removed:+ (REMOVED)}=="
change_listed=yes
echo_cm
fi
echo_cm " $repo:"
echo_cm

origdir=$PWD
export GIT_DIR=$gitdirs/$repo

if [ "$repocommitorig" = "null" ]; then
echo_cm " Adding repo $repo from $repourl"
echo_cm " commit $repocommit"
echo_cm
elif [ "$repocommit" = "null" ]; then
echo_cm " Removing repo $repo from $repourlorig"
echo_cm " commit $repocommitorig"
echo_cm
else
gittemp=`mktemp -t -d gittemp.XXXXXX`
echo_cm " Changed repo $repourlorig => $repourl"
echo_cm " commit $repocommitorig => $repocommit"
cd $gittemp
git init
git remote remove current
git remote remove orig
git remote add current $repourl
git remote add orig $repourlorig
git fetch --all -v
git log --oneline $repocommitorig..$repocommit | sed 's/^/ * /' >> $commitmsg
echo_cm
cd $origdir
rm -rf $gittemp
fi
unset GIT_DIR
done
done

echo "Commit msg:"
cat $commitmsg
set -x
pwd
git diff
git commit -a -F $commitmsg
rm -f $commitmsg

32 changes: 32 additions & 0 deletions .github/scripts/makemachines
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

targetdir=$1

m=`ls kas/machines/*`
configsuffix=:.github/configs/build-base-remix.yaml:.github/configs/shared-vols.yaml

configs=" \
kas/machines/sunxi-orange-pi-3lts.yaml:kas/bsp-base.yaml:kas/scarthgap.yaml$configsuffix \
kas/machines/sunxi-orange-pi-r1.yaml:kas/bsp-base.yaml:kas/scarthgap.yaml$configsuffix \
kas/machines/sunxi-nanopi-r1.yaml:kas/bsp-base.yaml:kas/scarthgap.yaml$configsuffix \
kas/machines/imx8qxpc0mek.yaml:kas/bsp-base.yaml:kas/scarthgap.yaml:kas/scarthgap-nxp.yaml$configsuffix \
kas/machines/raspberrypi-armv8.yaml:kas/bsp-base.yaml:kas/scarthgap.yaml$configsuffix \
"

echo "Processing configs:
$configs"

rm -f .github/configs/release/*-scarthgap.yaml

for cc in $configs; do
echo CC: $cc
m=`echo $cc | sed 's/.*machines.//;s/.yaml:.*//'`
KAS_WORK_DIR=. kas dump --resolve-refs "$cc" > .github/configs/release/$m-scarthgap.yaml
echo "new config for machine: $m"
cat .github/configs/release/$m-scarthgap.yaml
done

git add .github/configs/release/


2 changes: 1 addition & 1 deletion .github/workflows/buildkas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build-kas:
runs-on: ["self-hosted"]
container:
image: ghcr.io/pantacor/kas/kas:next-v2
image: ghcr.io/pantacor/kas/kas:next-v3
volumes:
- shared:/shared
options: --user root
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/onpush.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: 'Build On Push'

on:
push:
paths-ignore:
- '.github/scripts/**'
- '.github/workflows/updaterelease.yaml'

jobs:
remix-sunxi-orange-pi-3lts-remix-scarthgap:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/onschedule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Do things every 4 hours
on:
schedule:
- cron: "1 */4 * * *"

jobs:
update-release-machines:
uses: ./.github/workflows/updaterelease.yaml

28 changes: 28 additions & 0 deletions .github/workflows/updaterelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Update Release Machines'

on:
workflow_call:

push:
paths:
- .github/scripts/**
- .github/workflows/updaterelease.yaml

jobs:
updaterelease:
runs-on: ["self-hosted"]
container:
image: ghcr.io/pantacor/kas/kas:next-v3
volumes:
- shared:/shared
options: --user root
steps:
- uses: actions/checkout@v4
- run: ls .github/scripts
- run: pwd
- run: .github/scripts/makemachines
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "Pantavisor Meta Layer CI"
- run: .github/scripts/makecommit
- run: git push

0 comments on commit 3c769cf

Please sign in to comment.