Skip to content

Commit 8811bbe

Browse files
sobolkAmplifiyer
andauthored
test: remove extra hash (#13263)
* Revert "Revert "test: remove extra hash (#13071)" (#13084)" This reverts commit 5013f9a. * test: make upload idempotent * test: make upload idempotent * test: make upload idempotent * test: use ful hash for testing stuff * Update .circleci/local_publish_helpers_codebuild.sh Co-authored-by: Amplifiyer <[email protected]> --------- Co-authored-by: Amplifiyer <[email protected]>
1 parent ac44ef2 commit 8811bbe

File tree

3 files changed

+32
-46
lines changed

3 files changed

+32
-46
lines changed

.circleci/cb-publish-step-1-set-versions.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ elif [[ "$PROJECT_NAME" == "Release" ]]; then
2727
# create release commit and release tags
2828
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'
2929

30-
# release candidate or local publish for testing / building binary
31-
else
30+
# release candidate
31+
elif [[ "$PROJECT_NAME" == "RC" ]]; then
3232
# create release commit and release tags
3333
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'
34+
# local publish for testing / building binary, dev branch build, e2e tests
35+
else
36+
# create release commit and release tags
37+
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'
3438
fi

.circleci/local_publish_helpers_codebuild.sh

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,36 @@ function startLocalRegistry {
2424
}
2525

2626
function uploadPkgCliCodeBuild {
27+
# fail and exit if any command fails
28+
set -e
29+
2730
cd out/
28-
export hash=$(git rev-parse HEAD | cut -c 1-12)
2931
export version=$(./amplify-pkg-linux-x64 --version)
3032

31-
if [[ "$PROJECT_NAME" == "Release" ]] || [[ "$PROJECT_NAME" == "RC" ]] || [[ "$PROJECT_NAME" == "TaggedReleaseWithoutE2E" ]]; then
32-
aws s3 cp amplify-pkg-win-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-win-x64-$(echo $hash).tgz
33-
aws s3 cp amplify-pkg-macos-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-macos-x64-$(echo $hash).tgz
34-
aws s3 cp amplify-pkg-linux-arm64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-arm64-$(echo $hash).tgz
35-
aws s3 cp amplify-pkg-linux-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-x64-$(echo $hash).tgz
36-
37-
ALREADY_EXISTING_FILES="$(set -o pipefail && aws s3 ls s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-x64 | ( egrep -v "amplify-pkg-linux-x64-.*" || true ) | wc -l | xargs)"
38-
INCORRECT_PERMISSIONS=$?
39-
40-
if [ INCORRECT_PERMISSIONS -ne "0" ]; then
41-
echo "Insufficient permissions to list s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-x64"
42-
exit 1
43-
fi
44-
45-
if [ ALREADY_EXISTING_FILES -ne "0" ]; then
46-
echo "Cannot overwrite existing file at s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-x64.tgz"
47-
exit 1
48-
fi
49-
50-
aws s3 cp amplify-pkg-win-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-win-x64.tgz
51-
aws s3 cp amplify-pkg-macos-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-macos-x64.tgz
52-
aws s3 cp amplify-pkg-linux-arm64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-arm64.tgz
53-
aws s3 cp amplify-pkg-linux-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-x64.tgz
54-
55-
else
56-
aws s3 cp amplify-pkg-linux-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-x64-$(echo $hash).tgz
33+
# validate that version is uploaded in right build
34+
if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
35+
if [[ "$PROJECT_NAME" != "Release" ]]; then
36+
echo "Invalid project name $PROJECT_NAME for $version release."
37+
exit 1
38+
fi
39+
elif [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\. ]]; then
40+
if [[ "$PROJECT_NAME" != "RC" ]]; then
41+
echo "Invalid project name $PROJECT_NAME for $version RC release."
42+
exit 1
43+
fi
44+
elif [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+-$ ]]; then
45+
echo "Version $version is missing a tag";
46+
exit 1
5747
fi
5848

49+
# It's ok to re-upload binaries for the same build to make this step idempotent
50+
# Versioning is handled by cb-publish-step-1-set-versions script
51+
# Version conflicts are caught at cb-publish-step-2-verdaccio script
52+
aws s3 cp amplify-pkg-win-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-win-x64.tgz
53+
aws s3 cp amplify-pkg-macos-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-macos-x64.tgz
54+
aws s3 cp amplify-pkg-linux-arm64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-arm64.tgz
55+
aws s3 cp amplify-pkg-linux-x64.tgz s3://$PKG_CLI_BUCKET_NAME/$(echo $version)/amplify-pkg-linux-x64.tgz
56+
5957
cd ..
6058
}
6159

packages/amplify-cli-npm/binary.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'fs';
22
import path from 'path';
3-
import { spawnSync, execSync } from 'child_process';
3+
import { spawnSync } from 'child_process';
44
import util from 'util';
55
import tar from 'tar-stream';
66
import { createGunzip } from 'zlib';
@@ -75,27 +75,11 @@ const getCompressedBinaryUrl = (): string => {
7575
if (process.env.IS_AMPLIFY_CI && process.env.CODEBUILD_SRC_DIR) {
7676
// use cloudfront distribution for e2e
7777
url = `https://${process.env.PKG_CLI_CLOUDFRONT_URL}/${version}/${compressedBinaryName}`;
78-
url = url.replace('.tgz', `-${getCommitHash()}.tgz`);
79-
} else if (process.env.IS_AMPLIFY_CI) {
80-
url = url.replace('.tgz', `-${getCommitHash()}.tgz`);
8178
}
8279

8380
return url;
8481
};
8582

86-
/**
87-
* CI-only, used for testing hash-based binaries
88-
*
89-
* @returns string
90-
*/
91-
const getCommitHash = (): string => {
92-
if (process.env.hash) {
93-
return process.env.hash;
94-
}
95-
const hash = execSync('(git rev-parse HEAD | cut -c 1-12) || false').toString();
96-
return hash.substr(0, 12);
97-
};
98-
9983
/**
10084
* Wraps logic to download and run binary
10185
*/

0 commit comments

Comments
 (0)