diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index c5c7bbca5..e7e1081a5 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} @@ -48,91 +48,51 @@ jobs: _freeze/ key: ${{ runner.os }}-primes-${{ github.run_id }} - - name: Checkout gh-pages branch - uses: actions/checkout@v3 + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 with: - ref: gh-pages - path: gh-pages + branch: gh-pages + folder: _site + target-folder: pr-previews/${{ github.event.pull_request.number }} + clean: false + commit-message: Deploy preview for PR ${{ github.event.pull_request.number }} + token: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy Preview to GitHub Pages - run: | - PR_NUMBER=${{ github.event.pull_request.number }} - PREVIEW_DIR="pr-previews/${PR_NUMBER}" - mkdir -p gh-pages/${PREVIEW_DIR} - cp -r _site/* gh-pages/${PREVIEW_DIR} - cd gh-pages - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "Deploy preview for PR ${PR_NUMBER}" - git push + comment-preview-url: + needs: build-and-preview + if: needs.build-and-preview.result == 'success' + runs-on: ubuntu-latest + steps: + - name: Comment Preview URL + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + + Preview the changes: https://turinglang.org/docs/pr-previews/${{ github.event.pull_request.number }} + Please avoid using the search feature and navigation bar in PR previews! + comment_tag: preview-url-comment env: - GH_PAT: ${{ secrets.GH_PAT }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} delete-preview-directory: if: github.event.action == 'closed' || github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - name: Checkout gh-pages branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: gh-pages - + - name: Remove PR Preview Directory run: | PR_NUMBER=${{ github.event.pull_request.number }} PREVIEW_DIR="pr-previews/${PR_NUMBER}" git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" + git pull origin gh-pages rm -rf ${PREVIEW_DIR} git add . git commit -m "Remove preview for merged PR #${PR_NUMBER}" git push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - comment-preview-url: - needs: build-and-preview - if: needs.build-and-preview.result == 'success' - runs-on: ubuntu-latest - steps: - - name: Comment Preview URL - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const prNumber = context.payload.pull_request.number; - const repoName = context.repo.repo; - const previewUrl = `https://turinglang.org/${repoName}/pr-previews/${prNumber}`; - const commentBody = `Preview the changes: ${previewUrl}, Please avoid using the search feature and navigation bar in PR previews!`; - const botUsername = 'github-actions[bot]'; - - // Check for existing comments by the bot - const existingComments = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - }); - - const botComment = existingComments.data.find( - (comment) => comment.user.login === botUsername - ); - - if (botComment) { - // Update the existing comment - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: botComment.id, - body: commentBody, - }); - } else { - // Create a new comment - await github.rest.issues.createComment({ - issue_number: prNumber, - owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody, - }); - } - diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4c366c9f2..d564ef16e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -64,15 +64,26 @@ jobs: run: | jq -s '.[0] + .[1]' _site/search_original.json fixed_main_search.json > _site/search.json - - name: Read VERSION file - id: read_version - run: echo "version=$(cat VERSION)" >> $GITHUB_ENV + - name: Extract version from _quarto.yml + id: extract_version + run: | + minor_version=$(grep -oP 'text:\s+"v\K\d+\.\d+' _quarto.yml) + echo "minor_version=$minor_version" >> $GITHUB_ENV - - name: Fetch latest version from GitHub - id: fetch_latest_version + - name: Fetch latest bugfix version for the extracted minor version + id: fetch_latest_bugfix + run: | + repo_url="https://api.github.com/repos/TuringLang/Turing.jl/tags" + tags=$(curl -s $repo_url | jq -r '.[].name') + stable_tags=$(echo "$tags" | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+$') + latest_bugfix=$(echo "$stable_tags" | grep "^v${{ env.minor_version }}" | sort -rV | head -n 1) + echo "version=$latest_bugfix" >> $GITHUB_ENV + + - name: Fetch the actual latest bugfix version + id: fetch_latest_bugfix_actual run: | - latest_version=$(curl --silent "https://api.github.com/repos/TuringLang/Turing.jl/releases/latest" | jq -r .tag_name) - echo "latest_version=$latest_version" >> $GITHUB_ENV + latest=$(curl --silent "https://api.github.com/repos/TuringLang/Turing.jl/releases/latest" | jq -r .tag_name) + echo "LATEST=$latest" >> $GITHUB_ENV - name: Deploy versioned docs uses: JamesIves/github-pages-deploy-action@v4 @@ -83,9 +94,9 @@ jobs: clean: false - name: Deploy latest docs to root - if: env.version == env.latest_version + if: env.version == env.LATEST uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages folder: _site - clean: false + clean: false \ No newline at end of file diff --git a/.github/workflows/vcheck.yml b/.github/workflows/vcheck.yml index 3e3d538d1..99ab0a156 100644 --- a/.github/workflows/vcheck.yml +++ b/.github/workflows/vcheck.yml @@ -1,13 +1,9 @@ name: Check Turing.jl Version on: pull_request: - paths: ['VERSION'] + paths: ['_quarto.yml'] workflow_dispatch: -permissions: - contents: read - pull-requests: write - jobs: check-version: runs-on: ubuntu-latest @@ -15,23 +11,33 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Get current version - id: current_version - run: echo "VERSION=$(cat VERSION)" >> $GITHUB_OUTPUT + - name: Extract current minor version + id: extract_minor_version + run: | + minor_version=$(grep -oP 'text:\s+"v\K\d+\.\d+' _quarto.yml) + echo "MINOR_VERSION=$minor_version" >> $GITHUB_OUTPUT - - name: Get latest Turing.jl version - id: latest_version + - name: Fetch latest minor version + id: fetch_latest_minor run: | - latest=$(curl --silent "https://api.github.com/repos/TuringLang/Turing.jl/releases/latest" | jq -r .tag_name) + repo_url="https://api.github.com/repos/TuringLang/Turing.jl/releases/latest" + latest=$(curl -s $repo_url | jq -r .tag_name) + actual_latest_minor=${latest%.*} + echo "LATEST_MINOR=$actual_latest_minor" >> $GITHUB_OUTPUT echo "LATEST=$latest" >> $GITHUB_OUTPUT - - name: Update VERSION file if outdated + - name: Update _quarto.yml if outdated run: | - if [ "${{ steps.current_version.outputs.VERSION }}" != "${{ steps.latest_version.outputs.LATEST }}" ]; then - echo "${{ steps.latest_version.outputs.LATEST }}" > VERSION + minor_version=${{ steps.extract_minor_version.outputs.MINOR_VERSION }} + latest_minor=${{ steps.fetch_latest_minor.outputs.LATEST_MINOR }} + if [ "$minor_version" != "$latest_minor" ]; then + awk -v old="v$minor_version" -v new="$latest_minor" '{gsub(old, new); print}' _quarto.yml > temp.yml && mv temp.yml _quarto.yml + echo "Updated _quarto.yml to latest minor version: $latest_minor" fi - - name: Suggest changes - uses: parkerbxyz/suggest-changes@v1 + - name: Suggest Changes + uses: getsentry/action-git-diff-suggestions@main with: - comment: 'If this PR is not intended to update any previous release, please update the VERSION file to the latest version.' + message: 'The version in _quarto.yml is outdated. Please update to the latest version.' + github-token: ${{ secrets.GITHUB_TOKEN }} + continue-on-error: true diff --git a/VERSION b/VERSION deleted file mode 100644 index 12b531b55..000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -v0.33.0 \ No newline at end of file diff --git a/_quarto.yml b/_quarto.yml index 49e20c4cf..ab7585b5a 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -33,6 +33,14 @@ website: text: News - href: https://turinglang.org/team/ text: Team + right: + # Current version + - text: "v0.33" + menu: + - text: Changelog + href: https://turinglang.org/docs/changelog.html + - text: All Versions + href: https://turinglang.org/docs/versions.html tools: - icon: twitter href: https://x.com/TuringLang @@ -42,7 +50,7 @@ website: text: Turing GitHub sidebar: - - id: documentation + - text: documentation collapse-level: 1 contents: - section: "Documentation" @@ -111,11 +119,6 @@ website: - tutorials/docs-07-for-developers-variational-inference/index.qmd - text: "Implementing Samplers" href: tutorials/docs-17-implementing-samplers/index.qmd - - - text: "Versions" - href: versions.qmd - contents: - - changelog.qmd page-footer: background: "#073c44" @@ -132,7 +135,7 @@ website: aria-label: Turing GitHub back-to-top-navigation: true - repo-url: https://github.com/TuringLang/TuringTutorials + repo-url: https://github.com/TuringLang/docs repo-actions: [edit, issue] repo-branch: master repo-link-target: _blank diff --git a/theming/styles.css b/theming/styles.css index 06a2b93ec..b3927862f 100755 --- a/theming/styles.css +++ b/theming/styles.css @@ -46,4 +46,12 @@ .nav-footer-center { display: flex; justify-content: center; +} + +.dropdown-menu { + text-align: center; + min-width: 100px !important; + border-radius: 5px; + max-height: 250px; + overflow: scroll; } \ No newline at end of file