Use GitHub Action for deploying repo

This commit is contained in:
arkon
2020-11-12 19:22:02 -05:00
parent b2eb532944
commit 303d3e3633
10 changed files with 139 additions and 110 deletions

14
.github/scripts/commit-repo.sh vendored Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -e
rsync -a --delete --exclude .git --exclude .gitignore ../master/repo/ .
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git status
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Update extensions repo"
git push
else
echo "No changes to commit"
fi

48
.github/scripts/create-repo.sh vendored Executable file
View File

@ -0,0 +1,48 @@
#!/bin/bash
set -e
TOOLS="$(ls -d ${ANDROID_HOME}/build-tools/* | tail -1)"
mkdir -p repo/apk
mkdir -p repo/icon
cp -f apk/* repo/apk
cd repo
APKS=( ../apk/*".apk" )
for APK in ${APKS[@]}; do
FILENAME=$(basename ${APK})
BADGING="$(${TOOLS}/aapt dump --include-meta-data badging $APK)"
PACKAGE=$(echo "$BADGING" | grep package:)
PKGNAME=$(echo $PACKAGE | grep -Po "package: name='\K[^']+")
VCODE=$(echo $PACKAGE | grep -Po "versionCode='\K[^']+")
VNAME=$(echo $PACKAGE | grep -Po "versionName='\K[^']+")
NSFW=$(echo $BADGING | grep -Po "tachiyomi.extension.nsfw' value='\K[^']+")
APPLICATION=$(echo "$BADGING" | grep application:)
LABEL=$(echo $APPLICATION | grep -Po "label='\K[^']+")
LANG=$(echo $APK | grep -Po "tachiyomi-\K[^\.]+")
ICON=$(echo "$BADGING" | grep -Po "application-icon-320.*'\K[^']+")
unzip -p $APK $ICON > icon/${FILENAME%.*}.png
jq -n \
--arg name "$LABEL" \
--arg pkg "$PKGNAME" \
--arg apk "$FILENAME" \
--arg lang "$LANG" \
--argjson code $VCODE \
--arg version "$VNAME" \
--argjson nsfw $NSFW \
'{name:$name, pkg:$pkg, apk:$apk, lang:$lang, code:$code, version:$version, nsfw:$nsfw}'
done | jq -sr '[.[]]' > index.json
# Alternate gzipped copy
gzip -c index.json > index.json.gz
cat index.json

35
.github/scripts/sign-apks.sh vendored Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
set -e
TOOLS="$(ls -d ${ANDROID_HOME}/build-tools/* | tail -1)"
shopt -s globstar nullglob extglob
APKS=( **/*".apk" )
# Take base64 encoded key input and put it into a file
STORE_PATH=$PWD/signingkey.jks
rm -f $STORE_PATH && touch $STORE_PATH
echo $1 | base64 -d > $STORE_PATH
STORE_ALIAS=$2
export KEY_STORE_PASSWORD=$3
export KEY_PASSWORD=$4
DEST=$PWD/apk
rm -rf $DEST && mkdir -p $DEST
# Sign all of the APKs
for APK in ${APKS[@]}; do
BASENAME=$(basename $APK)
APKNAME="${BASENAME%%+(-release*)}.apk"
APKDEST="$DEST/$APKNAME"
${TOOLS}/zipalign -c -v -p 4 $APK
cp $APK $APKDEST
${TOOLS}/apksigner sign --ks $STORE_PATH --ks-key-alias $STORE_ALIAS --ks-pass env:KEY_STORE_PASSWORD --key-pass env:KEY_PASSWORD $APKDEST
done
rm $STORE_PATH
unset KEY_STORE_PASSWORD
unset KEY_PASSWORD