Commit 6e975a1c authored by Aníbal Portero Hermida's avatar Aníbal Portero Hermida

Merge branch 'upload_aws_images' into 'master'

Upload aws images and metadata

See merge request !9
parents f59c06ec 3aae83f9
Pipeline #85971013 passed with stages
in 152 minutes and 22 seconds
stages:
- upgrade
- environment
- build
image: registry.gitlab.com/pantacor/ci/pantavisor-builder:AMD64
......@@ -16,11 +17,15 @@ variables:
upgrade:
stage: upgrade
script:
# download source code
- mkdir work; cd work
- repo init -u $CI_PROJECT_URL; repo sync -j10
# download manifest project
- git clone -b $CI_COMMIT_REF_NAME --single-branch $CI_PROJECT_URL
# create new manifest
- cp pv-manifest/release.xml pv-manifest/.release.xml
- repo manifest -r -o pv-manifest/release.xml
# push manifest to gitlab, exit if no manifest changes
- cd pv-manifest
- git config --global user.name "Aníbal Portero Hermida"
- git config --global user.email "[email protected]"
......@@ -28,127 +33,103 @@ upgrade:
- RELEASE_CHANGES=`repo diffmanifests --raw release.xml .release.xml`
- git commit -m "auto commit of release.xml for daily build" -m "$RELEASE_CHANGES" || exit 0
- git push http://anibalportero:${PERSONAL_ACCESS_TOKEN}@$CI_SERVER_HOST/$CI_PROJECT_PATH HEAD:$CI_COMMIT_REF_NAME
- cd ../..; mkdir out
- cp -r work/pv-manifest/release.xml out/release.xml
only:
- schedules
artifacts:
expire_in: 1 day
paths:
- out/release.xml
environment:
stage: environment
script:
# prepare pipeline metadata
- PVMANIFEST_VERSION=$(git describe --tags)
- PVR_VERSION=$(pvr -v)
- COMMIT_TIME=$(git show -s --format=%ci $CI_COMMIT_SHA)
- "jq -n --arg mv \"$PVMANIFEST_VERSION\" --arg gs \"$CI_COMMIT_SHA\" --arg ct \"$COMMIT_TIME\" --arg pv \"$PVR_VERSION\" '{pvmanifestversion: $mv, gitsha: $gs, committime: $ct, pvrversion: $pv}' > pipeline.json"
# upload pipeline metadata to aws
- if test -z "$CI_COMMIT_TAG" ; then PIPELINE_PATH="$CI_COMMIT_REF_NAME/latest/$CI_PIPELINE_ID"; else PIPELINE_PATH="$CI_COMMIT_REF_NAME/stable/$CI_COMMIT_TAG"; fi
- aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws s3 cp pipeline.json s3://pantavisor-ci/$PIPELINE_PATH/pipeline.json
only:
- pushes
- tags
.build:
stage: build
variables:
PH_DEVICE_IN: TO_BE_OVERRIDDEN
PH_DEVICE_OUT: TO_BE_OVERRIDDEN
ARCH: TO_BE_OVERRIDDEN
TARGET: TO_BE_OVERRIDDEN
DEPLOY: TO_BE_OVERRIDDEN
PH_DEVICE_LATEST: ""
PH_DEVICE_STABLE: ""
ARCH: ""
TARGET: ""
DEPLOY: ""
script:
- test -e out/release.xml || exit 0
# download source code
- mkdir work; cd work
- repo init -u $CI_PROJECT_URL -m release.xml; cp ../out/release.xml .repo/manifests/release.xml; repo sync -j10
- repo init -u $CI_PROJECT_URL -m release.xml; cp ../release.xml .repo/manifests/release.xml; repo sync -j10
# download device from pantahub
- TOKEN=`http --ignore-stdin POST https://api.pantahub.com/auth/login username=$PHUSER password=$PHPASS | jq -r .token`
- pvr -a $TOKEN clone --objects .pvr/objects $PH_DEVICE_IN device-checkout
- pvr -a $TOKEN clone --objects .pvr/objects $PH_DEVICE_LATEST device-checkout
# build bsp binaries
- PVR_MERGE_SRC=device-checkout/.pvr PV_BUILD_INTERACIVE=false ./build.docker.sh $ARCH
- test "$DEPLOY" = "false" && exit 0
# update bsp binaries
- cd device-checkout
- rm -rf *
- pvr get ../out/$TARGET/trail/final/trails/0/.pvr/
- pvr checkout
# update platforms
- "test -z \"$CI_COMMIT_TAG\" && pvr app ls | while read -r line; do [ -f $line/src.json ] && ( pvr app update $line; pvr app install $line ) || echo \"Skipping app without src.json $line\"; done"
- pvr add .
- pvr commit
# post device to pantahub
- if test -z "$CI_COMMIT_TAG" ; then PH_DEVICE_OUT=$PH_DEVICE_LATEST; elif test -n "$PH_DEVICE_STABLE"; then PH_DEVICE_OUT=$PH_DEVICE_STABLE; else DEPLOY="false"; fi
- TOKEN=`http --ignore-stdin POST https://api.pantahub.com/auth/login username=$PHUSER password=$PHPASS | jq -r .token`
- pvr -a $TOKEN post -m "$CI_COMMIT_SHORT_SHA" $PH_DEVICE_OUT
- test "$DEPLOY" = "false" || PANTAHUB_REVISION=$(pvr -a $TOKEN post -m `git describe --tags` $PH_DEVICE_OUT | grep Revision | sed -e 's/.*Revision \(.*\) (.*/\1/')
- cd ..
# build image
- PVR_MERGE_SRC=device-checkout/.pvr PV_BUILD_INTERACIVE=false ./build.docker.sh $ARCH
# prepare image artifact and metadata
- cd out/$TARGET/
- xz *.img
dependencies:
- upgrade
artifacts:
name: images
paths:
- work/out/$TARGET/*.xz
build-rpi3-daily:
extends: .build
stage: build
variables:
PH_DEVICE_IN: https://pvr.pantahub.com/pantahub-ci/rpi3-initial-latest
PH_DEVICE_OUT: https://pvr.pantahub.com/pantahub-ci/rpi3-initial-latest
ARCH: arm-rpi3
TARGET: rpi3
DEPLOY: "true"
- "jq -n --arg pr \"$PANTAHUB_REVISION\" '{pantahubrevision: $pr}' > img.json"
# upload image and metadata to aws
- if test -z "$CI_COMMIT_TAG" ; then IMAGE_PATH="$CI_COMMIT_REF_NAME/latest/$CI_PIPELINE_ID/$TARGET"; else IMAGE_PATH="$CI_COMMIT_REF_NAME/stable/$CI_COMMIT_TAG/$TARGET"; fi
- aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws s3 cp *.img.xz s3://pantavisor-ci/$IMAGE_PATH/$TARGET.img.xz
- aws s3 cp img.json s3://pantavisor-ci/$IMAGE_PATH/img.json
only:
- schedules
- pushes
- tags
artifacts:
name: images
paths:
- work/out/$TARGET/*.xz
build-rpi3-stable:
build-rpi3:
extends: .build
stage: build
variables:
PH_DEVICE_IN: https://pvr.pantahub.com/pantahub-ci/rpi3-initial-latest
PH_DEVICE_OUT: https://pvr.pantahub.com/pantahub-ci/rpi3-initial-stable
PH_DEVICE_LATEST: https://pvr.pantahub.com/pantahub-ci/rpi3-initial-latest
PH_DEVICE_STABLE: https://pvr.pantahub.com/pantahub-ci/rpi3-initial-stable
ARCH: arm-rpi3
TARGET: rpi3
DEPLOY: "true"
only:
- tags
artifacts:
name: images
paths:
- work/out/$TARGET/*.xz
build-malta-daily:
build-malta:
extends: .build
stage: build
variables:
PH_DEVICE_IN: https://pvr.pantahub.com/pantahub-ci/malta-initial-latest
PH_DEVICE_OUT: https://pvr.pantahub.com/pantahub-ci/malta-initial-latest
PH_DEVICE_LATEST: https://pvr.pantahub.com/pantahub-ci/malta-initial-latest
PH_DEVICE_STABLE: https://pvr.pantahub.com/pantahub-ci/malta-initial-stable
ARCH: malta-qemu
TARGET: malta
DEPLOY: "true"
only:
- schedules
artifacts:
name: images
paths:
- work/out/$TARGET/*.xz
build-malta-stable:
build-bpi-r2:
extends: .build
stage: build
variables:
PH_DEVICE_IN: https://pvr.pantahub.com/pantahub-ci/malta-initial-latest
PH_DEVICE_OUT: https://pvr.pantahub.com/pantahub-ci/malta-initial-stable
ARCH: malta-qemu
TARGET: malta
DEPLOY: "true"
only:
- tags
artifacts:
name: images
paths:
- work/out/$TARGET/*.xz
PH_DEVICE_LATEST: https://pvr.pantahub.com/pantahub-ci/bpi-r2-initial-latest
ARCH: arm-bpi-r2
TARGET: bpi-r2
build-bpi-r2-daily:
build-x64:
extends: .build
stage: build
variables:
PH_DEVICE_IN: https://pvr.pantahub.com/pantahub-ci/bpi-r2-initial-latest
PH_DEVICE_OUT: https://pvr.pantahub.com/pantahub-ci/bpi-r2-initial-latest
ARCH: arm-bpi-r2
TARGET: bpi-r2
DEPLOY: "true"
only:
- schedules
artifacts:
name: images
paths:
- work/out/$TARGET/*.xz
PH_DEVICE_LATEST: https://pvr.pantahub.com/pantahub-ci/x64-initial-latest
ARCH: x64-uefi
TARGET: x64-uefi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment