refactor: move app-release-template to monorepo

This commit is contained in:
2023-03-14 17:26:49 +01:00
parent fdf7999437
commit 4f91f46af6
28 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env sh
. $PWD/app.conf
DEFAULT_APP_URL_SCHEME="de.anyschool.app"
APP_URL_SCHEME="${APP_URL_SCHEME:-$DEFAULT_APP_URL_SCHEME}"
ANDROID_MANIFEST_PATH="app/android/app/src/main/AndroidManifest.xml"
ANDROID_STRINGS_PATH="app/android/app/src/main/res/values/strings.xml"
git -C app checkout -- android/build.gradle
git -C app checkout -- android/gradle/wrapper/gradle-wrapper.properties
git -C app checkout -- android/app/src/main/AndroidManifest.xml
git -C app checkout -- android/app/src/main/res/values/styles.xml
# AndroidManifest.xml
xmlstarlet edit --pf --inplace \
--update "/manifest/@package" --value "$ANDROID_PACKAGE_NAME" \
$ANDROID_MANIFEST_PATH
xmlstarlet edit --pf --inplace \
--update "/manifest/application/activity/@android:name" --value "$ANDROID_PACKAGE_NAME".MainActivity \
$ANDROID_MANIFEST_PATH
# strings.xml
xmlstarlet edit --pf --inplace \
--update "/resources/string[@name='package_name']" --value "$ANDROID_PACKAGE_NAME" \
$ANDROID_STRINGS_PATH
xmlstarlet edit --pf --inplace \
--update "/resources/string[@name='custom_url_scheme']" --value "$APP_URL_SCHEME" \
$ANDROID_STRINGS_PATH
xmlstarlet edit --inplace \
--delete "/resources/string[@name='app_host']" \
--append "/resources/string[@name='custom_url_scheme']" --type elem -n string --value "$APP_LINK_HOST" \
--insert "/resources/string[not(@name)]" --type attr -n name --value "app_host" \
$ANDROID_STRINGS_PATH

View File

