mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Changed over deploy location to Cloudflare R2.
This commit is contained in:
+45
-32
@@ -1,48 +1,61 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
DOCUMENT_ROOT=/var/www/html
|
||||
MAINT_FILE="$DOCUMENT_ROOT/maintenance.file"
|
||||
R2_ENDPOINT="https://$CF_R2_ACCOUNT_ID.r2.cloudflarestorage.com"
|
||||
|
||||
cleanup() {
|
||||
rm -f "$MAINT_FILE"
|
||||
r2_cp() {
|
||||
src="$1"
|
||||
key="$2"
|
||||
cache_control="$3"
|
||||
content_type="$4"
|
||||
|
||||
AWS_ACCESS_KEY_ID="$CF_R2_ACCESS_KEY_ID" \
|
||||
AWS_SECRET_ACCESS_KEY="$CF_R2_SECRET_ACCESS_KEY" \
|
||||
AWS_DEFAULT_REGION=auto \
|
||||
aws s3 cp "$src" "s3://$CF_R2_BUCKET/$key" \
|
||||
--endpoint-url "$R2_ENDPOINT" \
|
||||
--only-show-errors \
|
||||
--cache-control "$cache_control" \
|
||||
--content-type "$content_type"
|
||||
}
|
||||
|
||||
upload_apk_latest_and_versioned() {
|
||||
src="$1"
|
||||
filename="$2"
|
||||
|
||||
r2_cp "$src" "$VERSION/$filename" \
|
||||
"public, max-age=31536000, immutable" \
|
||||
"application/vnd.android.package-archive"
|
||||
|
||||
r2_cp "$src" "$filename" \
|
||||
"no-store" \
|
||||
"application/vnd.android.package-archive"
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
# Sign sources
|
||||
echo "Signing all sources..."
|
||||
/usr/bin/bash ./sign-all-sources.sh
|
||||
|
||||
# Build content
|
||||
echo "Building content..."
|
||||
./gradlew --stacktrace assembleUnstableRelease
|
||||
|
||||
# Take site offline
|
||||
echo "Taking site offline..."
|
||||
touch "$MAINT_FILE"
|
||||
|
||||
# Swap over the content
|
||||
echo "Deploying content..."
|
||||
cp ./app/build/outputs/apk/unstable/release/app-unstable-x86_64-release.apk "$DOCUMENT_ROOT/app-x86_64-release-unstable.apk"
|
||||
cp ./app/build/outputs/apk/unstable/release/app-unstable-arm64-v8a-release.apk "$DOCUMENT_ROOT/app-arm64-v8a-release-unstable.apk"
|
||||
cp ./app/build/outputs/apk/unstable/release/app-unstable-armeabi-v7a-release.apk "$DOCUMENT_ROOT/app-armeabi-v7a-release-unstable.apk"
|
||||
cp ./app/build/outputs/apk/unstable/release/app-unstable-universal-release.apk "$DOCUMENT_ROOT/app-universal-release-unstable.apk"
|
||||
cp ./app/build/outputs/apk/unstable/release/app-unstable-x86-release.apk "$DOCUMENT_ROOT/app-x86-release-unstable.apk"
|
||||
cp ./app/build/outputs/apk/unstable/release/app-unstable-arm64-v8a-release.apk "$DOCUMENT_ROOT/app-release-unstable.apk"
|
||||
|
||||
VERSION="$(git describe --tags)"
|
||||
echo "$VERSION" > "$DOCUMENT_ROOT/version-unstable.txt"
|
||||
|
||||
# Notify Cloudflare to wipe the CDN cache
|
||||
echo "Purging Cloudflare cache for zone $CLOUDFLARE_ZONE_ID..."
|
||||
curl -X POST "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache" \
|
||||
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"files":["https://releases.grayjay.app/app-x86_64-release-unstable.apk", "https://releases.grayjay.app/app-arm64-v8a-release-unstable.apk", "https://releases.grayjay.app/app-armeabi-v7a-release-unstable.apk", "https://releases.grayjay.app/app-universal-release-unstable.apk", "https://releases.grayjay.app/app-x86-release-unstable.apk", "https://releases.grayjay.app/app-release-unstable.apk", "https://releases.grayjay.app/version-unstable.txt"]}'
|
||||
echo "Deploying unstable artifacts to Cloudflare R2..."
|
||||
upload_apk_latest_and_versioned "./app/build/outputs/apk/unstable/release/app-unstable-x86_64-release.apk" "app-x86_64-release-unstable.apk"
|
||||
upload_apk_latest_and_versioned "./app/build/outputs/apk/unstable/release/app-unstable-arm64-v8a-release.apk" "app-arm64-v8a-release-unstable.apk"
|
||||
upload_apk_latest_and_versioned "./app/build/outputs/apk/unstable/release/app-unstable-armeabi-v7a-release.apk" "app-armeabi-v7a-release-unstable.apk"
|
||||
upload_apk_latest_and_versioned "./app/build/outputs/apk/unstable/release/app-unstable-universal-release.apk" "app-universal-release-unstable.apk"
|
||||
upload_apk_latest_and_versioned "./app/build/outputs/apk/unstable/release/app-unstable-x86-release.apk" "app-x86-release-unstable.apk"
|
||||
upload_apk_latest_and_versioned "./app/build/outputs/apk/unstable/release/app-unstable-arm64-v8a-release.apk" "app-release-unstable.apk"
|
||||
|
||||
sleep 30
|
||||
tmp_version="$(mktemp)"
|
||||
printf '%s\n' "$VERSION" > "$tmp_version"
|
||||
r2_cp "$tmp_version" "$VERSION/version-unstable.txt" \
|
||||
"public, max-age=31536000, immutable" \
|
||||
"text/plain; charset=utf-8"
|
||||
r2_cp "$tmp_version" "version-unstable.txt" \
|
||||
"no-store" \
|
||||
"text/plain; charset=utf-8"
|
||||
rm -f "$tmp_version"
|
||||
|
||||
# Take site back online
|
||||
echo "Bringing site back online..."
|
||||
rm -f "$MAINT_FILE"
|
||||
trap - EXIT INT TERM
|
||||
echo "Done."
|
||||
Reference in New Issue
Block a user