Skip to content

Commit 2c9d1ae

Browse files
committed
Ensure unicity of S3 path
1 parent ee483ca commit 2c9d1ae

File tree

4 files changed

+54
-26
lines changed

4 files changed

+54
-26
lines changed

.github/workflows/cleanup_pypi.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,15 @@ jobs:
6060
uv run --no-sync -s scripts/pypi_cleanup.py ${{ inputs.dry-run && '--dry' || '' }} \
6161
--index-hostname "${{ vars.PYPI_HOST }}" \
6262
--username "${{ vars.PYPI_CLEANUP_USERNAME }}" \
63-
--max-nightlies ${{ vars.PYPI_MAX_NIGHTLIES }}
63+
--max-nightlies ${{ vars.PYPI_MAX_NIGHTLIES }} > cleanup_output 2>&1
64+
65+
- name: PyPI Cleanup Summary
66+
run : |
67+
echo "## PyPI Cleanup Summary" >> $GITHUB_STEP_SUMMARY
68+
echo "* Dry run: ${{ inputs.dry-run }}" >> $GITHUB_STEP_SUMMARY
69+
echo "* PyPI Host: ${{ vars.PYPI_HOST }}" >> $GITHUB_STEP_SUMMARY
70+
echo "* CI Environment: " >> $GITHUB_STEP_SUMMARY
71+
echo "* Output:" >> $GITHUB_STEP_SUMMARY
72+
echo '```' >> $GITHUB_STEP_SUMMARY
73+
cat cleanup_output >> $GITHUB_STEP_SUMMARY
74+
echo '```' >> $GITHUB_STEP_SUMMARY

