blob: 93bf677a45acf3feb3c297d81aee1c335a2d8f66 [file] [log] [blame]
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Azure template for uploading artifacts to a Google Cloud Platform (GCP)
# bucket.
#
# This template first installs gsutil to interact with GCP resources. Then,
# files located under parentDir and at paths specified by includeFiles will be
# packed into archiveName (a tar.gz file) and uploaded to a GCP bucket located
# at bucketURI using gsutil.
#
# Writing to a GCP bucket requires a GCP service account key with sufficient
# permisions. This key must be uploaded to Azure as a Secure File. The name of
# the key file should be provided as gcpKeyFile.
#
parameters:
- name: parentDir
type: string
default: ""
- name: includeFiles
type: object
default: []
- name: gcpKeyFile
type: string
default: ""
- name: bucketURI
type: string
default: ""
steps:
- task: DownloadSecureFile@1
name: gcpkey
inputs:
secureFile: ${{ parameters.gcpKeyFile }}
- bash: |
echo "Installing gsutil"
sudo apt-get install -y apt-transport-https ca-certificates gnupg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | \
sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
echo "vvvvvvvvv cat /etc/apt/sources.list.d/google-cloud-sdk.list"
cat /etc/apt/sources.list.d/google-cloud-sdk.list
echo "^^^^^^^^"
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo tee /usr/share/keyrings/cloud.google.gpg
sudo apt-get update || {
error "Failed to run apt-get update"
}
sudo apt-get install -y google-cloud-cli
. util/build_consts.sh
printf "$(date -u +%Y-%m-%dT%H:%M:%S)\n$(Build.SourceVersion)" > latest.txt
printf "${{ join('\n', parameters.includeFiles) }}" > include_files.txt
tar -C ${{ parameters.parentDir }} -zcvf bitstream-latest.tar.gz -T include_files.txt
gsutil -o Credentials:gs_service_key_file=$(gcpkey.secureFilePath) \
cp latest.txt ${{ parameters.bucketURI }}/latest.txt
gsutil -o Credentials:gs_service_key_file=$(gcpkey.secureFilePath) \
cp -r bitstream-latest.tar.gz ${{ parameters.bucketURI }}/bitstream-latest.tar.gz
gsutil -o Credentials:gs_service_key_file=$(gcpkey.secureFilePath) \
cp -r ${{ parameters.bucketURI }}/bitstream-latest.tar.gz ${{ parameters.bucketURI }}/bitstream-$(Build.SourceVersion).tar.gz
condition: succeeded()
continueOnError: true
displayName: Upload bitstreams to GCP bucket