diff --git a/.github/actions/build-website/action.yml b/.github/actions/build-website/action.yml index 83674f4ac..d296a1d99 100644 --- a/.github/actions/build-website/action.yml +++ b/.github/actions/build-website/action.yml @@ -59,24 +59,46 @@ runs: run: | make init - # Download pre-built library docs from the latest GitHub Release - # The generate-library.yml workflow must have run at least once + # Download pre-built library docs from draft release or latest published release - name: "Download Pre-built Library Docs" shell: bash env: GH_TOKEN: ${{ inputs.repo_access_token }} run: | - echo "Finding latest library-docs release..." - LATEST_TAG=$(gh release list --repo ${{ github.repository }} --limit 50 | grep "library-docs-" | head -1 | awk -F'\t' '{print $3}') - if [ -z "$LATEST_TAG" ]; then - echo "Error: No library-docs release found. Run the 'Generate Library' workflow first." - exit 1 + DOWNLOADED=false + + # Try draft release first + echo "Checking for draft release..." + DRAFT_TAG=$(gh release list --repo ${{ github.repository }} --exclude-drafts=false --limit 20 | { grep "Draft" || true; } | head -1 | awk -F'\t' '{print $3}') + + if [ -n "$DRAFT_TAG" ]; then + echo "Found draft release: ${DRAFT_TAG}" + if gh release download "${DRAFT_TAG}" \ + --repo ${{ github.repository }} \ + --pattern "library-docs.tar.gz" \ + --dir /tmp 2>/dev/null; then + echo "Downloaded library docs from draft release" + DOWNLOADED=true + else + echo "Draft release exists but has no library-docs.tar.gz asset" + fi + else + echo "No draft release found" fi - echo "Downloading from release: ${LATEST_TAG}" - gh release download "${LATEST_TAG}" \ - --repo ${{ github.repository }} \ - --pattern "library-docs.tar.gz" \ - --dir /tmp + + # Fall back to latest published release + if [ "$DOWNLOADED" = false ]; then + echo "Downloading from latest published release..." + if ! gh release download \ + --repo ${{ github.repository }} \ + --pattern "library-docs.tar.gz" \ + --dir /tmp; then + echo "Error: No library-docs.tar.gz found in any release. Run the 'Generate Library' workflow first." + exit 1 + fi + echo "Downloaded library docs from latest published release" + fi + echo "Extracting library docs..." tar -xzf /tmp/library-docs.tar.gz echo "Library docs downloaded and extracted successfully" diff --git a/.github/workflows/generate-library.yml b/.github/workflows/generate-library.yml index e50773da2..cd0eca19b 100644 --- a/.github/workflows/generate-library.yml +++ b/.github/workflows/generate-library.yml @@ -216,27 +216,19 @@ jobs: docs/modules/library \ docs/github-actions/library - - name: Create Release + - name: Upload to Draft Release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - VERSION="0.0.$(date -u +'%Y%m%d%H%M%S')" - gh release create "library-docs-${VERSION}" \ - --title "Library Docs ${VERSION}" \ - --notes "Pre-built library documentation for fast preview builds. Generated $(date -u +'%Y-%m-%d %H:%M:%S UTC')." \ - library-docs.tar.gz - - - name: Cleanup Old Releases - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - echo "Cleaning up old library-docs releases (keeping last 5)..." - gh release list --repo ${{ github.repository }} --limit 100 \ - | grep "library-docs-" \ - | tail -n +6 \ - | awk '{print $1}' \ - | while read tag; do - echo "Deleting release: ${tag}" - gh release delete "${tag}" --yes --cleanup-tag || true - done - echo "Cleanup complete" + echo "Finding draft release..." + DRAFT_TAG=$(gh release list --exclude-drafts=false --limit 20 | { grep "Draft" || true; } | head -1 | awk -F'\t' '{print $3}') + + if [ -z "$DRAFT_TAG" ]; then + echo "No draft release found. Library docs will be uploaded when a draft release is created (on next PR merge)." + echo "Skipping upload." + exit 0 + fi + + echo "Uploading library-docs.tar.gz to draft release: ${DRAFT_TAG}" + gh release upload "${DRAFT_TAG}" library-docs.tar.gz --clobber + echo "Upload complete"