GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cas-parser-java/scripts/upload-artifacts at main · CASParser/cas-parser-java

Expand file tree

/

upload-artifacts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
194 lines (161 loc) · 6.1 KB
/

upload-artifacts

Copy path

File metadata and controls

executable file
·
194 lines (161 loc) · 6.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/env bash
set -euo pipefail
# ANSI Color Codes
GREEN='\033[32m'
RED='\033[31m'
NC='\033[0m' # No Color
MAVEN_REPO_PATH="./build/local-maven-repo"
log_error() {
local msg="$1"
local headers="$2"
local body="$3"
echo -e "${RED}${msg}${NC}"
[[ -f "$headers" ]] && echo -e "${RED}Headers:$(cat "$headers")${NC}"
echo -e "${RED}Body: ${body}${NC}"
exit 1
}
upload_file() {
local file_name="$1"
local tmp_headers
tmp_headers=$(mktemp)
if [ -f "$file_name" ]; then
echo -e "${GREEN}Processing file: $file_name${NC}"
pkg_file_name="mvn${file_name#"${MAVEN_REPO_PATH}"}"
# Get signed URL for uploading artifact file
signed_url_response=$(curl -X POST -G "$URL" \
-sS --retry 5 \
-D "$tmp_headers" \
--data-urlencode "filename=$pkg_file_name" \
-H "Authorization: Bearer $AUTH" \
-H "Content-Type: application/json")
# Validate JSON and extract URL
if ! signed_url=$(echo "$signed_url_response" | jq -e -r '.url' 2>/dev/null) || [[ "$signed_url" == "null" ]]; then
log_error "Failed to get valid signed URL" "$tmp_headers" "$signed_url_response"
fi
# Set content-type based on file extension
local extension="${file_name##*.}"
local content_type
case "$extension" in
jar) content_type="application/java-archive" ;;
md5|sha1|sha256|sha512) content_type="text/plain" ;;
module) content_type="application/json" ;;
pom|xml) content_type="application/xml" ;;
html) content_type="text/html" ;;
*) content_type="application/octet-stream" ;;
esac
# Upload file
upload_response=$(curl -v -X PUT \
--retry 5 \
--retry-all-errors \
-D "$tmp_headers" \
-H "Content-Type: $content_type" \
--data-binary "@${file_name}" "$signed_url" 2>&1)
if ! echo "$upload_response" | grep -q "HTTP/[0-9.]* 200"; then
log_error "Failed to upload artifact file" "$tmp_headers" "$upload_response"
fi
# Insert small throttle to reduce rate limiting risk
sleep 0.1
fi
}
walk_tree() {
local current_dir="$1"
for entry in "$current_dir"/*; do
# Check that entry is valid
[ -e "$entry" ] || [ -h "$entry" ] || continue
if [ -d "$entry" ]; then
walk_tree "$entry"
else
upload_file "$entry"
fi
done
}
generate_instructions() {
cat << EOF > "$MAVEN_REPO_PATH/index.html"
<!DOCTYPE html>
<html>
<head>
<title>Maven Repo</title>
<meta name="robots" content="noindex, nofollow">
</head>
<body>
<h1>Stainless SDK Maven Repository</h1>
<p>This is the Maven repository for your Stainless Java SDK build.</p>
<h2>Project configuration</h2>
<p>The details depend on whether you're using Maven or Gradle as your build tool.</p>
<h3>Maven</h3>
<p>Add the following to your project's <code>pom.xml</code>:</p>
<pre>&lt;repositories&gt;
&lt;repository&gt;
&lt;id&gt;stainless-sdk-repo&lt;/id&gt;
&lt;url&gt;https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn&lt;/url&gt;
&lt;/repository&gt;
&lt;/repositories&gt;</pre>
<h3>Gradle</h3>
<p>Add the following to your <code>build.gradle</code> file:</p>
<pre>repositories {
maven {
url "https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn"
}
}</pre>
<details>
<summary><h3 style="display:inline-block">Configuring authentication (if required)<h3></summary>
<p>Some accounts may require authentication to access the repository. If so, use the
following instructions, replacing <code>YOUR_STAINLESS_API_TOKEN</code> with your actual token.</p>
<h3>Maven with authentication</h3>
<p>First, ensure you have the following in your Maven <code>settings.xml</code> for repo authentication:</p>
<pre>&lt;servers&gt;
&lt;server&gt;
&lt;id&gt;stainless-sdk-repo&lt;/id&gt;
&lt;configuration&gt;
&lt;httpHeaders&gt;
&lt;property&gt;
&lt;name&gt;Authorization&lt;/name&gt;
&lt;value&gt;Bearer YOUR_STAINLESS_API_TOKEN&lt;/value&gt;
&lt;/property&gt;
&lt;/httpHeaders&gt;
&lt;/configuration&gt;
&lt;/server&gt;
&lt;/servers&gt;</pre>
<p>Then, add the following to your project's <code>pom.xml</code>:</p>
<pre>&lt;repositories&gt;
&lt;repository&gt;
&lt;id&gt;stainless-sdk-repo&lt;/id&gt;
&lt;url&gt;https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn&lt;/url&gt;
&lt;/repository&gt;
&lt;/repositories&gt;</pre>
<h3>Gradle with authentication</h3>
<p>Add the following to your <code>build.gradle</code> file:</p>
<pre>repositories {
maven {
url "https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn"
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = "Bearer YOUR_STAINLESS_API_TOKEN"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}</pre>
</details>
<h2>Using the repository</h2>
<p>Once you've configured the repository, you can include dependencies from it as usual. See your
<a href="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA}/README.md">project README</a>
for more details.</p>
</body>
</html>
EOF
upload_file "${MAVEN_REPO_PATH}/index.html"
echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'"
echo "For more details, see the directions in https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn/index.html"
}
cd "$(dirname "$0")/.."
echo "::group::Creating local Maven content"
./gradlew publishMavenPublicationToLocalFileSystemRepository -PpublishLocal
echo "::endgroup::"
echo "::group::Uploading to pkg.stainless.com"
walk_tree "$MAVEN_REPO_PATH"
echo "::endgroup::"
echo "::group::Generating instructions"
generate_instructions
echo "::endgroup::"
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.