diff --git a/.github/workflows/publish-to-aws.yaml b/.github/workflows/publish-to-aws.yaml index ce28d28..d763226 100644 --- a/.github/workflows/publish-to-aws.yaml +++ b/.github/workflows/publish-to-aws.yaml @@ -35,8 +35,41 @@ jobs: - name: Get package version id: get_version run: | - chmod +x ./scripts/get_version.sh - VERSION=$(./scripts/get_version.sh) + echo "Current working directory:" + pwd + echo "Listing files:" + ls -la + + echo "Checking if version file exists..." + if [ -f "src/atlas/_version.py" ]; then + echo "Version file found:" + cat src/atlas/_version.py + + # Extract version directly + VERSION=$(grep -E '^__version__\s*=' src/atlas/_version.py | grep -o '".*"' | tr -d '"') + echo "Direct extraction result: '$VERSION'" + else + echo "Version file not found, trying script method..." + fi + + # Fallback to script method if direct extraction failed + if [ -z "$VERSION" ]; then + echo "Trying script method..." + chmod +x ./scripts/get_version.sh + ls -la ./scripts/get_version.sh + VERSION=$(./scripts/get_version.sh 2>&1) + echo "Script output: '$VERSION'" + + # Extract just the version (last line) in case there's debug output + VERSION=$(echo "$VERSION" | tail -n 1) + fi + + if [ -z "$VERSION" ]; then + echo "Error: Could not extract version" + exit 1 + fi + + echo "Final version: '$VERSION'" echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "Package version: $VERSION" @@ -60,24 +93,58 @@ jobs: 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 + aws s3 ls s3://${{ secrets.S3_BUCKET_NAME }}/versions/ 2>/dev/null > existing_versions.txt || echo "" > existing_versions.txt + + # Extract version numbers from S3 listing + EXISTING_VERSIONS="" + if [ -s existing_versions.txt ]; then + EXISTING_VERSIONS=$(awk '{print $2}' existing_versions.txt | sed 's/\///g' | grep -v '^$' | sort -V || true) + fi - # 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 }}" + echo "Current version: $CURRENT_VERSION" + echo "Existing versions from S3: $EXISTING_VERSIONS" + + # Validate current version is not empty + if [ -z "$CURRENT_VERSION" ]; then + echo "Error: Current version is empty" + exit 1 + fi # Combine existing and current versions, remove duplicates, and sort - ALL_VERSIONS=$(echo -e "$VERSIONS\n$CURRENT_VERSION" | sort -V | uniq) + if [ -z "$EXISTING_VERSIONS" ]; then + ALL_VERSIONS="$CURRENT_VERSION" + else + ALL_VERSIONS=$(echo -e "$EXISTING_VERSIONS\n$CURRENT_VERSION" | sort -V | uniq | grep -v '^$' || echo "$CURRENT_VERSION") + fi echo "Available versions:" echo "$ALL_VERSIONS" - # Save for use in HTML generation - echo "$ALL_VERSIONS" > all_versions.txt + # Save for use in HTML generation (ensure no empty lines) + if [ -n "$ALL_VERSIONS" ]; then + echo "$ALL_VERSIONS" | grep -v '^$' > all_versions.txt || echo "$ALL_VERSIONS" > all_versions.txt + else + echo "$CURRENT_VERSION" > all_versions.txt + fi + + # Format for JSON array (for potential future use) - simplified approach + VERSIONS_JSON="[" + FIRST=true + while IFS= read -r version; do + if [ -n "$version" ]; then + if [ "$FIRST" = true ]; then + VERSIONS_JSON="$VERSIONS_JSON\"$version\"" + FIRST=false + else + VERSIONS_JSON="$VERSIONS_JSON,\"$version\"" + fi + fi + done < all_versions.txt + VERSIONS_JSON="$VERSIONS_JSON]" - # Format for JSON array (for potential future use) - VERSIONS_JSON=$(echo "$ALL_VERSIONS" | jq -R . | jq -s .) echo "VERSIONS_JSON=$VERSIONS_JSON" >> $GITHUB_OUTPUT + echo "Generated JSON: $VERSIONS_JSON" - name: Copy package files to simple index (all versions) run: |