Skip to content

Commit

Permalink
ci: rc, release, tagged rc, hotfix workflows (#12918)
Browse files Browse the repository at this point in the history
* ci: rc, release, tagged rc, hotfix workflows

* ci: cleanup

* ci: update prepush hooks

* ci: adjustments for yarn2

* ci: split deployment step codebuild

* ci: remove references to old helpers file

* ci: remove old publish helpers file

* ci: add artifact to allow all jobs to be dependedon

* ci: add deployment verification steps

* ci: enable tagged release

* ci: fix typo in path to file

* ci: aea flag

* ci: try source

* ci: fix permissions on file

* ci: remove checkout in publish helpers

* ci: cleanup extra step

* ci: maintain old cci files
  • Loading branch information
awsluja authored Aug 3, 2023
1 parent 727a1d3 commit 71257ec
Show file tree
Hide file tree
Showing 42 changed files with 1,272 additions and 225 deletions.
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 [email protected]

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 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 [email protected]

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

# 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"

# 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

# fast forward hotfix to release
git fetch origin hotfix
git checkout hotfix
git merge release --ff-only
git push origin hotfix
else
echo "branch name" "$BRANCH_NAME" "did not match any branch publish rules."
exit 1
fi
Loading

0 comments on commit 71257ec

Please sign in to comment.