Skip to content

Commit b4d5b5b

Browse files
fixed preview workflow and added current version in navbar! (#488)
* update preview workflow * testing preview workflow * testing preview workflow * testing preview workflow * testing preview workflow * tests * test2 * test2 * test2 * test2 * thollander comment workflow * thollander comment workflow * thollander comment workflow * thollander comment workflow * vcheck workflow test for forks * vcheck skip * added vdropdown with current version in navbar * hotfix in _quarto.yml * ajusted vdropdown a bit * updated comments * removed version and changelog from sidebar * testing new workflow * updated vcheck * updated version in _quarto.yml * updated version in _quarto.yml * Changed sed to awk * updated vcheck * updated publish.yml * . * . * updated vcheck * updated vcheck * another suggestion workflow * updated suggestion workflow * manual approach * json parsing fixed * continue on error previous worklow * finally its done😊 * Update .github/workflows/vcheck.yml Co-authored-by: Hong Ge <[email protected]> --------- Co-authored-by: Hong Ge <[email protected]>
1 parent 7a8fc92 commit b4d5b5b

File tree

6 files changed

+87
-100
lines changed

6 files changed

+87
-100
lines changed

.github/workflows/preview.yml

Lines changed: 26 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717
with:
1818
ref: ${{ github.event.pull_request.head.sha }}
1919

@@ -48,91 +48,51 @@ jobs:
4848
_freeze/
4949
key: ${{ runner.os }}-primes-${{ github.run_id }}
5050

51-
- name: Checkout gh-pages branch
52-
uses: actions/checkout@v3
51+
- name: Deploy to GitHub Pages
52+
uses: JamesIves/github-pages-deploy-action@v4
5353
with:
54-
ref: gh-pages
55-
path: gh-pages
54+
branch: gh-pages
55+
folder: _site
56+
target-folder: pr-previews/${{ github.event.pull_request.number }}
57+
clean: false
58+
commit-message: Deploy preview for PR ${{ github.event.pull_request.number }}
59+
token: ${{ secrets.GITHUB_TOKEN }}
5660

57-
- name: Deploy Preview to GitHub Pages
58-
run: |
59-
PR_NUMBER=${{ github.event.pull_request.number }}
60-
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
61-
mkdir -p gh-pages/${PREVIEW_DIR}
62-
cp -r _site/* gh-pages/${PREVIEW_DIR}
63-
cd gh-pages
64-
git config --global user.name "github-actions[bot]"
65-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
66-
git add .
67-
git commit -m "Deploy preview for PR ${PR_NUMBER}"
68-
git push
61+
comment-preview-url:
62+
needs: build-and-preview
63+
if: needs.build-and-preview.result == 'success'
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Comment Preview URL
67+
uses: thollander/actions-comment-pull-request@v2
68+
with:
69+
message: |
70+
<!-- preview-url-comment -->
71+
Preview the changes: https://turinglang.org/docs/pr-previews/${{ github.event.pull_request.number }}
72+
Please avoid using the search feature and navigation bar in PR previews!
73+
comment_tag: preview-url-comment
6974
env:
70-
GH_PAT: ${{ secrets.GH_PAT }}
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7176

7277
delete-preview-directory:
7378
if: github.event.action == 'closed' || github.event.pull_request.merged == true
7479
runs-on: ubuntu-latest
7580
steps:
7681
- name: Checkout gh-pages branch
77-
uses: actions/checkout@v3
82+
uses: actions/checkout@v4
7883
with:
7984
ref: gh-pages
80-
85+
8186
- name: Remove PR Preview Directory
8287
run: |
8388
PR_NUMBER=${{ github.event.pull_request.number }}
8489
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
8590
git config --global user.name "github-actions[bot]"
8691
git config --global user.email "github-actions[bot]@users.noreply.github.com"
92+
git pull origin gh-pages
8793
rm -rf ${PREVIEW_DIR}
8894
git add .
8995
git commit -m "Remove preview for merged PR #${PR_NUMBER}"
9096
git push
9197
env:
9298
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93-
94-
comment-preview-url:
95-
needs: build-and-preview
96-
if: needs.build-and-preview.result == 'success'
97-
runs-on: ubuntu-latest
98-
steps:
99-
- name: Comment Preview URL
100-
uses: actions/github-script@v7
101-
with:
102-
github-token: ${{ secrets.GITHUB_TOKEN }}
103-
script: |
104-
const prNumber = context.payload.pull_request.number;
105-
const repoName = context.repo.repo;
106-
const previewUrl = `https://turinglang.org/${repoName}/pr-previews/${prNumber}`;
107-
const commentBody = `Preview the changes: ${previewUrl}, Please avoid using the search feature and navigation bar in PR previews!`;
108-
const botUsername = 'github-actions[bot]';
109-
110-
// Check for existing comments by the bot
111-
const existingComments = await github.rest.issues.listComments({
112-
owner: context.repo.owner,
113-
repo: context.repo.repo,
114-
issue_number: prNumber,
115-
});
116-
117-
const botComment = existingComments.data.find(
118-
(comment) => comment.user.login === botUsername
119-
);
120-
121-
if (botComment) {
122-
// Update the existing comment
123-
await github.rest.issues.updateComment({
124-
owner: context.repo.owner,
125-
repo: context.repo.repo,
126-
comment_id: botComment.id,
127-
body: commentBody,
128-
});
129-
} else {
130-
// Create a new comment
131-
await github.rest.issues.createComment({
132-
issue_number: prNumber,
133-
owner: context.repo.owner,
134-
repo: context.repo.repo,
135-
body: commentBody,
136-
});
137-
}
138-

.github/workflows/publish.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,26 @@ jobs:
6464
run: |
6565
jq -s '.[0] + .[1]' _site/search_original.json fixed_main_search.json > _site/search.json
6666
67-
- name: Read VERSION file
68-
id: read_version
69-
run: echo "version=$(cat VERSION)" >> $GITHUB_ENV
67+
- name: Extract version from _quarto.yml
68+
id: extract_version
69+
run: |
70+
minor_version=$(grep -oP 'text:\s+"v\K\d+\.\d+' _quarto.yml)
71+
echo "minor_version=$minor_version" >> $GITHUB_ENV
7072
71-
- name: Fetch latest version from GitHub
72-
id: fetch_latest_version
73+
- name: Fetch latest bugfix version for the extracted minor version
74+
id: fetch_latest_bugfix
75+
run: |
76+
repo_url="https://api.github.com/repos/TuringLang/Turing.jl/tags"
77+
tags=$(curl -s $repo_url | jq -r '.[].name')
78+
stable_tags=$(echo "$tags" | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+$')
79+
latest_bugfix=$(echo "$stable_tags" | grep "^v${{ env.minor_version }}" | sort -rV | head -n 1)
80+
echo "version=$latest_bugfix" >> $GITHUB_ENV
81+
82+
- name: Fetch the actual latest bugfix version
83+
id: fetch_latest_bugfix_actual
7384
run: |
74-
latest_version=$(curl --silent "https://api.github.com/repos/TuringLang/Turing.jl/releases/latest" | jq -r .tag_name)
75-
echo "latest_version=$latest_version" >> $GITHUB_ENV
85+
latest=$(curl --silent "https://api.github.com/repos/TuringLang/Turing.jl/releases/latest" | jq -r .tag_name)
86+
echo "LATEST=$latest" >> $GITHUB_ENV
7687
7788
- name: Deploy versioned docs
7889
uses: JamesIves/github-pages-deploy-action@v4
@@ -83,9 +94,9 @@ jobs:
8394
clean: false
8495

8596
- name: Deploy latest docs to root
86-
if: env.version == env.latest_version
97+
if: env.version == env.LATEST
8798
uses: JamesIves/github-pages-deploy-action@v4
8899
with:
89100
branch: gh-pages
90101
folder: _site
91-
clean: false
102+
clean: false

.github/workflows/vcheck.yml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
11
name: Check Turing.jl Version
22
on:
33
pull_request:
4-
paths: ['VERSION']
4+
paths: ['_quarto.yml']
55
workflow_dispatch:
66

7-
permissions:
8-
contents: read
9-
pull-requests: write
10-
117
jobs:
128
check-version:
139
runs-on: ubuntu-latest
1410
steps:
1511
- name: Checkout
1612
uses: actions/checkout@v4
1713

18-
- name: Get current version
19-
id: current_version
20-
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_OUTPUT
14+
- name: Extract current minor version
15+
id: extract_minor_version
16+
run: |
17+
minor_version=$(grep -oP 'text:\s+"v\K\d+\.\d+' _quarto.yml)
18+
echo "MINOR_VERSION=$minor_version" >> $GITHUB_OUTPUT
2119
22-
- name: Get latest Turing.jl version
23-
id: latest_version
20+
- name: Fetch latest minor version
21+
id: fetch_latest_minor
2422
run: |
25-
latest=$(curl --silent "https://api.github.com/repos/TuringLang/Turing.jl/releases/latest" | jq -r .tag_name)
23+
repo_url="https://api.github.com/repos/TuringLang/Turing.jl/releases/latest"
24+
latest=$(curl -s $repo_url | jq -r .tag_name)
25+
actual_latest_minor=${latest%.*}
26+
echo "LATEST_MINOR=$actual_latest_minor" >> $GITHUB_OUTPUT
2627
echo "LATEST=$latest" >> $GITHUB_OUTPUT
2728
28-
- name: Update VERSION file if outdated
29+
- name: Update _quarto.yml if outdated
2930
run: |
30-
if [ "${{ steps.current_version.outputs.VERSION }}" != "${{ steps.latest_version.outputs.LATEST }}" ]; then
31-
echo "${{ steps.latest_version.outputs.LATEST }}" > VERSION
31+
minor_version=${{ steps.extract_minor_version.outputs.MINOR_VERSION }}
32+
latest_minor=${{ steps.fetch_latest_minor.outputs.LATEST_MINOR }}
33+
if [ "$minor_version" != "$latest_minor" ]; then
34+
awk -v old="v$minor_version" -v new="$latest_minor" '{gsub(old, new); print}' _quarto.yml > temp.yml && mv temp.yml _quarto.yml
35+
echo "Updated _quarto.yml to latest minor version: $latest_minor"
3236
fi
3337
34-
- name: Suggest changes
35-
uses: parkerbxyz/suggest-changes@v1
38+
- name: Suggest Changes
39+
uses: getsentry/action-git-diff-suggestions@main
3640
with:
37-
comment: 'If this PR is not intended to update any previous release, please update the VERSION file to the latest version.'
41+
message: 'The version in _quarto.yml is outdated. Please update to the latest version.'
42+
github-token: ${{ secrets.GITHUB_TOKEN }}
43+
continue-on-error: true

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

_quarto.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ website:
3333
text: News
3434
- href: https://turinglang.org/team/
3535
text: Team
36+
right:
37+
# Current version
38+
- text: "v0.33"
39+
menu:
40+
- text: Changelog
41+
href: https://turinglang.org/docs/changelog.html
42+
- text: All Versions
43+
href: https://turinglang.org/docs/versions.html
3644
tools:
3745
- icon: twitter
3846
href: https://x.com/TuringLang
@@ -42,7 +50,7 @@ website:
4250
text: Turing GitHub
4351

4452
sidebar:
45-
- id: documentation
53+
- text: documentation
4654
collapse-level: 1
4755
contents:
4856
- section: "Documentation"
@@ -111,11 +119,6 @@ website:
111119
- tutorials/docs-07-for-developers-variational-inference/index.qmd
112120
- text: "Implementing Samplers"
113121
href: tutorials/docs-17-implementing-samplers/index.qmd
114-
115-
- text: "Versions"
116-
href: versions.qmd
117-
contents:
118-
- changelog.qmd
119122

120123
page-footer:
121124
background: "#073c44"
@@ -132,7 +135,7 @@ website:
132135
aria-label: Turing GitHub
133136

134137
back-to-top-navigation: true
135-
repo-url: https://github.com/TuringLang/TuringTutorials
138+
repo-url: https://github.com/TuringLang/docs
136139
repo-actions: [edit, issue]
137140
repo-branch: master
138141
repo-link-target: _blank

theming/styles.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,12 @@
4646
.nav-footer-center {
4747
display: flex;
4848
justify-content: center;
49+
}
50+
51+
.dropdown-menu {
52+
text-align: center;
53+
min-width: 100px !important;
54+
border-radius: 5px;
55+
max-height: 250px;
56+
overflow: scroll;
4957
}

0 commit comments

Comments
 (0)