.github/workflows/on_external_dispatch.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
upload_s3:
8181
name: Upload Artifacts to the S3 Staging Bucket
8282
runs-on: ubuntu-latest
83-
needs: externally_triggered_build
83+
needs: [commit_submodule, externally_triggered_build]
8484
outputs:
8585
version: ${{ steps.s3_upload.outputs.version }}
8686
if: ${{ github.repository_owner == 'duckdb' && inputs.publish-packages }}
@@ -102,15 +102,24 @@ jobs:
102102
- name: Upload Artifacts
103103
id: s3_upload
104104
run: |
105-
version=$(basename artifacts/*.tar.gz | sed 's/duckdb-\(.*\).tar.gz/\1/g')
106-
aws s3 cp artifacts s3://duckdb-staging/${{ github.repository }}/${version}/ --recursive
105+
sha=${{ needs.commit_submodule.outputs.sha-after-commit }}
106+
aws s3 cp artifacts s3://duckdb-staging/${{ github.repository }}/${sha:0:10}/ --recursive
107107
echo "version=${version}" >> $GITHUB_OUTPUT
108108
109+
- name: S3 Upload Summary
110+
run : |
111+
sha=${{ needs.commit_submodule.outputs.sha-after-commit }}
112+
version=$(basename artifacts/*.tar.gz | sed 's/duckdb-\(.*\).tar.gz/\1/g')
113+
echo "## S3 Upload Summary" >> $GITHUB_STEP_SUMMARY
114+
echo "* Version: ${version}" >> $GITHUB_STEP_SUMMARY
115+
echo "* SHA: ${sha:0:10}" >> $GITHUB_STEP_SUMMARY
116+
echo "* S3 URL: s3://duckdb-staging/${{ github.repository }}/${sha:0:10}/" >> $GITHUB_STEP_SUMMARY
117+
109118
publish_to_pypi:
110119
name: Upload Artifacts to PyPI
111-
needs: upload_s3
120+
needs: [ commit_submodule, upload_s3 ]
112121
if: ${{ force-version == '' }}
113122
uses: ./.github/workflows/upload_to_pypi.yml
114123
with:
115-
version: ${{ needs.upload_s3.outputs.version }}
116-
environment: pypi.production
124+
sha: ${{ needs.commit_submodule.outputs.sha-after-commit }}
125+
environment: pypi.production

.github/workflows/upload_to_pypi.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
description: CI environment to run in (test.pypi or production.pypi)
77
type: string
88
required: true
9-
version:
10-
description: The version to upload (must be present in the S3 staging bucket)
9+
sha:
10+
description: The SHA of the commit that the packages were built from
1111
type: string
1212
required: true
1313
workflow_dispatch:
@@ -20,13 +20,13 @@ on:
2020
options:
2121
- test.pypi
2222
- production.pypi
23-
version:
24-
description: The version to upload (must be present in the S3 staging bucket)
23+
sha:
24+
description: The SHA of the commit that the packages were built from
2525
type: string
2626
required: true
2727

2828
concurrency:
29-
group: ${{ inputs.version }}
29+
group: ${{ inputs.sha }}
3030
cancel-in-progress: true
3131

3232
jobs:
@@ -53,7 +53,7 @@ jobs:
5353

5454
- name: Download Artifacts From S3
5555
env:
56-
S3_URL: 's3://duckdb-staging/${{ github.repository }}/${{ inputs.version }}/'
56+
S3_URL: 's3://duckdb-staging/${{ github.repository }}/${{ inputs.sha }}/'
5757
AWS_ACCESS_KEY_ID: ${{ secrets.S3_DUCKDB_STAGING_ID }}
5858
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DUCKDB_STAGING_KEY }}
5959
run: |
@@ -66,6 +66,14 @@ jobs:
6666
repository-url: 'https://${{ vars.PYPI_HOST }}/legacy/'
6767
packages-dir: packages
6868

69+
- name: PyPI Upload Summary
70+
run : |
71+
version=$(basename packages/*.tar.gz | sed 's/duckdb-\(.*\).tar.gz/\1/g')
72+
echo "## PyPI Upload Summary" >> $GITHUB_STEP_SUMMARY
73+
echo "* Version: ${version}" >> $GITHUB_STEP_SUMMARY
74+
echo "* PyPI Host: ${{ vars.PYPI_HOST }}" >> $GITHUB_STEP_SUMMARY
75+
echo "* CI Environment: ${{ inputs.environment }}" >> $GITHUB_STEP_SUMMARY
76+
6977
cleanup_nightlies:
7078
name: Remove Nightlies from PyPI
7179
needs: publish-pypi

scripts/pypi_cleanup.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ def run(self):
185185
sorted_versions = sorted(versions, key=lambda x: int(x.split('dev')[-1]))
186186
pkg_vers.extend(sorted_versions[:-self.max_dev_releases])
187187

188+
print("Following pkg_vers can be deleted: ", pkg_vers)
188189
if not self.do_it:
189-
print("Following pkg_vers can be deleted: ", pkg_vers)
190190
return
191191

192192
if not pkg_vers:
@@ -231,9 +231,9 @@ def run(self):
231231

232232
two_factor = False
233233
with s.post(
234-
f"{self.url}/account/login/",
235-
data={"csrf_token": csrf, "username": self.username, "password": self.password},
236-
headers={"referer": f"{self.url}/account/login/"},
234+
f"{self.url}/account/login/",
235+
data={"csrf_token": csrf, "username": self.username, "password": self.password},
236+
headers={"referer": f"{self.url}/account/login/"},
237237
) as r:
238238
r.raise_for_status()
239239
if r.url == f"{self.url}/account/login/":
@@ -255,9 +255,9 @@ def run(self):
255255
for i in range(3):
256256
auth_code = pyotp.TOTP(self.otp).now()
257257
with s.post(
258-
two_factor_url,
259-
data={"csrf_token": csrf, "method": "totp", "totp_value": auth_code},
260-
headers={"referer": two_factor_url},
258+
two_factor_url,
259+
data={"csrf_token": csrf, "method": "totp", "totp_value": auth_code},
260+
headers={"referer": two_factor_url},
261261
) as r:
262262
r.raise_for_status()
263263
if r.url == two_factor_url:
@@ -286,12 +286,12 @@ def run(self):
286286
referer = r.url
287287

288288
with s.post(
289-
form_url,
290-
data={
291-
"csrf_token": csrf,
292-
"confirm_delete_version": pkg_ver,
293-
},
294-
headers={"referer": referer},
289+
form_url,
290+
data={
291+
"csrf_token": csrf,
292+
"confirm_delete_version": pkg_ver,
293+
},
294+
headers={"referer": referer},
295295
) as r:
296296
r.raise_for_status()
297297

0 commit comments

Comments
 (0)