Skip to content

Commit a0477fa

Browse files
author
Victor Santos
committed
fix: improve S3 environment variable validation and streamline upload logic
- Changed the validation for S3 environment variables to exit on error instead of warning, ensuring the script halts if required variables are missing. - Removed the S3_ENABLED flag, simplifying the upload logic for APK and RPM packages by directly checking for the presence of files. - Enhanced clarity in the RPM upload section by consolidating the upload and metadata regeneration steps.
1 parent ed01935 commit a0477fa

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

upload_to_cloudsmith.sh

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ validate_s3_env() {
1717
[ -z "$AWS_SECRET_ACCESS_KEY" ] && missing+=("AWS_SECRET_ACCESS_KEY")
1818

1919
if [ ${#missing[@]} -gt 0 ]; then
20-
echo "Warning: Missing environment variables for S3 uploads: ${missing[*]}"
21-
echo "S3 upload steps will be skipped."
22-
return 1
20+
echo "Error: Missing required environment variables for S3 uploads: ${missing[*]}"
21+
exit 1
2322
fi
24-
return 0
2523
}
2624

27-
S3_ENABLED=false
28-
validate_s3_env && S3_ENABLED=true
25+
validate_s3_env
2926

3027
# ============================================
3128
# APK - Upload to Cloudsmith (keep until S3 is validated)
@@ -38,7 +35,7 @@ done
3835
# ============================================
3936
# APK - Upload to S3 and generate APKINDEX
4037
# ============================================
41-
if ls *.apk 1> /dev/null 2>&1 && [ "$S3_ENABLED" = "true" ]; then
38+
if ls *.apk 1> /dev/null 2>&1; then
4239
echo "Processing APK packages..."
4340

4441
# Create local directory structure
@@ -122,24 +119,22 @@ done
122119
# ============================================
123120
# RPM - Upload to S3 and regenerate repo metadata
124121
# ============================================
125-
if [ "$S3_ENABLED" = "true" ]; then
126-
for i in *.rpm; do
127-
[ -f "$i" ] || break
128-
129-
# Sign the RPM package
130-
rpmsign --addsign --key-id="$INFISICAL_CLI_REPO_SIGNING_KEY_ID" "$i"
131-
132-
# Upload to S3
133-
aws s3 cp "$i" "s3://$INFISICAL_CLI_S3_BUCKET/rpm/Packages/"
134-
done
122+
for i in *.rpm; do
123+
[ -f "$i" ] || break
124+
125+
# Sign the RPM package
126+
rpmsign --addsign --key-id="$INFISICAL_CLI_REPO_SIGNING_KEY_ID" "$i"
127+
128+
# Upload to S3
129+
aws s3 cp "$i" "s3://$INFISICAL_CLI_S3_BUCKET/rpm/Packages/"
130+
done
135131

136-
# Regenerate RPM repository metadata with mkrepo
137-
# Note: mkrepo uses boto3 which automatically reads AWS_ACCESS_KEY_ID and
138-
# AWS_SECRET_ACCESS_KEY from environment variables set in the workflow
139-
if ls *.rpm 1> /dev/null 2>&1; then
140-
export GPG_SIGN_KEY=$INFISICAL_CLI_REPO_SIGNING_KEY_ID
141-
mkrepo "s3://$INFISICAL_CLI_S3_BUCKET/rpm" \
142-
--s3-region="us-east-1" \
143-
--sign
144-
fi
132+
# Regenerate RPM repository metadata with mkrepo
133+
# Note: mkrepo uses boto3 which automatically reads AWS_ACCESS_KEY_ID and
134+
# AWS_SECRET_ACCESS_KEY from environment variables set in the workflow
135+
if ls *.rpm 1> /dev/null 2>&1; then
136+
export GPG_SIGN_KEY=$INFISICAL_CLI_REPO_SIGNING_KEY_ID
137+
mkrepo "s3://$INFISICAL_CLI_S3_BUCKET/rpm" \
138+
--s3-region="us-east-1" \
139+
--sign
145140
fi

0 commit comments

Comments
 (0)