From 576f63c5965a4a8b473a8437ec2e327fcd66f845 Mon Sep 17 00:00:00 2001 From: Leandro Echevarria Date: Mon, 25 Aug 2025 15:18:43 -0300 Subject: [PATCH] feat | LAY-917 Storing all sdk versions --- .github/workflows/publish-to-aws.yaml | 140 +++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-to-aws.yaml b/.github/workflows/publish-to-aws.yaml index 6234b8a..ce28d28 100644 --- a/.github/workflows/publish-to-aws.yaml +++ b/.github/workflows/publish-to-aws.yaml @@ -50,11 +50,48 @@ jobs: - name: Create package directory structure run: | mkdir -p upload/simple/${{ env.PACKAGE_NAME }} + mkdir -p upload/versions/${{ steps.get_version.outputs.VERSION }} - - name: Copy package files + - name: Copy package files to version-specific folder run: | + cp dist/* upload/versions/${{ steps.get_version.outputs.VERSION }}/ + + - name: List existing versions from S3 + id: list_versions + run: | + # Get existing versions from S3 (ignore errors if bucket is empty) + aws s3 ls s3://${{ secrets.S3_BUCKET_NAME }}/versions/ || true > existing_versions.txt + + # Extract version numbers and add current version + VERSIONS=$(awk '{print $2}' existing_versions.txt | sed 's/\///g' | sort -V) + CURRENT_VERSION="${{ steps.get_version.outputs.VERSION }}" + + # Combine existing and current versions, remove duplicates, and sort + ALL_VERSIONS=$(echo -e "$VERSIONS\n$CURRENT_VERSION" | sort -V | uniq) + + echo "Available versions:" + echo "$ALL_VERSIONS" + + # Save for use in HTML generation + echo "$ALL_VERSIONS" > all_versions.txt + + # Format for JSON array (for potential future use) + VERSIONS_JSON=$(echo "$ALL_VERSIONS" | jq -R . | jq -s .) + echo "VERSIONS_JSON=$VERSIONS_JSON" >> $GITHUB_OUTPUT + + - name: Copy package files to simple index (all versions) + run: | + # Copy current version to simple index cp dist/* upload/simple/${{ env.PACKAGE_NAME }}/ + # Download and copy existing versions from S3 + while IFS= read -r version; do + if [ ! -z "$version" ] && [ "$version" != "${{ steps.get_version.outputs.VERSION }}" ]; then + echo "Downloading version $version" + aws s3 sync s3://${{ secrets.S3_BUCKET_NAME }}/versions/$version/ upload/simple/${{ env.PACKAGE_NAME }}/ || echo "Version $version not found in S3" + fi + done < all_versions.txt + - name: Generate package index HTML run: | cat > upload/simple/${{ env.PACKAGE_NAME }}/index.html << EOF @@ -65,6 +102,7 @@ jobs:

Links for ${{ env.PACKAGE_NAME }}

+

View all versions

EOF for file in upload/simple/${{ env.PACKAGE_NAME }}/*.{tar.gz,whl}; do @@ -76,6 +114,70 @@ jobs: echo "" >> upload/simple/${{ env.PACKAGE_NAME }}/index.html + - name: Generate versions page HTML + run: | + cat > upload/versions.html << EOF + + + + All Versions of ${{ env.PACKAGE_NAME }} + + + +

All Versions of ${{ env.PACKAGE_NAME }}

+

Available versions of the ${{ env.PACKAGE_NAME }} package.

+ +
+ Install latest: pip install ${{ env.PACKAGE_NAME }} --index-url https://${{ secrets.CLOUDFRONT_DOMAIN }}/simple/
+ Install specific version: pip install ${{ env.PACKAGE_NAME }}==VERSION --index-url https://${{ secrets.CLOUDFRONT_DOMAIN }}/simple/ +
+ EOF + + # Generate version listings + while IFS= read -r version; do + if [ ! -z "$version" ]; then + echo "Processing version: $version" + + # Check if this is the current version + CURRENT_CLASS="" + if [ "$version" = "${{ steps.get_version.outputs.VERSION }}" ]; then + CURRENT_CLASS=" current" + fi + + cat >> upload/versions.html << EOF +
+

Version $version

+ EOF + + if [ "$version" = "${{ steps.get_version.outputs.VERSION }}" ]; then + echo "

(Current/Latest Version)

" >> upload/versions.html + fi + + echo "
" >> upload/versions.html + echo " Available files:
" >> upload/versions.html + + # List files for this version + for file in upload/versions/$version/*.{tar.gz,whl}; do + if [ -f "$file" ]; then + filename=$(basename "$file") + echo " $filename
" >> upload/versions.html + fi + done + + echo "
" >> upload/versions.html + echo "
" >> upload/versions.html + fi + done < all_versions.txt + + echo "" >> upload/versions.html + - name: Generate main simple index run: | cat > upload/simple/index.html << EOF @@ -98,20 +200,50 @@ jobs: LayerLens Python Package Repository +

LayerLens Python Package Repository

Custom Python package repository for ${{ env.PACKAGE_NAME }}

-

Browse packages

+ + +

Installation

-
pip install ${{ env.PACKAGE_NAME }} --index-url https://${{ secrets.CLOUDFRONT_DOMAIN }}/simple/
+
+ # Install latest version
+ pip install ${{ env.PACKAGE_NAME }} --index-url https://${{ secrets.CLOUDFRONT_DOMAIN }}/simple/

+ + # Install specific version
+ pip install ${{ env.PACKAGE_NAME }}==1.0.0 --index-url https://${{ secrets.CLOUDFRONT_DOMAIN }}/simple/ +
+ +

Current Version

+

Latest version: ${{ steps.get_version.outputs.VERSION }}

EOF - name: Upload to S3 run: | - aws s3 sync upload/ s3://${{ secrets.S3_BUCKET_NAME }}/ --delete + # Upload everything except we don't want to delete old versions + # Upload the simple index (with --delete to clean up old files) + aws s3 sync upload/simple/ s3://${{ secrets.S3_BUCKET_NAME }}/simple/ --delete + + # Upload version-specific files (without --delete to preserve old versions) + aws s3 sync upload/versions/ s3://${{ secrets.S3_BUCKET_NAME }}/versions/ + + # Upload main pages (index.html, versions.html) + aws s3 cp upload/index.html s3://${{ secrets.S3_BUCKET_NAME }}/index.html + aws s3 cp upload/versions.html s3://${{ secrets.S3_BUCKET_NAME }}/versions.html - name: Invalidate CloudFront cache run: |