11version : 0.2
22
33phases :
4+ install :
5+ runtime-versions :
6+ golang : 1.13
7+ pre_build :
8+ commands :
9+ # GOPATH is setup like the following in Codebuild standard 2.0 image
10+ # /go:/codebuild/output/src<some numbers>
11+ # so we copy all the source code to the appropriate location before
12+ # invoking any go command
13+ - ls -lah
14+ - mkdir -p /go/src/github.com/aws/amazon-ecs-cli
15+ - cp -R . /go/src/github.com/aws/amazon-ecs-cli/
16+ - |
17+ env -i PATH=$PATH GOPATH=`go env GOPATH` GOROOT=`go env GOROOT` GOCACHE=`go env GOCACHE` \
18+ go test -race -v -cover github.com/aws/amazon-ecs-cli/ecs-cli/modules/...
19+ # make a copy of the version.go because `go run gen/version-gen.go` will
20+ # modify it.
21+ - cp /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/version.go /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/_version.go
22+ # need to cd into the version package because version-gen.go assumes the relative
23+ # location of the VERSION file.
24+ - cd /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/
25+ # since we are running the go program inside a Linux container, has to hardcode
26+ # the GOOS and GOARCH correspondinly regardless of what the host OS is.
27+ - GOOS=linux GOARCH=amd64 ECS_RELEASE=cleanbuild go run gen/version-gen.go
428 build :
529 commands :
6- - make integ-test
7- - ./bin/local/ecs-cli.test
30+ - echo "cd into $CODEBUILD_SRC_DIR"
31+ - cd $CODEBUILD_SRC_DIR
32+ - echo "Compilation context:"
33+ - echo "CODEBUILD_SOURCE_VERSION=$CODEBUILD_SOURCE_VERSION"
34+ - VERSION=`git tag --points-at HEAD`
35+ - echo "VERSION=$VERSION"
36+ - GIT_COMMIT_ID=`git rev-parse HEAD`
37+ - echo "GIT_COMMIT_ID=$GIT_COMMIT_ID"
38+ # TODO: Get rid of the VERSION file after we fully switch to the new CI/CD
39+ - CHECKED_IN_VERSION=`cat /go/src/github.com/aws/amazon-ecs-cli/VERSION`
40+ - echo "VERSION_FILE=$CHECKED_IN_VERSION"
41+ - echo "GOPATH=$GOPATH"
42+ - |
43+ # $CHECKED_IN_VERSION is not prefixed with "v", only the semantic version number,
44+ # such as 1.17.0 instead of v1.17.0, which is what normal version tags look like.
45+ if [ "$VERSION" != "v$CHECKED_IN_VERSION" ]; then
46+ echo "the VERSION file contains a version number that is different from the git tag. file: $CHECKED_IN_VERSION, tag: $VERSION"
47+ exit 1
48+ fi
49+ - GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "-s" -o aws/amazon-ecs-cli/ecs-cli-windows-amd64-$VERSION.exe github.com/aws/amazon-ecs-cli/ecs-cli/
50+ - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "-s" -o aws/amazon-ecs-cli/ecs-cli-linux-amd64-$VERSION github.com/aws/amazon-ecs-cli/ecs-cli/
51+ - GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "-s" -o aws/amazon-ecs-cli/ecs-cli-darwin-amd64-$VERSION github.com/aws/amazon-ecs-cli/ecs-cli/
52+ finally :
53+ - echo "built artifacts:"
54+ - ls -lah aws/amazon-ecs-cli/
55+ - ./aws/amazon-ecs-cli/ecs-cli-linux-amd64-$VERSION --version
56+ post_build :
57+ commands :
58+ # restore the version file
59+ - mv /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/_version.go /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/version.go
60+ - echo "Creating latest artifacts..."
61+ - cp aws/amazon-ecs-cli/ecs-cli-windows-amd64-$VERSION.exe aws/amazon-ecs-cli/ecs-cli-windows-amd64-latest.exe
62+ - cp aws/amazon-ecs-cli/ecs-cli-linux-amd64-$VERSION aws/amazon-ecs-cli/ecs-cli-linux-amd64-latest
63+ - cp aws/amazon-ecs-cli/ecs-cli-darwin-amd64-$VERSION aws/amazon-ecs-cli/ecs-cli-darwin-amd64-latest
64+ - MANIFESTFILE="$GIT_COMMIT_ID.manifest"
65+ - echo "aws/amazon-ecs-cli/ecs-cli-windows-amd64-$VERSION.exe" >> $MANIFESTFILE
66+ - echo "aws/amazon-ecs-cli/ecs-cli-linux-amd64-$VERSION" >> $MANIFESTFILE
67+ - echo "aws/amazon-ecs-cli/ecs-cli-darwin-amd64-$VERSION" >> $MANIFESTFILE
68+ - echo "aws/amazon-ecs-cli/ecs-cli-windows-amd64-latest.exe" >> $MANIFESTFILE
69+ - echo "aws/amazon-ecs-cli/ecs-cli-linux-amd64-latest" >> $MANIFESTFILE
70+ - echo "aws/amazon-ecs-cli/ecs-cli-darwin-amd64-latest" >> $MANIFESTFILE
71+ artifacts :
72+ files :
73+ - ' **/*'
0 commit comments