@@ -0,0 +1,18 @@
#!/usr/bin/env sh
# get semantical versioning string linke 2.0.0 (if $1 is v2.0.0) or $1
DEFAULT_VERSION="0.0.0"
APP_VERSION="${APP_VERSION:-$DEFAULT_VERSION}"
if echo -n $1 | grep -Eq 'v[0-9]+\.[0-9]+\.[0-9]+'; then
APP_VERSION=$(echo -n "$1" | cut -c 2-);
else
APP_VERSION=$1;
fi
if [ "$APP_VERSION" = "0.0.0" ]; then
echo "Unsupported app version was set!"
return 1
fi
git clone --depth 1 --branch $APP_VERSION https://gitlab.com/openstapps/app.git app

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env sh
. $PWD/app.conf
DEFAULT_APP_ID="de.anyschool.app"
DEFAULT_CONFIG_MODE="WEB"
APP_ID="${APP_ID:-$DEFAULT_APP_ID}"
APP_VERSION=$(jq '.version' app/package.json)
CONFIG_MODE="${CONFIG_MODE:-$DEFAULT_CONFIG_MODE}"
if [ "$CONFIG_MODE" = 'ANDROID' ]; then
APP_ID="$ANDROID_PACKAGE_NAME"
fi
if [ "$CONFIG_MODE" = 'IOS' ]; then
APP_ID="$IOS_BUNDLE_IDENTIFIER"
fi
# ionic config
cat app/ionic.config.json | jq '.name = $newName' --arg newName "$APP_NAME" > tmp.$$.json && mv tmp.$$.json app/ionic.config.json
sed -i -e 's@<title>StApps<\/title>@<title>'"$APP_DISPLAY_NAME"'<\/title>@g' app/src/index.html
ROOT_THEME_DEFINITONS=$(cat app/src/theme/variables.scss | grep -o :root | wc -l)
if [ $ROOT_THEME_DEFINITONS -gt 1 ]; then
#update
echo "SCSS theme has already been set"
else
#insert
cat customizable/theme/variables.scss >> app/src/theme/variables.scss
fi
# capacitor config
awk "/appName:.*,/ && !done { gsub(/appName:.*,/, \"appName: '$APP_NAME',\"); done=1}; 1" app/capacitor.config.ts > tmp.$$.json && mv tmp.$$.json app/capacitor.config.ts
awk "/appId:.*,/ && !done { gsub(/appId:.*,/, \"appId: '$APP_ID',\"); done=1}; 1" app/capacitor.config.ts > tmp.$$.json && mv tmp.$$.json app/capacitor.config.ts
# cordova config
xmlstarlet edit -L --update "/widget/@id" --value "$APP_ID" app/config.xml
xmlstarlet edit -L --update "/widget/@version" --value "$APP_VERSION" app/config.xml
xmlstarlet edit -L -N x="http://www.w3.org/ns/widgets" --update "//x:name" --value "$APP_NAME" app/config.xml
SHORT_EXISTS=$(xmlstarlet sel -N x='http://www.w3.org/ns/widgets' -T -t -v '//x:name[@short]' app/config.xml)
if [ -z "${SHORT_EXISTS:-}" ]; then
#insert
xmlstarlet edit -L -N x="http://www.w3.org/ns/widgets" -s "//x:name" -t attr -n "short" -v "$APP_DISPLAY_NAME" app/config.xml
else
#update
xmlstarlet edit -L -N x="http://www.w3.org/ns/widgets" --update "//x:name[@short]" -v "$APP_DISPLAY_NAME" app/config.xml
fi
# environment config
awk "/backend_url:.*,/ && !done { gsub(/backend_url:.*,/, \"backend_url: '$BACKEND_URL',\"); done=1}; 1" app/src/environments/environment.production.ts > tmp.$$.json && mv tmp.$$.json app/src/environments/environment.production.ts
awk "/backend_version:.*,/ && !done { gsub(/backend_version:.*,/, \"backend_version: '$BACKEND_VERSION',\"); done=1}; 1" app/src/environments/environment.production.ts > tmp.$$.json && mv tmp.$$.json app/src/environments/environment.production.ts
awk "/app_host:.*,/ && !done { gsub(/app_host:.*,/, \"app_host: '$APP_LINK_HOST',\"); done=1}; 1" app/src/environments/environment.production.ts > tmp.$$.json && mv tmp.$$.json app/src/environments/environment.production.ts
awk "/custom_url_scheme:.*,/ && !done { gsub(/custom_url_scheme:.*,/, \"custom_url_scheme: '$APP_URL_SCHEME',\"); done=1}; 1" app/src/environments/environment.production.ts > tmp.$$.json && mv tmp.$$.json app/src/environments/environment.production.ts

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env sh
. $PWD/app.conf
ENTITLEMENTS_FILE="app/ios/App/App/App.entitlements"
INFOPLIST_FILE="app/ios/App/App/Info.plist"
/usr/libexec/PlistBuddy -c "Delete :com.apple.developer.associated-domains string applinks:$APP_LINK_HOST" $ENTITLEMENTS_FILE
/usr/libexec/PlistBuddy -c "Add :com.apple.developer.associated-domains array" $ENTITLEMENTS_FILE
/usr/libexec/PlistBuddy -c "Add :com.apple.developer.associated-domains:0 string applinks:$APP_LINK_HOST" $ENTITLEMENTS_FILE
/usr/libexec/PlistBuddy -c "Delete :BGTaskSchedulerPermittedIdentifiers string com.transistorsoft.fetch" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :BGTaskSchedulerPermittedIdentifiers array" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :BGTaskSchedulerPermittedIdentifiers:0 string com.transistorsoft.fetch" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Delete :UISupportedInterfaceOrientations~iphone array" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Delete :UISupportedInterfaceOrientations array" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :UISupportedInterfaceOrientations array" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :UISupportedInterfaceOrientations:0 string \"UIInterfaceOrientationPortrait\"" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Delete :UISupportedInterfaceOrientations~ipad array" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :UISupportedInterfaceOrientations~ipad array" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :UISupportedInterfaceOrientations~ipad:0 string \"UIInterfaceOrientationPortrait\"" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :UISupportedInterfaceOrientations~ipad:1 string \"UIInterfaceOrientationPortraitUpsideDown\"" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :UISupportedInterfaceOrientations~ipad:2 string \"UIInterfaceOrientationLandscapeLeft\"" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :UISupportedInterfaceOrientations~ipad:3 string \"UIInterfaceOrientationLandscapeRight\"" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Delete :UIViewControllerBasedStatusBarAppearance bool" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :UIViewControllerBasedStatusBarAppearance bool" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Set :UIViewControllerBasedStatusBarAppearance NO" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Delete :UIStatusBarStyle string" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Add :UIStatusBarStyle string" $INFOPLIST_FILE
/usr/libexec/PlistBuddy -c "Set :UIStatusBarStyle UIStatusBarStyleLightContent" $INFOPLIST_FILE
git -C app checkout -- ios/App/App/AppDelegate.swift

View File

