version: 0.2 # Run unprivileged for most phases (except those marked "run-as: root"). run-as: codebuild-user env: variables: AWS_TOOLKIT_TEST_USER_DIR: '/tmp/' # needed or else webpack will cause it to run out of memory NODE_OPTIONS: '--max-old-space-size=8192' phases: install: run-as: root runtime-versions: nodejs: 16 commands: # Prepare env for unprivileged user. - | mkdir -p ~codebuild-user chown -R codebuild-user:codebuild-user /tmp ~codebuild-user . chmod +x ~codebuild-user ls -ld ~codebuild-user pre_build: commands: # CodeBuild ignores env.variables.HOME, so do it manually here :( - export HOME=/home/codebuild-user # If present, log into CodeArtifact. Provides a nice safety net in case NPM is down. # Should only affect tests run through IDEs team-hosted CodeBuild. - | if [ "$TOOLKITS_CODEARTIFACT_DOMAIN" ] && [ "$TOOLKITS_CODEARTIFACT_REPO" ] && [ "$TOOLKITS_ACCOUNT_ID" ]; then if aws codeartifact login --tool npm --domain "$TOOLKITS_CODEARTIFACT_DOMAIN" --domain-owner "$TOOLKITS_ACCOUNT_ID" --repository "$TOOLKITS_CODEARTIFACT_REPO" > /dev/null 2>&1; then echo "Connected to CodeArtifact" else echo "CodeArtifact connection failed. Falling back to npm" fi fi - npm ci build: commands: # CodeBuild ignores env.variables.HOME, so do it manually here :( - export HOME=/home/codebuild-user # Generate CHANGELOG.md - npm run createRelease - npm run generateNonCodeFiles - cp ./README.quickstart.vscode.md ./README.md - npm run package artifacts: files: - aws-toolkit-vscode* discard-paths: true