Skip to content

Commit

Permalink
Merge branch 'aws-amplify:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolk authored Aug 21, 2023
2 parents f4c187a + 5140bb2 commit 68a4d18
Show file tree
Hide file tree
Showing 269 changed files with 4,130 additions and 1,660 deletions.
2 changes: 1 addition & 1 deletion .circleci/amplify_init.exp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ send -- "$env(AWS_SECRET_ACCESS_KEY)\r"
expect -exact "region:"
log_user 1;
send -- "j\r"
expect "Help improve Amplify CLI by sharing non sensitive configurations on failures"
expect "Help improve Amplify CLI by sharing non-sensitive project configurations on failures"
send -- "\r"
interact;
30 changes: 30 additions & 0 deletions .circleci/cb-publish-step-1-set-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash -e

git config --global user.name aws-amplify-bot
git config --global user.email aws@amazon.com

if [[ "$BRANCH_NAME" =~ ^tagged-release ]]; then
if [[ "$BRANCH_NAME" =~ ^tagged-release-without-e2e-tests\/.* ]]; then
# Remove tagged-release-without-e2e-tests/
export NPM_TAG="${BRANCH_NAME/tagged-release-without-e2e-tests\//}"
elif [[ "$BRANCH_NAME" =~ ^tagged-release\/.* ]]; then
# Remove tagged-release/
export NPM_TAG="${BRANCH_NAME/tagged-release\//}"
fi
if [ -z "$NPM_TAG" ]; then
echo "Tag name is missing. Name your branch with either tagged-release/<tag-name> or tagged-release-without-e2e-tests/<tag-name>"
exit 1
fi

npx lerna version --exact --preid=$NPM_TAG --conventional-commits --conventional-prerelease --yes --no-push --include-merged-tags --message "chore(release): Publish tagged release $NPM_TAG [ci skip]" --no-commit-hooks --force-publish '@aws-amplify/cli-internal'

# @latest release
elif [[ "$BRANCH_NAME" == "release" ]]; then
# create release commit and release tags
npx lerna version --exact --conventional-commits --conventional-graduate --yes --no-push --include-merged-tags --message "chore(release): Publish latest [ci skip]" --no-commit-hooks --force-publish '@aws-amplify/cli-internal'

# release candidate or local publish for testing / building binary
else
# create release commit and release tags
npx lerna version --preid=rc.$(git rev-parse --short=15 HEAD) --exact --conventional-prerelease --conventional-commits --yes --no-push --include-merged-tags --message "chore(release): Publish rc [ci skip]" --no-commit-hooks --force-publish '@aws-amplify/cli-internal'
fi
25 changes: 25 additions & 0 deletions .circleci/cb-publish-step-2-verdaccio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -e

# lerna has a bug (https://github.com/lerna/lerna/issues/1066) where failed publishes do not set the exit code properly
# this causes the script to keep running even after failed publishes
# this function forces failed publishes to exit on failure
function lernaPublishExitOnFailure {
# exit on failure
set -e
# run lerna publish with the args that were passed to this function
# duplicate stdout to a temp file
# grep the temp file for the lerna err token and return exit 1 if found (-v option inverts grep exit code)
npx lerna publish "$@" | tee /tmp/publish-results && grep -qvz "lerna ERR!" < /tmp/publish-results
}

