image: ubuntu:20.04

build:
  stage: build
  script:
    - apt update
    - apt install android-tools-mkbootimg bc build-essential ca-certificates curl git kmod libssl-dev libtinfo5 python2 sudo unzip wget xz-utils -y --no-install-recommends
    - ln -sf python2.7 /usr/bin/python
    - ./build.sh
  artifacts:
    paths:
      - out/*

flashable:
  stage: deploy
  script:
    - apt update
    - apt install -y img2simg jq sudo wget xz-utils
    - DEVICE="$(source deviceinfo && echo $deviceinfo_codename)"
    - ./build/fetch-and-prepare-latest-ota.sh "16.04/arm64/android9/devel" "$DEVICE" ota
    - mkdir -p out
    - ./build/system-image-from-ota.sh ota/ubuntu_command out
  artifacts:
    paths:
      - out/boot.img
      - out/system.img
  when: manual

devel-flashable:
  stage: deploy
  script:
    - apt update
    - apt install -y img2simg jq sudo wget xz-utils
    - DEVICE="$(source deviceinfo && echo $deviceinfo_codename)"
    - ./build/prepare-fake-ota.sh out/device_$DEVICE.tar.xz ota
    - mkdir -p out
    - ./build/system-image-from-ota.sh ota/ubuntu_command out
  artifacts:
    paths:
      - out/boot.img
      - out/system.img