@@ -0,0 +1,70 @@
#!/usr/bin/env sh
set -e
SSH_DEPLOY_TARGET=$2
SSH_DEPLOY_TARGET="${SSH_DEPLOY_TARGET:-"missingtarget"}"
SSH_PRIVATE_KEY=$3
SSH_PRIVATE_KEY="${SSH_PRIVATE_KEY:-"missingkey"}"
GOTO_FAIL=false
if [ "$SSH_DEPLOY_TARGET" = "missingtarget" ]; then
echo "SSH target for web deployment job is unset!"
GOTO_FAIL=true
fi
if [ "$SSH_PRIVATE_KEY" = "missingkey" ]; then
echo "SSH key for web deployment job is unset!"
GOTO_FAIL=true
fi
if [ "$GOTO_FAIL" = true ]; then
return 1
fi
TARGET_COMPONENTS=$(echo "$SSH_DEPLOY_TARGET" | tr '@' "\n")
TARGET_COMPONENTS=$(echo "$TARGET_COMPONENTS" | tr ':' "\n")
SSH_DEPLOY_TARGET_USER=$(echo "$TARGET_COMPONENTS" | head -n 1 | tail -n 1)
SSH_DEPLOY_TARGET_HOST=$(echo "$TARGET_COMPONENTS" | head -n 2 | tail -n 1)
SSH_DEPLOY_TARGET_PATH=$(echo "$TARGET_COMPONENTS" | head -n 3 | tail -n 1)
SSH_DEPLOY_TARGET_USER="${SSH_DEPLOY_TARGET_USER:-"missinguser"}"
SSH_DEPLOY_TARGET_HOST="${SSH_DEPLOY_TARGET_HOST:-"missinghost"}"
SSH_DEPLOY_TARGET_PATH="${SSH_DEPLOY_TARGET_PATH:-"missingpath"}"
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
mkdir -p ~/.ssh
chmod 700 ~/.ssh
eval `ssh-agent -s`
echo "$SSH_PRIVATE_KEY" | base64 -d | tr -d '\r' | ssh-add -
## Use ssh-keyscan to scan the keys of your private server.
## You can copy and repeat that command if you have more than
## one server to connect to.
ssh-keyscan $SSH_DEPLOY_TARGET_HOST >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
web() {
scp www.zip "$SSH_DEPLOY_TARGET"
ssh "$SSH_DEPLOY_TARGET_USER@$SSH_DEPLOY_TARGET_HOST" "cd $SSH_DEPLOY_TARGET_PATH && unzip -o www.zip && rm -f www.zip"
}
apk() {
scp app/android/app/build/outputs/apk/release/app-release.apk "$SSH_DEPLOY_TARGET"
}
if declare -f "$1" > /dev/null
then
"$@"
else
echo "'$1' is not a known function name"
exit 1
fi

View File

@@ -0,0 +1,58 @@
#!/usr/bin/env sh
. $PWD/app.conf
# iOS universal link file generation
if [ -z "$TEAM_ID" ] && [ -z "$IOS_BUNDLE_IDENTIFIER" ]
then
echo "Unable to find Apple Team ID and bundle identifier. Skipping apple-app-site-association generation..."
else
file_content=$(cat <<EOF
{
"applinks": {
"details": [
{
"appIDs": [ "${TEAM_ID}.${IOS_BUNDLE_IDENTIFIER}"],
"components": [
{
"/": "/*",
"comment": "Match all links"
}
]
}
]
}
}
EOF
)
echo $file_content > $PWD/app/www/.well-known/apple-app-site-association
fi
# Google Play/Android universal link file generation
KEYTOOL_INFO=$(keytool -list -v -keystore ./playstore.keystore -alias $ANDROID_KEYSTORE_KEY_ALIAS -storepass $ANDROID_KEYSTORE_PASSWORD -keypass $ANDROID_KEYSTORE_KEY_PASSWORD || true)
CERT_FINGERPRINT=$(echo $KEYTOOL_INFO | grep -Po '(?:[a-fA-F0-9]{2}:){31}[a-fA-F0-9]{2}')
if [ -z "$CERT_FINGERPRINT" ]
then
echo "Unable to retrieve Android sigining SHA256 fingerprint. Skipping assetlinks.json generation..."
else
file_content=$(cat <<EOF
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "${ANDROID_PACKAGE_NAME}",
"sha256_cert_fingerprints": [
"${CERT_FINGERPRINT}"
]
}
}
]
EOF
)
echo $file_content > $PWD/app/www/.well-known/assetlinks.json
fi