@@ -82,3 +82,76 @@ download_dependency_wheels:
8282 artifacts :
8383 paths :
8484 - " pywheels-dep/"
85+
86+ publish-wheels-to-s3 :
87+ tags : ["arch:amd64"]
88+ image : registry.ddbuild.io/images/mirror/amazon/aws-cli:2.4.29
89+ stage : package
90+ rules :
91+ - when : always
92+ needs :
93+ - job : download_ddtrace_artifacts
94+ artifacts : true
95+ - job : compute_library_version
96+ artifacts : true
97+ variables :
98+ BUCKET : dd-trace-py-builds
99+ script :
100+ - set -euo pipefail
101+ - shopt -s nullglob
102+ # Find wheels
103+ - WHEELS=(pywheels/*.whl)
104+ - |
105+ if [ ${#WHEELS[@]} -eq 0 ]; then
106+ echo "No wheels found in pywheels/"; exit 1
107+ fi
108+ - echo "Found ${#WHEELS[@]} wheel(s):"
109+ - printf ' - %s\n' "${WHEELS[@]}"
110+
111+ - |
112+ if [ -f library-version/version.txt ]; then
113+ VERSION="$(tr -d '\r\n' < library-version/version.txt)"
114+ fi
115+
116+ if [ -z "${VERSION:-}" ]; then
117+ echo "ERROR: VERSION is not defined or library-version/version.txt missing!"
118+ exit 1
119+ fi
120+
121+ - printf 'Detected version %s\n' ${VERSION}
122+
123+ # Upload all wheels to versioned prefix and pipeline-id prefix
124+ - aws s3 cp --recursive --exclude "*" --include "*.whl" pywheels "s3://${BUCKET}/${VERSION}/"
125+ - aws s3 cp --recursive --exclude "*" --include "*.whl" pywheels "s3://${BUCKET}/${CI_PIPELINE_ID}/"
126+
127+ - |
128+ VERSION_ENC="${VERSION//+/%2B}"
129+ S3_BASE_VER="https://${BUCKET}.s3.amazonaws.com/${VERSION_ENC}"
130+ S3_BASE_PIPE="https://${BUCKET}.s3.amazonaws.com/${CI_PIPELINE_ID}"
131+
132+ generate_index_html() {
133+ local outfile="$1"
134+ {
135+ echo "<html><body>"
136+ for w in "${WHEELS[@]}"; do
137+ fname="$(basename "$w")"
138+ enc_fname="${fname//+/%2B}"
139+ echo "<a href=\"${enc_fname}\">${fname}</a><br>"
140+ done
141+ echo "</body></html>"
142+ } > "${outfile}"
143+ }
144+
145+ # Generate both minimal indexes
146+ generate_index_html "index.version.html"
147+ generate_index_html "index.pipeline.html"
148+
149+ # Upload to each S3 prefix
150+ aws s3 cp "index.version.html" "s3://${BUCKET}/${VERSION}/index.html" --content-type text/html
151+ aws s3 cp "index.pipeline.html" "s3://${BUCKET}/${CI_PIPELINE_ID}/index.html" --content-type text/html
152+
153+ # Print the clickable URLs
154+ VER_INDEX_URL="${S3_BASE_VER}/index.html"
155+ PIPE_INDEX_URL="${S3_BASE_PIPE}/index.html"
156+ echo "S3 index (version): ${VER_INDEX_URL}"
157+ echo "S3 index (pipeline): ${PIPE_INDEX_URL}"
0 commit comments