Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE] Generate S3 manifests #1732

Merged
merged 3 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/build-artifact-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,22 @@ jobs:
- name: Copy all files as zip for Glue
run: for file in dist/*.whl; do cp $file dist/`basename $file .whl`.zip; done
- name: Upload files to s3
run: for file in dist/*; do aws s3 cp $file s3://github-actions-artifacts-bucket/daft-build-artifact-s3/${{ github.sha }}/ --no-progress; done


run: for file in dist/*; do aws s3 cp $file s3://github-actions-artifacts-bucket/daft-build-artifact-s3/${{ github.sha }}/ --acl public-read --no-progress; done

list-wheels:
name: List Wheels and Zip files Published to S3
runs-on: ubuntu-latest
needs:
- build-and-push

concurrency:
group: GenerateManifestS3
cancel-in-progress: false
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4

- name: Assume GitHub Actions AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -92,3 +94,7 @@ jobs:
role-session-name: DaftPythonPackageGitHubWorkflow
- name: List Wheels
run: aws s3 ls s3://github-actions-artifacts-bucket/daft-build-artifact-s3/${{ github.sha }}/
- name: install boto3
run: pip3 install boto3
- name: Generate New Manifest
run: python3 tools/generate_whl_html_manifest.py
53 changes: 53 additions & 0 deletions tools/generate_whl_html_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from __future__ import annotations

import boto3

s3 = boto3.client("s3")

all_objects = []

paginator = s3.get_paginator("list_objects_v2")
pages = paginator.paginate(Bucket="github-actions-artifacts-bucket")

for page in pages:
for obj in page["Contents"]:
all_objects.append(obj)

all_wheels = [obj["Key"] for obj in all_objects if obj["Key"].endswith(".whl")]

html_href = []

for key in all_wheels:
name = key.split("/")[-1]
link = key.replace("+", "%2B")
href = f" <a href='../{link}'>{name} </a>"
html_href.append(href)
html_href.append(" <br />")

html_href.pop()

all_href = "\n".join(h for h in html_href)

manifest = f"""<html>
<head>
<title>Links</title>
</head>
<body>
<h1>Links</h1>
{all_href}
</body>
</html>"""


with open("index.html", "w") as f:
f.write(manifest)

s3.upload_file(
"index.html",
Bucket="github-actions-artifacts-bucket",
Key="getdaft/index.html",
ExtraArgs={"ACL": "public-read", "ContentType": "text/html"},
)

print("uploaded:")
print(manifest)
Loading