Skip to content

Commit

Permalink
Add AL23 ref doc and install specific go version
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephylouise committed Jul 1, 2024
1 parent c20567c commit 540bbcb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions buildspecs/pr-build-amzn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
phases:
install:
commands:
# Same buildspec used for different Amazon Linuc versions - detect verison to use in Go installation
# Same buildspec used for different Amazon Linux versions - detect verison to use in Go installation
- |
if [ -f /etc/os-release ]; then
. /etc/os-release
Expand Down Expand Up @@ -41,25 +41,30 @@ phases:
esac

# Identify the correct AL2023 version to use in the Go installation
# Ref: https://docs.aws.amazon.com/linux/al2023/ug/managing-repos-os-updates.html
# xmllint is required to find the latest distribution release from releasemd.xml in us-west-2
- AL23_VERSION="$(curl -s https://al2023-repos-us-west-2-de612dc2.s3.dualstack.us-west-2.amazonaws.com/core/releasemd.xml | xmllint --xpath "string(//root/releases/release[last()]/@version)" -)"
- AGENT_VERSION=$(cat VERSION)

# Need to install GOLANG explicitly as required versions do not come preinstalled
# Remove existing go installation (goenv utility) and install downloaded binaries
# Remove existing go installation (goenv utility)
- sudo rm -rf /root/.goenv
- sudo rm -rf /usr/local/go/bin/go

# Install dependencies and define variables based on the build image used
# Define the Go version to install
- GOVERSION="$(cat GO_VERSION)"

# Install Go and define variables based on Amazon Linux version (2 or 2023)
# Amazon Linux 2023 uses package manager DNF, while older versions use YUM
# Set the appropriate AL23 version echo string to include in build log
- |
if [[ "$amzn_version" = "amzn2023" ]]; then
sudo dnf --releasever="$AL23_VERSION" update -y
sudo yum install -y golang
sudo yum install -y golang-$GOVERSION
amzn_version="amzn2023"
al23_version_echo="Amazon Linux 2023 Version: $AL23_VERSION"
elif [[ "$amzn_version" = "amzn2" ]]; then
sudo yum install -y golang
sudo yum install -y golang-$GOVERSION
amzn_version="amzn2"
al23_version_echo=""
else
Expand Down

0 comments on commit 540bbcb

Please sign in to comment.