#!/bin/bash

# This script outputs an artifact_manifest.yaml mapping 
# a shorebird engine revision to a flutter engine revision.
# Usage:
#  ./generate_manifest.sh <flutter_engine_revision> > artifact_manifest.yaml

set -e

if [ "$#" -ne 1 ]; then
  echo "Usage: ./generate_manifest.sh <flutter_engine_revision>"
  exit 1
fi

FLUTTER_ENGINE_REVISION=$1

cat <<EOF
# This file is generated by shorebird/packages/artifact_proxy/tool/generate_manifest.sh
# Do not edit this file manually.

flutter_engine_revision: $FLUTTER_ENGINE_REVISION
storage_bucket: download.shorebird.dev
artifact_overrides:
  # artifacts.zip
  - flutter_infra_release/flutter/\$engine/android-arm-64-release/artifacts.zip
  - flutter_infra_release/flutter/\$engine/android-arm-release/artifacts.zip
  - flutter_infra_release/flutter/\$engine/android-x64-release/artifacts.zip
  - flutter_infra_release/flutter/\$engine/ios-release/artifacts.zip
  # embedding release
  - download.flutter.io/io/flutter/flutter_embedding_release/1.0.0-\$engine/flutter_embedding_release-1.0.0-\$engine.pom
  - download.flutter.io/io/flutter/flutter_embedding_release/1.0.0-\$engine/flutter_embedding_release-1.0.0-\$engine.jar
  # arm64_v8a release
  - download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-\$engine/arm64_v8a_release-1.0.0-\$engine.pom
  - download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-\$engine/arm64_v8a_release-1.0.0-\$engine.jar
  # armeabi_v7a release
  - download.flutter.io/io/flutter/armeabi_v7a_release/1.0.0-\$engine/armeabi_v7a_release-1.0.0-\$engine.pom
  - download.flutter.io/io/flutter/armeabi_v7a_release/1.0.0-\$engine/armeabi_v7a_release-1.0.0-\$engine.jar
  # x86_64 release
  - download.flutter.io/io/flutter/x86_64_release/1.0.0-\$engine/x86_64_release-1.0.0-\$engine.pom
  - download.flutter.io/io/flutter/x86_64_release/1.0.0-\$engine/x86_64_release-1.0.0-\$engine.jar
