From ffcd0f48aac36c84bb0b117ae737fa47e63ceddb Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 5 Feb 2026 14:20:14 -0600 Subject: [PATCH] fix --- .github/workflows/release.yml | 120 +++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 51 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 035fd6b..8327eb1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,18 +12,19 @@ permissions: env: MKDOCS_CONFIG: mkdocs/mkdocs.yml - MKDOCS_OUTPUT_DIR: ${{ runner.temp }}/dist MKDOCS_STRICT: ${{ vars.MKDOCS_STRICT || 'true' }} jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout (tag) + uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 + - name: Setup Python + uses: actions/setup-python@v5 with: python-version: "3.11" @@ -41,30 +42,50 @@ jobs: FLAGS+=(--strict) fi - mkdir -p "${MKDOCS_OUTPUT_DIR}" + OUT_BASE="${RUNNER_TEMP}/mkdocs_out" + SITE="${OUT_BASE}/site" + SITE_OFFLINE="${OUT_BASE}/site_offline" - OFFLINE="${OFFLINE:-true}" mkdocs build \ - "${FLAGS[@]}" \ - -f "${MKDOCS_CONFIG}" \ - -d "${MKDOCS_OUTPUT_DIR}/offline" - mkdocs build \ - "${FLAGS[@]}" \ - -f "${MKDOCS_CONFIG}" \ - -d "${MKDOCS_OUTPUT_DIR}/dist" + rm -rf "${OUT_BASE}" + mkdir -p "${SITE}" "${SITE_OFFLINE}" + + # Normal build + mkdocs build "${FLAGS[@]}" -f "${MKDOCS_CONFIG}" -d "${SITE}" + + # Offline build (only matters if your mkdocs.yml/plugins read OFFLINE) + OFFLINE=true mkdocs build "${FLAGS[@]}" -f "${MKDOCS_CONFIG}" -d "${SITE_OFFLINE}" + + - name: Upload site artifact (normal) + uses: actions/upload-artifact@v4 + with: + name: site + path: ${{ runner.temp }}/mkdocs_out/site + + - name: Upload site artifact (offline) + uses: actions/upload-artifact@v4 + with: + name: site_offline + path: ${{ runner.temp }}/mkdocs_out/site_offline - - name: Zip site - run: | - set -euo pipefail - cd "${MKDOCS_OUTPUT_DIR}" - zip -r "${GITHUB_REF_NAME}.zip" "./offline" release: runs-on: ubuntu-latest needs: build + permissions: + contents: write + steps: - # ------------------------- - # RC-only step - # ------------------------- - - name: Publish prerelease + - name: Download offline site artifact + uses: actions/download-artifact@v4 + with: + name: site_offline + path: site_offline + + - name: Zip offline site + run: | + set -euo pipefail + zip -r "${GITHUB_REF_NAME}.zip" site_offline + + - name: Publish prerelease if: startsWith(github.ref_name, 'rc') uses: softprops/action-gh-release@v2 with: @@ -74,11 +95,8 @@ jobs: body: | Release candidate preview (if deployed): /rc/ files: | - ${{ runner.temp }}/${{ github.ref_name }}.zip + ${{ github.ref_name }}.zip - # ------------------------- - # Final release-only step - # ------------------------- - name: Publish release if: startsWith(github.ref_name, 'v') uses: softprops/action-gh-release@v2 @@ -86,51 +104,51 @@ jobs: name: ${{ github.ref_name }} tag_name: ${{ github.ref_name }} files: | - ${{ runner.temp }}/${{ github.ref_name }}.zip + ${{ github.ref_name }}.zip + deploy: runs-on: ubuntu-latest needs: build + permissions: + contents: write + steps: - - name: Checkout (tag) + - name: Download normal site artifact + uses: actions/download-artifact@v4 + with: + name: site + path: site + + - name: Checkout gh-pages branch uses: actions/checkout@v4 with: + ref: gh-pages fetch-depth: 0 - - name: Checkout gh-pages branch + + - name: Deploy release to gh-pages root + if: startsWith(github.ref_name, 'v') run: | set -euo pipefail - git fetch origin gh-pages:gh-pages || true - if git show-ref --verify --quiet refs/heads/gh-pages; then - git switch gh-pages - else - git switch --orphan gh-pages - rm -rf ./* - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git commit --allow-empty -m "Initialize gh-pages" - fi - - - name: Publish release - run: | - set -euo pipefail - rm -rf assets styles search *{.html,.xml,xml.gz} || true - cp -a "${MKDOCS_OUTPUT_DIR}/dist/." "" - + rm -rf ./* + cp -a ../site/. . git add -A git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git commit -m "Deploy release ${GITHUB_REF_NAME}" || echo "No changes to commit" git push origin gh-pages - - name: Publish RC preview under /rc// + - name: Deploy RC preview to /rc/ + if: startsWith(github.ref_name, 'rc') run: | set -euo pipefail - rm -rf "rc"* || true - mkdir -p "rc/" - cp -a "${MKDOCS_OUTPUT_DIR}/dist/." "rc/" + rm -rf rc + mkdir -p rc + cp -a ../site/. rc/ + # optional metadata for your toolbar link idea: + printf '{"tag":"%s"}\n' "${GITHUB_REF_NAME}" > rc/rc.json git add -A git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git commit -m "Deploy RC preview ${GITHUB_REF_NAME}" || echo "No changes to commit" - git push origin gh-pages - \ No newline at end of file + git push origin gh-pages \ No newline at end of file