Skip to content

Commit 003d57c

Browse files
sfc-gh-heshahsfc-gh-bli
authored andcommitted
SNOW-2343819: consolidate common deploy functionality, generate sha256 checksum files in deploy scripts (#245)
1. What Jira ticket or GitHub issue is this PR addressing? Make sure that there is a ticket or issue accompanying your PR. Fixes SNOW-2343819. 2. Fill out the following pre-review checklist: - [ ] I am adding a new automated test(s) to verify correctness of my new code - [ ] I am adding new logging messages - [ ] I am adding a new telemetry message - [ ] I am adding new credentials - [ ] I am adding a new dependency 3. Please describe how your code solves the related issue. Need `.sha256` checksum files for released artifacts as well. Updating deploy scripts to do so. See - https://snowflake.slack.com/archives/C054J469AN4/p1758085517918489 - snowflakedb/snowflake#337992
1 parent 46fe0de commit 003d57c

File tree

3 files changed

+124
-226
lines changed

3 files changed

+124
-226
lines changed

scripts/deploy-common.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash -ex
2+
#
3+
# DO NOT RUN DIRECTLY.
4+
# Script must be sourced by deploy.sh or deploy-fips.sh
5+
# after setting or unsetting `SNOWPARK_FIPS` environment variable.
6+
#
7+
8+
if [ -z "$GPG_KEY_ID" ]; then
9+
export GPG_KEY_ID="Snowflake Computing"
10+
echo "[WARN] GPG key ID not specified, using default: $GPG_KEY_ID."
11+
fi
12+
13+
if [ -z "$GPG_KEY_PASSPHRASE" ]; then
14+
echo "[ERROR] GPG passphrase is not specified for $GPG_KEY_ID!"
15+
exit 1
16+
fi
17+
18+
if [ -z "$GPG_PRIVATE_KEY" ]; then
19+
echo "[ERROR] GPG private key file is not specified!"
20+
exit 1
21+
fi
22+
23+
if [ -z "$sonatype_user" ]; then
24+
echo "[ERROR] Jenkins sonatype user is not specified!"
25+
exit 1
26+
fi
27+
28+
if [ -z "$sonatype_password" ]; then
29+
echo "[ERROR] Jenkins sonatype pwd is not specified!"
30+
exit 1
31+
fi
32+
33+
if [ -z "$PUBLISH" ]; then
34+
echo "[ERROR] 'PUBLISH' is not specified!"
35+
exit 1
36+
fi
37+
38+
if [ -z "$github_version_tag" ]; then
39+
echo "[ERROR] 'github_version_tag' is not specified!"
40+
exit 1
41+
fi
42+
43+
mkdir -p ~/.ivy2
44+
45+
STR=$'host=central.sonatype.com
46+
user='$sonatype_user'
47+
password='$sonatype_password''
48+
49+
echo "$STR" > ~/.ivy2/.credentials
50+
51+
# import private key first
52+
echo "[INFO] Importing PGP key."
53+
if [ ! -z "$GPG_PRIVATE_KEY" ] && [ -f "$GPG_PRIVATE_KEY" ]; then
54+
# First check if already imported private key
55+
if ! gpg --list-secret-key | grep "$GPG_KEY_ID"; then
56+
gpg --allow-secret-key-import --import "$GPG_PRIVATE_KEY"
57+
fi
58+
fi
59+
60+
which sbt
61+
if [ $? -ne 0 ]
62+
then
63+
pushd ..
64+
echo "[INFO] sbt is not installed, downloading latest sbt for test and build."
65+
curl -L -o sbt-1.11.4.zip https://github.com/sbt/sbt/releases/download/v1.11.4/sbt-1.11.4.zip
66+
unzip sbt-1.11.4.zip
67+
PATH=$PWD/sbt/bin:$PATH
68+
popd
69+
else
70+
echo "[INFO] Using system installed sbt."
71+
fi
72+
which sbt
73+
sbt version
74+
75+
echo "[INFO] Checking out snowpark-java-scala @ tag: $github_version_tag."
76+
git checkout $github_version_tag
77+
78+
if [ "$PUBLISH" = true ]; then
79+
if [ "$SNOWPARK_FIPS" = true ]; then
80+
echo "[INFO] Packaging snowpark-fips @ tag: $github_version_tag."
81+
else
82+
echo "[INFO] Packaging snowpark @ tag: $github_version_tag."
83+
fi
84+
sbt +publishSigned
85+
echo "[INFO] Staged packaged artifacts locally with PGP signing."
86+
sbt sonaUpload
87+
echo "[SUCCESS] Uploaded artifacts to central portal."
88+
echo "[ACTION-REQUIRED] Please log in to Central Portal to publish artifacts: https://central.sonatype.com/"
89+
# TODO: alternatively automate publishing fully
90+
# sbt sonaRelease
91+
# echo "[SUCCESS] Released Snowpark Java-Scala v$github_version_tag to Maven."
92+
else
93+
#release to s3
94+
echo "[INFO] Staging signed artifacts to local ivy2 repository."
95+
rm -rf ~/.ivy2/local/
96+
sbt +publishLocalSigned
97+
98+
# SBT will build FIPS version of Snowpark automatically if the environment variable exists.
99+
if [ "$SNOWPARK_FIPS" = true ]; then
100+
S3_JENKINS_URL="s3://sfc-eng-jenkins/repository/snowparkclient-fips"
101+
S3_DATA_URL="s3://sfc-eng-data/client/snowparkclient-fips/releases"
102+
echo "[INFO] Uploading snowpark-fips artifacts to:"
103+
else
104+
S3_JENKINS_URL="s3://sfc-eng-jenkins/repository/snowparkclient"
105+
S3_DATA_URL="s3://sfc-eng-data/client/snowparkclient/releases"
106+
echo "[INFO] Uploading snowpark artifacts to:"
107+
fi
108+
echo "[INFO] - $S3_JENKINS_URL/$github_version_tag/"
109+
echo "[INFO] - $S3_DATA_URL/$github_version_tag/"
110+
111+
# Rename all produced artifacts to include version number (sbt doesn't by default when publishing to local ivy2 repository).
112+
find ~/.ivy2/local -type f -name '*snowpark*' | while read file; do newfile=$(echo "$file" | sed "s/\(2\.1[23]\)\([-\.]\)/\1-${github_version_tag#v}\2/"); mv "$file" "$newfile"; done
113+
114+
# Generate sha256 checksums for all artifacts produced except .md5, .sha1, and existing .sha256 checksum files.
115+
find ~/.ivy2/local -type f -name '*snowpark*' ! -name '*.md5' ! -name '*.sha1' ! -name '*.sha256' -exec sh -c 'for f; do sha256sum "$f" | awk '"'"'{printf "%s", $1}'"'"' > "$f.sha256"; done' _ {} +
116+
117+
# Copy all files, flattening the nested structure of the ivy2 repository into the expected structure on s3.
118+
find ~/.ivy2/local -type f -name '*snowpark*' -exec aws s3 cp \{\} $S3_JENKINS_URL/$github_version_tag/ \;
119+
find ~/.ivy2/local -type f -name '*snowpark*' -exec aws s3 cp \{\} $S3_DATA_URL/$github_version_tag/ \;
120+
121+
echo "[SUCCESS] Published Snowpark Java-Scala v$github_version_tag artifacts to S3."
122+
fi

scripts/deploy-fips.sh

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -4,117 +4,5 @@
44
# This script needs to be executed by snowflake jenkins job.
55
#
66

7-
if [ -z "$GPG_KEY_ID" ]; then
8-
export GPG_KEY_ID="Snowflake Computing"
9-
echo "[WARN] GPG key ID not specified, using default: $GPG_KEY_ID."
10-
fi
11-
12-
if [ -z "$GPG_KEY_PASSPHRASE" ]; then
13-
echo "[ERROR] GPG passphrase is not specified for $GPG_KEY_ID!"
14-
exit 1
15-
fi
16-
17-
if [ -z "$GPG_PRIVATE_KEY" ]; then
18-
echo "[ERROR] GPG private key file is not specified!"
19-
exit 1
20-
fi
21-
22-
if [ -z "$sonatype_user" ]; then
23-
echo "[ERROR] Jenkins sonatype user is not specified!"
24-
exit 1
25-
fi
26-
27-
if [ -z "$sonatype_password" ]; then
28-
echo "[ERROR] Jenkins sonatype pwd is not specified!"
29-
exit 1
30-
fi
31-
32-
if [ -z "$PUBLISH" ]; then
33-
echo "[ERROR] 'PUBLISH' is not specified!"
34-
exit 1
35-
fi
36-
37-
if [ -z "$github_version_tag" ]; then
38-
echo "[ERROR] 'github_version_tag' is not specified!"
39-
exit 1
40-
fi
41-
42-
mkdir -p ~/.ivy2
43-
44-
STR=$'host=central.sonatype.com
45-
user='$sonatype_user'
46-
password='$sonatype_password''
47-
48-
echo "$STR" > ~/.ivy2/.credentials
49-
50-
# import private key first
51-
echo "[INFO] Importing PGP key."
52-
if [ ! -z "$GPG_PRIVATE_KEY" ] && [ -f "$GPG_PRIVATE_KEY" ]; then
53-
# First check if already imported private key
54-
if ! gpg --list-secret-key | grep "$GPG_KEY_ID"; then
55-
gpg --allow-secret-key-import --import "$GPG_PRIVATE_KEY"
56-
fi
57-
fi
58-
59-
which sbt
60-
if [ $? -ne 0 ]
61-
then
62-
pushd ..
63-
echo "[INFO] sbt is not installed, downloading latest sbt for test and build."
64-
curl -L -o sbt-1.11.4.zip https://github.com/sbt/sbt/releases/download/v1.11.4/sbt-1.11.4.zip
65-
unzip sbt-1.11.4.zip
66-
PATH=$PWD/sbt/bin:$PATH
67-
popd
68-
else
69-
echo "[INFO] Using system installed sbt."
70-
fi
71-
which sbt
72-
sbt version
73-
74-
echo "[INFO] Checking out snowpark-java-scala @ tag: $github_version_tag."
75-
git checkout $github_version_tag
76-
777
export SNOWPARK_FIPS="true"
78-
79-
if [ "$PUBLISH" = true ]; then
80-
if [ "$SNOWPARK_FIPS" = true ]; then
81-
echo "[INFO] Packaging snowpark-fips @ tag: $github_version_tag."
82-
else
83-
echo "[INFO] Packaging snowpark @ tag: $github_version_tag."
84-
fi
85-
sbt +publishSigned
86-
echo "[INFO] Staged packaged artifacts locally with PGP signing."
87-
sbt sonaUpload
88-
echo "[SUCCESS] Uploaded artifacts to central portal."
89-
echo "[ACTION-REQUIRED] Please log in to Central Portal to publish artifacts: https://central.sonatype.com/"
90-
# TODO: alternatively automate publishing fully
91-
# sbt sonaRelease
92-
# echo "[SUCCESS] Released Snowpark Java-Scala v$github_version_tag to Maven."
93-
else
94-
#release to s3
95-
echo "[INFO] Staging signed artifacts to local ivy2 repository."
96-
rm -rf ~/.ivy2/local/
97-
sbt +publishLocalSigned
98-
99-
# SBT will build FIPS version of Snowpark automatically if the environment variable exists.
100-
if [ -v SNOWPARK_FIPS ]; then
101-
S3_JENKINS_URL="s3://sfc-eng-jenkins/repository/snowparkclient-fips"
102-
S3_DATA_URL="s3://sfc-eng-data/client/snowparkclient-fips/releases"
103-
echo "[INFO] Uploading snowpark-fips artifacts to:"
104-
else
105-
S3_JENKINS_URL="s3://sfc-eng-jenkins/repository/snowparkclient"
106-
S3_DATA_URL="s3://sfc-eng-data/client/snowparkclient/releases"
107-
echo "[INFO] Uploading snowpark artifacts to:"
108-
fi
109-
echo "[INFO] - $S3_JENKINS_URL/$github_version_tag/"
110-
echo "[INFO] - $S3_DATA_URL/$github_version_tag/"
111-
112-
# Rename all produced artifacts to include version number (sbt doesn't by default when publishing to local ivy2 repository).
113-
find ~/.ivy2/local -type f -name "*snowpark*" | while read file; do newfile=$(echo "$file" | sed "s/\(2\.1[23]\)\([-\.]\)/\1-${github_version_tag#v}\2/"); mv "$file" "$newfile"; done
114-
115-
# Copy all files, flattening the nested structure of the ivy2 repository into the expected structure on s3.
116-
find ~/.ivy2/local -type f -name "*snowpark*" -exec aws s3 cp \{\} $S3_JENKINS_URL/$github_version_tag/ \;
117-
find ~/.ivy2/local -type f -name "*snowpark*" -exec aws s3 cp \{\} $S3_DATA_URL/$github_version_tag/ \;
118-
119-
echo "[SUCCESS] Published Snowpark Java-Scala v$github_version_tag artifacts to S3."
120-
fi
8+
source scripts/deploy-common.sh

scripts/deploy.sh

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -4,117 +4,5 @@
44
# This script needs to be executed by snowflake jenkins job.
55
#
66

7-
if [ -z "$GPG_KEY_ID" ]; then
8-
export GPG_KEY_ID="Snowflake Computing"
9-
echo "[WARN] GPG key ID not specified, using default: $GPG_KEY_ID."
10-
fi
11-
12-
if [ -z "$GPG_KEY_PASSPHRASE" ]; then
13-
echo "[ERROR] GPG passphrase is not specified for $GPG_KEY_ID!"
14-
exit 1
15-
fi
16-
17-
if [ -z "$GPG_PRIVATE_KEY" ]; then
18-
echo "[ERROR] GPG private key file is not specified!"
19-
exit 1
20-
fi
21-
22-
if [ -z "$sonatype_user" ]; then
23-
echo "[ERROR] Jenkins sonatype user is not specified!"
24-
exit 1
25-
fi
26-
27-
if [ -z "$sonatype_password" ]; then
28-
echo "[ERROR] Jenkins sonatype pwd is not specified!"
29-
exit 1
30-
fi
31-
32-
if [ -z "$PUBLISH" ]; then
33-
echo "[ERROR] 'PUBLISH' is not specified!"
34-
exit 1
35-
fi
36-
37-
if [ -z "$github_version_tag" ]; then
38-
echo "[ERROR] 'github_version_tag' is not specified!"
39-
exit 1
40-
fi
41-
42-
mkdir -p ~/.ivy2
43-
44-
STR=$'host=central.sonatype.com
45-
user='$sonatype_user'
46-
password='$sonatype_password''
47-
48-
echo "$STR" > ~/.ivy2/.credentials
49-
50-
# import private key first
51-
echo "[INFO] Importing PGP key."
52-
if [ ! -z "$GPG_PRIVATE_KEY" ] && [ -f "$GPG_PRIVATE_KEY" ]; then
53-
# First check if already imported private key
54-
if ! gpg --list-secret-key | grep "$GPG_KEY_ID"; then
55-
gpg --allow-secret-key-import --import "$GPG_PRIVATE_KEY"
56-
fi
57-
fi
58-
59-
which sbt
60-
if [ $? -ne 0 ]
61-
then
62-
pushd ..
63-
echo "[INFO] sbt is not installed, downloading latest sbt for test and build."
64-
curl -L -o sbt-1.11.4.zip https://github.com/sbt/sbt/releases/download/v1.11.4/sbt-1.11.4.zip
65-
unzip sbt-1.11.4.zip
66-
PATH=$PWD/sbt/bin:$PATH
67-
popd
68-
else
69-
echo "[INFO] Using system installed sbt."
70-
fi
71-
which sbt
72-
sbt version
73-
74-
echo "[INFO] Checking out snowpark-java-scala @ tag: $github_version_tag."
75-
git checkout $github_version_tag
76-
777
unset SNOWPARK_FIPS
78-
79-
if [ "$PUBLISH" = true ]; then
80-
if [ -v SNOWPARK_FIPS ]; then
81-
echo "[INFO] Packaging snowpark-fips @ tag: $github_version_tag."
82-
else
83-
echo "[INFO] Packaging snowpark @ tag: $github_version_tag."
84-
fi
85-
sbt +publishSigned
86-
echo "[INFO] Staged packaged artifacts locally with PGP signing."
87-
sbt sonaUpload
88-
echo "[SUCCESS] Uploaded artifacts to central portal."
89-
echo "[ACTION-REQUIRED] Please log in to Central Portal to publish artifacts: https://central.sonatype.com/"
90-
# TODO: alternatively automate publishing fully
91-
# sbt sonaRelease
92-
# echo "[SUCCESS] Released Snowpark Java-Scala v$github_version_tag to Maven."
93-
else
94-
#release to s3
95-
echo "[INFO] Staging signed artifacts to local ivy2 repository."
96-
rm -rf ~/.ivy2/local/
97-
sbt +publishLocalSigned
98-
99-
# SBT will build FIPS version of Snowpark automatically if the environment variable exists.
100-
if [ -v SNOWPARK_FIPS ]; then
101-
S3_JENKINS_URL="s3://sfc-eng-jenkins/repository/snowparkclient-fips"
102-
S3_DATA_URL="s3://sfc-eng-data/client/snowparkclient-fips/releases"
103-
echo "[INFO] Uploading snowpark-fips artifacts to:"
104-
else
105-
S3_JENKINS_URL="s3://sfc-eng-jenkins/repository/snowparkclient"
106-
S3_DATA_URL="s3://sfc-eng-data/client/snowparkclient/releases"
107-
echo "[INFO] Uploading snowpark artifacts to:"
108-
fi
109-
echo "[INFO] - $S3_JENKINS_URL/$github_version_tag/"
110-
echo "[INFO] - $S3_DATA_URL/$github_version_tag/"
111-
112-
# Rename all produced artifacts to include version number (sbt doesn't by default when publishing to local ivy2 repository).
113-
find ~/.ivy2/local -type f -name "*snowpark*" | while read file; do newfile=$(echo "$file" | sed "s/\(2\.1[23]\)\([-\.]\)/\1-${github_version_tag#v}\2/"); mv "$file" "$newfile"; done
114-
115-
# Copy all files, flattening the nested structure of the ivy2 repository into the expected structure on s3.
116-
find ~/.ivy2/local -type f -name "*snowpark*" -exec aws s3 cp \{\} $S3_JENKINS_URL/$github_version_tag/ \;
117-
find ~/.ivy2/local -type f -name "*snowpark*" -exec aws s3 cp \{\} $S3_DATA_URL/$github_version_tag/ \;
118-
119-
echo "[SUCCESS] Published Snowpark Java-Scala v$github_version_tag artifacts to S3."
120-
fi
8+
source scripts/deploy-common.sh

0 commit comments

Comments
 (0)