Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into category-custom/tsc-…
Browse files Browse the repository at this point in the history
…build
  • Loading branch information
sobolk committed Jan 31, 2025
2 parents efc2ea6 + 6715c82 commit 7b609e2
Show file tree
Hide file tree
Showing 857 changed files with 39,275 additions and 22,200 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;
38 changes: 38 additions & 0 deletions .circleci/cb-publish-step-1-set-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash -e

git config --global user.name aws-amplify-bot
git config --global user.email [email protected]

if [[ "$PROJECT_NAME" == "TaggedReleaseWithoutE2E" ]]; then
if [ -z "$NPM_TAG" ]; then
echo "Tag name is missing. Make sure CodeBuild workflow was started with NPM_TAG environment variable"
exit 1
fi

if [[ "$BRANCH_NAME" == "main" ]] || [[ "$BRANCH_NAME" == "dev" ]] || [[ "$BRANCH_NAME" == "hotfix" ]] || [[ "$BRANCH_NAME" == "release" ]]; then
echo "You can't use $BRANCH_NAME for tagged release"
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" --no-commit-hooks --force-publish '@aws-amplify/cli-internal'

# @latest release
elif [[ "$PROJECT_NAME" == "Release" ]]; then

if [[ "$BRANCH_NAME" != "release" ]]; then
echo "Release must run from release branch. Branch provided was $BRANCH_NAME."
exit 1
fi

# 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" --no-commit-hooks --force-publish '@aws-amplify/cli-internal'

# release candidate
elif [[ "$PROJECT_NAME" == "RC" ]]; then
# 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" --no-commit-hooks --force-publish '@aws-amplify/cli-internal'
# local publish for testing / building binary, dev branch build, e2e tests
else
# create release commit and release tags
npx lerna version --preid=dev.$(git rev-parse HEAD) --exact --conventional-prerelease --conventional-commits --yes --no-push --include-merged-tags --message "chore(release): Publish dev" --no-commit-hooks --force-publish '@aws-amplify/cli-internal'
fi
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ function lernaPublishExitOnFailure {
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
npx lerna publish "$@" 2>&1 | tee /tmp/publish-results
# grep the temp file for the lerna err token and return exit 1
number_of_lerna_errors=$(grep "lerna ERR" /tmp/publish-results | wc -l)
if [[ number_of_lerna_errors -gt 0 ]]; then
echo "Fail! Lerna error."
exit 1;
else
echo "Success! Lerna publish succeeded."
fi
}

npmRegistryUrl=$(npm get registry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ function lernaPublishExitOnFailure {
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
npx lerna publish "$@" 2>&1 | tee /tmp/publish-results
# grep the temp file for the lerna err token and return exit 1
number_of_lerna_errors=$(grep "lerna ERR" /tmp/publish-results | wc -l)
if [[ number_of_lerna_errors -gt 0 ]]; then
echo "Fail! Lerna error."
exit 1;
else
echo "Success! Lerna publish succeeded."
fi
}

# verifies that binaries are uploaded and available before publishing to NPM
Expand All @@ -23,22 +30,20 @@ function verifyPkgIsAvailable {
# 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://package.cli.amplify.aws/$desiredPkgVersion/amplify-pkg-linux-x64.tgz
curl -I --fail https://package.cli.amplify.aws/$desiredPkgVersion/amplify-pkg-linux-arm64.tgz
curl -I --fail https://package.cli.amplify.aws/$desiredPkgVersion/amplify-pkg-macos-x64.tgz
curl -I --fail https://package.cli.amplify.aws/$desiredPkgVersion/amplify-pkg-win-x64.tgz
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 [[ "$CIRCLE_BRANCH" =~ ^tagged-release ]]; then
if [[ "$CIRCLE_BRANCH" =~ ^tagged-release-without-e2e-tests\/.* ]]; then
# Remove tagged-release-without-e2e-tests/
export NPM_TAG="${CIRCLE_BRANCH/tagged-release-without-e2e-tests\//}"
elif [[ "$CIRCLE_BRANCH" =~ ^tagged-release\/.* ]]; then
# Remove tagged-release/
export NPM_TAG="${CIRCLE_BRANCH/tagged-release\//}"
fi
if [[ "$PROJECT_NAME" == "TaggedReleaseWithoutE2E" ]]; then
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>"
echo "Tag name is missing. Make sure CodeBuild workflow was started with NPM_TAG environment variable"
exit 1
fi

if [[ "$BRANCH_NAME" == "main" ]] || [[ "$BRANCH_NAME" == "dev" ]] || [[ "$BRANCH_NAME" == "hotfix" ]] || [[ "$BRANCH_NAME" == "release" ]]; then
echo "You can't use $BRANCH_NAME for tagged release"
exit 1
fi

Expand All @@ -49,22 +54,28 @@ if [[ "$CIRCLE_BRANCH" =~ ^tagged-release ]]; then
lernaPublishExitOnFailure from-git --yes --no-push --dist-tag=$NPM_TAG

# @latest release
elif [[ "$CIRCLE_BRANCH" == "release" ]]; then
elif [[ "$PROJECT_NAME" == "Release" ]]; then

if [[ "$BRANCH_NAME" != "release" ]]; then
echo "Release must run from release branch. Branch provided was $BRANCH_NAME."
exit 1
fi

# 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 [[ "$CIRCLE_BRANCH" =~ ^run-e2e-with-rc\/.* ]] || [[ "$CIRCLE_BRANCH" =~ ^release_rc\/.* ]]; then
elif [[ "$PROJECT_NAME" == "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" "$CIRCLE_BRANCH" "did not match any branch publish rules."
echo "Project name" "$PROJECT_NAME" "did not match any publish rules."
exit 1
fi
40 changes: 40 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,40 @@
#!/bin/bash -e

git config --global user.name aws-amplify-bot
git config --global user.email [email protected]

if [[ "$BRANCH_NAME" == "" ]]; then
echo "BRANCH_NAME must be defined for push to git step."
exit 1
fi

if [[ "$PROJECT_NAME" == "TaggedReleaseWithoutE2E" ]] || [[ "$PROJECT_NAME" == "RC" ]]; then
# push release commit
git push origin "$BRANCH_NAME" --no-verify

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

# @latest release
elif [[ "$PROJECT_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 --no-verify

# 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 "Project name" "$PROJECT_NAME" "did not match any publish rules."
exit 1
fi
45 changes: 45 additions & 0 deletions .circleci/codebuild-checkout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash -e

# 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 "PROJECT_NAME=$PROJECT_NAME"
echo "CODEBUILD_SOURCE_VERSION=$CODEBUILD_SOURCE_VERSION"
echo "BRANCH_NAME=$BRANCH_NAME"
echo "CODEBUILD_WEBHOOK_TRIGGER=$CODEBUILD_WEBHOOK_TRIGGER"

# Codebuild doesn't checkout the branch by default
if [[ "$PROJECT_NAME" == "AmplifyCLI-PR-Testing" ]]; then
# If we're in PR workflow create temporary local branch.
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
else
echo "Checking out $BRANCH_NAME"
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"
exit 1
fi
Loading

0 comments on commit 7b609e2

Please sign in to comment.