Skip to content

Commit

Permalink
add npm rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolk committed Nov 28, 2023
1 parent ddb8425 commit cac8a74
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 96 deletions.
102 changes: 6 additions & 96 deletions codebuild_specs/release_workflows/rollback_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,99 +26,9 @@ batch:
compute-type: BUILD_GENERAL1_LARGE
depend-on:
- validate_rollback_target_version
# - identifier: verify_yarn_lock
# buildspec: codebuild_specs/verify_yarn_lock.yml
# depend-on:
# - build_linux
# - identifier: publish_to_local_registry
# buildspec: codebuild_specs/publish_to_local_registry.yml
# depend-on:
# - build_linux
# env:
# compute-type: BUILD_GENERAL1_LARGE
# - identifier: build_pkg_binaries_arm
# buildspec: codebuild_specs/build_pkg_binaries_arm.yml
# depend-on:
# - build_linux
# env:
# compute-type: BUILD_GENERAL1_LARGE
# - identifier: build_pkg_binaries_linux
# buildspec: codebuild_specs/build_pkg_binaries_linux.yml
# depend-on:
# - build_linux
# env:
# compute-type: BUILD_GENERAL1_LARGE
# - identifier: build_pkg_binaries_macos
# buildspec: codebuild_specs/build_pkg_binaries_macos.yml
# depend-on:
# - build_linux
# env:
# compute-type: BUILD_GENERAL1_LARGE
# - identifier: build_pkg_binaries_win
# buildspec: codebuild_specs/build_pkg_binaries_win.yml
# depend-on:
# - build_linux
# env:
# compute-type: BUILD_GENERAL1_LARGE
# - identifier: upb
# buildspec: codebuild_specs/upload_pkg_binaries.yml
# depend-on:
# - build_linux
# env:
# compute-type: BUILD_GENERAL1_LARGE
# - identifier: verify_pkg_cli
# buildspec: codebuild_specs/verify_pkg_cli.yml
# depend-on:
# - build_linux
# env:
# compute-type: BUILD_GENERAL1_LARGE
# - identifier: verify_versions_match
# buildspec: codebuild_specs/verify_versions_match.yml
# depend-on:
# - build_linux
# - identifier: github_prerelease
# buildspec: codebuild_specs/release_workflows/github_prerelease.yml
# env:
# compute-type: BUILD_GENERAL1_LARGE
# debug-session: true
# depend-on:
# - upb
# - identifier: github_prerelease_install_sanity_check
# buildspec: codebuild_specs/release_workflows/github_prerelease_install_sanity_check.yml
# env:
# compute-type: BUILD_GENERAL1_LARGE
# debug-session: true
# depend-on:
# - github_prerelease
# - identifier: publish_to_npm
# buildspec: codebuild_specs/publish_to_npm.yml
# env:
# compute-type: BUILD_GENERAL1_LARGE
# debug-session: true
# depend-on:
# - upb
# - verify_versions_match
# - github_prerelease_install_sanity_check
# - publish_to_local_registry
# - validate_cdk_version
# - verify_yarn_lock
# - verify_pkg_cli
# - identifier: post_publish_push_to_git
# buildspec: codebuild_specs/release_workflows/post_publish_push_to_git.yml
# depend-on:
# - publish_to_npm
# - identifier: github_release
# buildspec: codebuild_specs/release_workflows/github_release.yml
# env:
# compute-type: BUILD_GENERAL1_LARGE
# debug-session: true
# depend-on:
# - post_publish_push_to_git
# - identifier: deployment_verification_post_release
# buildspec: codebuild_specs/deployment_verification_post_release.yml
# env:
# compute-type: BUILD_GENERAL1_LARGE
# git-credential-helper: yes
# debug-session: true
# depend-on:
# - github_release
- identifier: rollback_npm
buildspec: codebuild_specs/rollback_npm.yml
env:
compute-type: BUILD_GENERAL1_LARGE
depend-on:
- validate_rollback_target_version
11 changes: 11 additions & 0 deletions codebuild_specs/rollback_npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 0.2
env:
shell: bash
git-credential-helper: yes
phases:
build:
commands:
- source ./shared-scripts.sh && _rollbackNpm
artifacts:
files:
- 'shared-scripts.sh'
13 changes: 13 additions & 0 deletions shared-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,19 @@ function _publishToNpm {

source ./.circleci/cb-publish-step-3-npm.sh
}
function _rollbackNpm {
loadCache repo $CODEBUILD_SRC_DIR

if [ -z "$ROLLBACK_TARGET_VERSION" ]; then
echo "Rollback target version is missing. Make sure CodeBuild workflow was started with ROLLBACK_TARGET_VERSION environment variable"
exit 1
fi

echo Authenticate with npm
echo "//registry.npmjs.org/:_authToken=$NPM_PUBLISH_TOKEN" > ~/.npmrc

npm dist-tag add @aws-amplify/cli@$ROLLBACK_TARGET_VERSION "latest"
}
function _postPublishPushToGit {
loadCache repo $CODEBUILD_SRC_DIR
loadCache all-binaries $CODEBUILD_SRC_DIR/out
Expand Down

0 comments on commit cac8a74

Please sign in to comment.