version: 0.2 env: variables: # Github username of the forked repo on which to make builds GITHUBUSERNAME: aws phases: install: commands: - architecture="" # Same buildspec for different architectures - detect the architecture here and rename the artifacts accordingly - case $(uname -m) in x86_64) architecture="amd64" ;; aarch64) architecture="arm64" ;; esac # Set up proper go version - GOVERSION="$(cat GO_VERSION)" - BUILD_LOG="build_${architecture}.log" - GOLANG_TAR="go${GOVERSION}.linux-${architecture}.tar.gz" # Need to install GOLANG explicitly as required versions do not come preinstalled # Remove existing go installation (goenv utility) and install downloaded binaries - rm -rf /root/.goenv/ - wget -O /tmp/${GOLANG_TAR} https://storage.googleapis.com/golang/${GOLANG_TAR} | tee $BUILD_LOG - tar -C /usr/local -xzf /tmp/${GOLANG_TAR} | tee -a $BUILD_LOG # Set appropriate environment variables - export GOROOT=/usr/local/go - export GOPATH=$HOME/go - export GOBIN=$GOPATH/bin - export PATH=$PATH:$GOROOT/bin:$GOBIN - which go | tee -a $BUILD_LOG - go version | tee -a $BUILD_LOG build: commands: - go version - echo "build_id = $CODEBUILD_LOG_PATH" 2>&1 | tee -a $BUILD_LOG - echo "Building agent image" 2>&1 | tee -a $BUILD_LOG - AGENT_VERSION=$(cat VERSION) - ECS_AGENT_TAR="ecs-agent-v${AGENT_VERSION}.tar" - ECS_AGENT_RPM="amazon-ecs-init-${AGENT_VERSION}-1.x86_64.rpm" - echo $(pwd) 2>&1 | tee -a $BUILD_LOG # Path readjustment for codebuild testing with fork and setting GOPATH appropriately - cd ../../../.. - export GOPATH=$GOPATH:$(pwd) - cd src/github.com - | if [[ $GITHUBUSERNAME != "aws" ]] ; then mv $GITHUBUSERNAME aws fi - cd aws/amazon-ecs-agent # Building agent tars - GO111MODULE=auto - make release-agent 2>&1 | tee -a $BUILD_LOG - make generic-rpm-integrated 2>&1 | tee -a $BUILD_LOG - ls # Rename artifacts for architecture - | if [[ $architecture == "arm64" ]] ; then mv $ECS_AGENT_TAR "ecs-agent-arm64-v${AGENT_VERSION}.tar" ECS_AGENT_RPM="amazon-ecs-init-${AGENT_VERSION}-1.aarch64.rpm" ECS_AGENT_TAR="ecs-agent-arm64-v${AGENT_VERSION}.tar" fi post_build: commands: artifacts: files: - $ECS_AGENT_TAR - $ECS_AGENT_RPM - $BUILD_LOG name: $CODEBUILD_RESOLVED_SOURCE_VERSION