Skip to content

Commit 7838ba8

Browse files
chore(internal): clean up maven repo artifact script and add html documentation to repo root
1 parent e4de24f commit 7838ba8

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

scripts/upload-artifacts

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ GREEN='\033[32m'
77
RED='\033[31m'
88
NC='\033[0m' # No Color
99

10+
MAVEN_REPO_PATH="./build/local-maven-repo"
11+
1012
log_error() {
1113
local msg="$1"
1214
local headers="$2"
@@ -24,7 +26,7 @@ upload_file() {
2426

2527
if [ -f "$file_name" ]; then
2628
echo -e "${GREEN}Processing file: $file_name${NC}"
27-
pkg_file_name="mvn${file_name#./build/local-maven-repo}"
29+
pkg_file_name="mvn${file_name#"${MAVEN_REPO_PATH}"}"
2830

2931
# Get signed URL for uploading artifact file
3032
signed_url_response=$(curl -X POST -G "$URL" \
@@ -47,6 +49,7 @@ upload_file() {
4749
md5|sha1|sha256|sha512) content_type="text/plain" ;;
4850
module) content_type="application/json" ;;
4951
pom|xml) content_type="application/xml" ;;
52+
html) content_type="text/html" ;;
5053
*) content_type="application/octet-stream" ;;
5154
esac
5255

@@ -81,16 +84,51 @@ walk_tree() {
8184
done
8285
}
8386

87+
generate_instructions() {
88+
cat << EOF > "$MAVEN_REPO_PATH/index.html"
89+
<!DOCTYPE html>
90+
<html>
91+
<head>
92+
<title>Maven Repo</title>
93+
</head>
94+
<body>
95+
<h1>Stainless SDK Maven Repository</h1>
96+
<p>This is the Maven repository for your Stainless Java SDK build.</p>
97+
98+
<h1>Directions</h1>
99+
<p>To use the uploaded Maven repository, add the following to your project's <code>pom.xml</code>:</p>
100+
<pre>&lt;repositories&gt;
101+
&lt;repository&gt;
102+
&lt;id&gt;stainless-sdk-repo&lt;/id&gt;
103+
&lt;url&gt;https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn&lt;/url&gt;
104+
&lt;/repository&gt;
105+
&lt;/repositories&gt;</pre>
106+
107+
<p>If you're using Gradle, add the following to your <code>build.gradle</code> file:</p>
108+
<pre>repositories {
109+
maven {
110+
url 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'
111+
}
112+
}</pre>
113+
</body>
114+
</html>
115+
EOF
116+
upload_file "${MAVEN_REPO_PATH}/index.html"
117+
118+
echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'"
119+
echo "For more details, see the directions in https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn/index.html"
120+
}
121+
84122
cd "$(dirname "$0")/.."
85123

86124
echo "::group::Creating local Maven content"
87125
./gradlew publishMavenPublicationToLocalFileSystemRepository -PpublishLocal
88126
echo "::endgroup::"
89127

90128
echo "::group::Uploading to pkg.stainless.com"
91-
walk_tree "./build/local-maven-repo"
129+
walk_tree "$MAVEN_REPO_PATH"
92130
echo "::endgroup::"
93131

94132
echo "::group::Generating instructions"
95-
echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'"
133+
generate_instructions
96134
echo "::endgroup::"

0 commit comments

Comments
 (0)