Simplify APK updates and harden R2 cache headers
This commit is contained in:
@@ -20,6 +20,9 @@ Required env:
|
||||
Optional env:
|
||||
R2_PUBLIC_BASE_URL (example: https://downloads.dewemoji.com)
|
||||
DEWEMOJI_APK_URL (default: https://dewemoji.com/downloads/dewemoji-latest.apk)
|
||||
APK_VERSIONED_CACHE_CONTROL (default: public,max-age=31536000,immutable)
|
||||
APK_LATEST_CACHE_CONTROL (default: no-store,max-age=0,must-revalidate)
|
||||
APK_VERSION_JSON_CACHE_CONTROL (default: no-store,max-age=0,must-revalidate)
|
||||
USAGE
|
||||
}
|
||||
|
||||
@@ -82,6 +85,9 @@ latest_key="apk/dewemoji-latest.apk"
|
||||
version_json_key="apk/version.json"
|
||||
|
||||
apk_url="${DEWEMOJI_APK_URL:-https://dewemoji.com/downloads/dewemoji-latest.apk}"
|
||||
versioned_cache_control="${APK_VERSIONED_CACHE_CONTROL:-public,max-age=31536000,immutable}"
|
||||
latest_cache_control="${APK_LATEST_CACHE_CONTROL:-no-store,max-age=0,must-revalidate}"
|
||||
version_json_cache_control="${APK_VERSION_JSON_CACHE_CONTROL:-no-store,max-age=0,must-revalidate}"
|
||||
version_json_path="${tmp_dir}/version.json"
|
||||
"${MAKE_VERSION_SCRIPT}" \
|
||||
--version-name "${version_name}" \
|
||||
@@ -94,13 +100,19 @@ version_json_path="${tmp_dir}/version.json"
|
||||
--out "${version_json_path}"
|
||||
|
||||
echo "== Upload versioned APK =="
|
||||
aws --endpoint-url "${endpoint}" s3 cp "${apk}" "s3://${R2_BUCKET}/${versioned_key}" --content-type application/vnd.android.package-archive
|
||||
aws --endpoint-url "${endpoint}" s3 cp "${apk}" "s3://${R2_BUCKET}/${versioned_key}" \
|
||||
--content-type application/vnd.android.package-archive \
|
||||
--cache-control "${versioned_cache_control}"
|
||||
|
||||
echo "== Upload latest APK alias =="
|
||||
aws --endpoint-url "${endpoint}" s3 cp "${apk}" "s3://${R2_BUCKET}/${latest_key}" --content-type application/vnd.android.package-archive
|
||||
aws --endpoint-url "${endpoint}" s3 cp "${apk}" "s3://${R2_BUCKET}/${latest_key}" \
|
||||
--content-type application/vnd.android.package-archive \
|
||||
--cache-control "${latest_cache_control}"
|
||||
|
||||
echo "== Upload version metadata =="
|
||||
aws --endpoint-url "${endpoint}" s3 cp "${version_json_path}" "s3://${R2_BUCKET}/${version_json_key}" --content-type application/json --cache-control no-store
|
||||
aws --endpoint-url "${endpoint}" s3 cp "${version_json_path}" "s3://${R2_BUCKET}/${version_json_key}" \
|
||||
--content-type application/json \
|
||||
--cache-control "${version_json_cache_control}"
|
||||
|
||||
echo "Published to R2 bucket: ${R2_BUCKET}"
|
||||
echo "Versioned APK key: ${versioned_key}"
|
||||
|
||||
Reference in New Issue
Block a user