npmRegistryUrl=$(npm get registry)
if [[ "$npmRegistryUrl" =~ ^http://localhost ]]; then
# registy URL update changes .yarnrc.yml file
git update-index --assume-unchanged .yarnrc.yml

echo "Publishing to local registry under latest tag"
lernaPublishExitOnFailure from-git --yes --no-push
else
echo "NPM registry url is not pointing to localhost, $npmRegistryUrl"
exit 1
fi
70 changes: 70 additions & 0 deletions .circleci/cb-publish-step-3-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash -e

# lerna has a bug (https://github.com/lerna/lerna/issues/1066) where failed publishes do not set the exit code properly
# this causes the script to keep running even after failed publishes
# this function forces failed publishes to exit on failure
function lernaPublishExitOnFailure {
# exit on failure
set -e
# run lerna publish with the args that were passed to this function
# duplicate stdout to a temp file
# grep the temp file for the lerna err token and return exit 1 if found (-v option inverts grep exit code)
npx lerna publish "$@" | tee /tmp/publish-results && grep -qvz "lerna ERR!" < /tmp/publish-results
}

# verifies that binaries are uploaded and available before publishing to NPM
function verifyPkgIsAvailable {
# exit on failure
set -e

# read version of @aws-amplify/cli
desiredPkgVersion=$(npx lerna list --scope @aws-amplify/cli --json | jq -r '.[0].version')

# check binaries
# send HEAD requests to check for binary presence
# curl --fail exits with non-zero code and makes this script fail
curl -I --fail https://$PKG_CLI_CLOUDFRONT_URL/$desiredPkgVersion/amplify-pkg-linux-x64.tgz
curl -I --fail https://$PKG_CLI_CLOUDFRONT_URL/$desiredPkgVersion/amplify-pkg-linux-arm64.tgz
curl -I --fail https://$PKG_CLI_CLOUDFRONT_URL/$desiredPkgVersion/amplify-pkg-macos-x64.tgz
curl -I --fail https://$PKG_CLI_CLOUDFRONT_URL/$desiredPkgVersion/amplify-pkg-win-x64.tgz
}

if [[ "$BRANCH_NAME" =~ ^tagged-release ]]; then
if [[ "$BRANCH_NAME" =~ ^tagged-release-without-e2e-tests\/.* ]]; then
# Remove tagged-release-without-e2e-tests/
export NPM_TAG="${BRANCH_NAME/tagged-release-without-e2e-tests\//}"
elif [[ "$BRANCH_NAME" =~ ^tagged-release\/.* ]]; then
# Remove tagged-release/
export NPM_TAG="${BRANCH_NAME/tagged-release\//}"
fi
if [ -z "$NPM_TAG" ]; then
echo "Tag name is missing. Name your branch with either tagged-release/<tag-name> or tagged-release-without-e2e-tests/<tag-name>"
exit 1
fi

# verify that binary has been uploaded
verifyPkgIsAvailable

echo "Publishing to NPM under $NPM_TAG tag"
lernaPublishExitOnFailure from-git --yes --no-push --dist-tag=$NPM_TAG

# @latest release
elif [[ "$BRANCH_NAME" == "release" ]]; then
# verify that binary has been uploaded
verifyPkgIsAvailable

# publish versions that were just computed
lernaPublishExitOnFailure from-git --yes --no-push

# release candidate or local publish for testing / building binary
elif [[ "$BRANCH_NAME" =~ ^run-e2e-with-rc\/.* ]] || [[ "$BRANCH_NAME" =~ ^release_rc\/.* ]]; then

# verify that binary has been uploaded
verifyPkgIsAvailable

# publish versions that were just computed
lernaPublishExitOnFailure from-git --yes --no-push --dist-tag rc
else
echo "branch name" "$BRANCH_NAME" "did not match any branch publish rules."
exit 1
fi
35 changes: 35 additions & 0 deletions .circleci/cb-publish-step-4-push-to-git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash -e

git config --global user.name aws-amplify-bot
git config --global user.email aws@amazon.com

if [[ "$BRANCH_NAME" =~ ^tagged-release ]] || [[ "$BRANCH_NAME" =~ ^run-e2e-with-rc\/.* ]] || [[ "$BRANCH_NAME" =~ ^release_rc\/.* ]]; then
# push release commit
git push origin "$BRANCH_NAME" --no-verify

# push release tags
git tag --points-at HEAD | xargs git push origin

# @latest release
elif [[ "$BRANCH_NAME" == "release" ]]; then
# push release commit
git push origin "$BRANCH_NAME" --no-verify

# push release tags
git tag --points-at HEAD | xargs git push origin

# fast forward main to release
git fetch origin main
git checkout main
git merge release --ff-only
git push origin main --no-verify

# fast forward hotfix to release
git fetch origin hotfix
git checkout hotfix
git merge release --ff-only
git push origin hotfix --no-verify
else
echo "branch name" "$BRANCH_NAME" "did not match any branch publish rules."
exit 1
fi
19 changes: 18 additions & 1 deletion .circleci/codebuild-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# This script checks out a branch & loads git tags.

# Get the hash that CodeBuild used to start workflow and use it later to validate that we didn't change it after transformations below.
INITIAL_HEAD_HASH=$(git rev-parse HEAD)

git status

echo "CODEBUILD_SOURCE_VERSION=$CODEBUILD_SOURCE_VERSION"
Expand All @@ -14,13 +17,17 @@ if [[ "$CODEBUILD_SOURCE_VERSION" != "" ]]; then
fi

# Codebuild doesn't checkout the branch by default
if [[ "$CODEBUILD_WEBHOOK_TRIGGER" =~ ^pr/ || "$CODEBUILD_SOURCE_VERSION" =~ ^pr/ || "$CODEBUILD_SOURCE_VERSION_REF" =~ refs/pull/[0-9]+/head$ ]]; then
if [[ "$AMPLIFY_CI_MANUAL_PR_BUILD" == "true" || "$CODEBUILD_WEBHOOK_TRIGGER" =~ ^pr/ || "$CODEBUILD_SOURCE_VERSION" =~ ^pr/ || "$CODEBUILD_SOURCE_VERSION_REF" =~ refs/pull/[0-9]+/head$ ]]; then
# If we're in PR workflow create temporary local branch.
# We detect if we're in PR by looking for pr/<number> pattern in code build env variables
# or by checking if commit is matching refs/pull/<number>/head.
echo "Creating temporary local branch for PR build"
TEMP_BRANCH_NAME=$(cat /proc/sys/kernel/random/uuid)
git checkout -b $TEMP_BRANCH_NAME
elif [[ "$CODEBUILD_WEBHOOK_TRIGGER" == "branch/dev" ]]; then
# We're in E2E workflow triggered after pushing to dev.
echo "Checking out dev"
git checkout dev
elif [[ "$BRANCH_NAME" == "" ]]; then
echo "BRANCH_NAME must be defined for non-PR builds"
exit 1
Expand All @@ -29,5 +36,15 @@ else
git checkout $BRANCH_NAME
fi

git show --summary

echo "Fetching tags"
git fetch --all --tags

# A sanity check that we haven't altered commit we're building from. This must be last section in this script
HEAD_HASH=$(git rev-parse HEAD)
if [[ "$INITIAL_HEAD_HASH" != "$HEAD_HASH" ]]; then
echo "Fail! Detected a drift of commit we attempt to build!"
echo "INITIAL_HEAD_HASH=$INITIAL_HEAD_HASH"
echo "HEAD_HASH=$HEAD_HASH"
fi
7 changes: 6 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ workflows:
setup:
when: << pipeline.parameters.setup >>
jobs:
- setup
- setup:
filters:
branches:
only:
- /run-e2e\/.*/
- /pull\/.*
nightly_console_integration_tests:
when: << pipeline.parameters.nightly_console_integration_tests >>
jobs:
Expand Down
Loading

0 comments on commit 68a4d18

Please sign in to comment.