Skip to content

Commit 7a8fc92

Browse files
Versioning of website based on Turing's versions (#478)
* versioning test 1 * versioning test 2 * versioning test 3 * versioning test 4 * versioning test 5 * versioning test 6 * versioning test 7 * versioning test 8 * final versioning workflow * added versions and changelog * updated versions script * updated workflow * added VERSION file * fixed bash script in workflow * Set VERSION file to latest * testing committing lates * testing * testing 2 * final workflow * testing workflow * testing workflow * testing workflow * testing workflow * testing workflow * vcheck workflow tests * hotfix * hotfix * hotfix * vcheck workflow tests * Update VERSION * vcheck workflow tests * vcheck workflow tests * vcheck workflow tests * hotfix * vcheck workflow tests * vcheck workflow tests * hotfix * hotfix * vcheck workflow tests * tests * tests * tests * tests * added changelog in submenu * try1 * try2 * try2 * try2 * try3 * try3 * try3 * try3 * try3 * try3 * try3 * try3 * try3 * try3 * try3 * try3 * suggest changes workflow * suggest changes workflow * suggest workflow updated * working * added if condition in publish workflow --------- Co-authored-by: GitHub Action <[email protected]>
1 parent 6bf2fa9 commit 7a8fc92

File tree

7 files changed

+176
-7
lines changed

7 files changed

+176
-7
lines changed

.github/workflows/publish.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
name: Render Docs Website
2+
13
on:
24
push:
35
branches:
46
- master
5-
6-
name: Render Docs Website
7+
workflow_dispatch: # manual trigger for testing
78

89
jobs:
910
build-and-deploy:
@@ -63,8 +64,28 @@ jobs:
6364
run: |
6465
jq -s '.[0] + .[1]' _site/search_original.json fixed_main_search.json > _site/search.json
6566
66-
- name: Deploy to GitHub Pages
67+
- name: Read VERSION file
68+
id: read_version
69+
run: echo "version=$(cat VERSION)" >> $GITHUB_ENV
70+
71+
- name: Fetch latest version from GitHub
72+
id: fetch_latest_version
73+
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
76+
77+
- name: Deploy versioned docs
78+
uses: JamesIves/github-pages-deploy-action@v4
79+
with:
80+
branch: gh-pages
81+
folder: _site
82+
target-folder: versions/${{ env.version }}
83+
clean: false
84+
85+
- name: Deploy latest docs to root
86+
if: env.version == env.latest_version
6787
uses: JamesIves/github-pages-deploy-action@v4
6888
with:
6989
branch: gh-pages
7090
folder: _site
91+
clean: false

.github/workflows/vcheck.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Check Turing.jl Version
2+
on:
3+
pull_request:
4+
paths: ['VERSION']
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
check-version:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Get current version
19+
id: current_version
20+
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_OUTPUT
21+
22+
- name: Get latest Turing.jl version
23+
id: latest_version
24+
run: |
25+
latest=$(curl --silent "https://api.github.com/repos/TuringLang/Turing.jl/releases/latest" | jq -r .tag_name)
26+
echo "LATEST=$latest" >> $GITHUB_OUTPUT
27+
28+
- name: Update VERSION file if outdated
29+
run: |
30+
if [ "${{ steps.current_version.outputs.VERSION }}" != "${{ steps.latest_version.outputs.LATEST }}" ]; then
31+
echo "${{ steps.latest_version.outputs.LATEST }}" > VERSION
32+
fi
33+
34+
- name: Suggest changes
35+
uses: parkerbxyz/suggest-changes@v1
36+
with:
37+
comment: 'If this PR is not intended to update any previous release, please update the VERSION file to the latest version.'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ _freeze
2020
_site
2121
.quarto
2222
/.quarto/
23+
changelog.qmd
24+
versions.qmd

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.33.0

_quarto.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ project:
44
# Change port if it's busy in your system or just remove this line so that It will automatically use any free port
55
port: 4200
66
browser: true
7+
pre-render:
8+
- sh assets/scripts/changelog.sh
9+
- sh assets/scripts/versions.sh
710

811
# These cannot be used as variables. They are reserved for the project configuration.
912
website:
@@ -43,11 +46,10 @@ website:
4346
collapse-level: 1
4447
contents:
4548
- section: "Documentation"
46-
# href: tutorials/index.qmd
49+
# href: tutorials/index.qmd, This page will be added later so keep this line commented
4750
contents:
4851
- section: "Using Turing - Modelling Syntax and Interface"
4952
collapse-level: 1
50-
href: tutorials/docs-00-getting-started/index.qmd
5153
contents:
5254
- tutorials/docs-00-getting-started/index.qmd
5355
- text: "Quick Start"
@@ -102,15 +104,18 @@ website:
102104
href: tutorials/16-contexts/index.qmd
103105
- tutorials/docs-06-for-developers-interface/index.qmd
104106

105-
106107
- section: "For Developers (Inference)"
107108
collapse-level: 1
108109
contents:
109110
- tutorials/docs-04-for-developers-abstractmcmc-turing/index.qmd
110111
- tutorials/docs-07-for-developers-variational-inference/index.qmd
111112
- text: "Implementing Samplers"
112113
href: tutorials/docs-17-implementing-samplers/index.qmd
113-
114+
115+
- text: "Versions"
116+
href: versions.qmd
117+
contents:
118+
- changelog.qmd
114119

115120
page-footer:
116121
background: "#073c44"

assets/scripts/changelog.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
url="https://raw.githubusercontent.com/TuringLang/Turing.jl/master/HISTORY.md"
2+
3+
changelog_content=$(curl -s "$url")
4+
5+
cat << EOF > changelog.qmd
6+
---
7+
title: Changelog
8+
repo-actions: false
9+
include-in-header:
10+
- text: |
11+
<style>
12+
a {
13+
text-decoration: none;
14+
}
15+
a:hover {
16+
text-decoration: underline;
17+
}
18+
</style>
19+
---
20+
21+
$changelog_content
22+
EOF

assets/scripts/versions.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
REPO_URL="https://api.github.com/repos/TuringLang/Turing.jl/tags"
4+
5+
# Fetch the tags
6+
TAGS=$(curl -s $REPO_URL | grep 'name' | sed 's/.*: "\(.*\)",/\1/')
7+
8+
# Filter out pre-release version tags (e.g., 0.33.0-rc.1) and keep only stable version tags
9+
STABLE_TAGS=$(echo "$TAGS" | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+$')
10+
11+
# Find the latest version (including bug fix versions)
12+
LATEST_VERSION=$(echo "$STABLE_TAGS" | head -n 1)
13+
14+
# Find the latest minor version (without bug fix)
15+
STABLE_VERSION=$(echo "$STABLE_TAGS" | grep -Eo 'v[0-9]+\.[0-9]+(\.0)?$' | head -n 1)
16+
17+
# Filter out bug fix version tags from STABLE_TAGS to get only minor version tags
18+
MINOR_TAGS=$(echo "$STABLE_TAGS" | grep -Eo 'v[0-9]+\.[0-9]+(\.0)?$')
19+
20+
# Set the minimum version to include in the "Previous Versions" section
21+
MIN_VERSION="v0.31.0"
22+
23+
# versions.qmd file will be generated from this content
24+
VERSIONS_CONTENT="---
25+
pagetitle: Versions
26+
repo-actions: false
27+
include-in-header:
28+
- text: |
29+
<style>
30+
a {
31+
text-decoration: none;
32+
}
33+
a:hover {
34+
text-decoration: underline;
35+
}
36+
</style>
37+
---
38+
39+
# Latest Version
40+
| | | |
41+
| --- | --- | --- |
42+
| ${LATEST_VERSION} | [Documention](versions/${LATEST_VERSION}/) | [Changelog](changelog.qmd) |
43+
44+
# Stable Version
45+
| | |
46+
| --- | --- |
47+
| ${STABLE_VERSION} | [Documention](versions/${STABLE_VERSION}/) |
48+
49+
# Previous Versions
50+
| | |
51+
| --- | --- |
52+
"
53+
# Add previous versions, excluding the latest and stable versions
54+
for MINOR_TAG in $MINOR_TAGS; do
55+
if [ "$MINOR_TAG" != "$LATEST_VERSION" ] && [ "$MINOR_TAG" != "$STABLE_VERSION" ] && [ "$MINOR_TAG" \> "$MIN_VERSION" ]; then
56+
# Find the latest bug fix version for the current minor version
57+
LATEST_BUG_FIX=$(echo "$STABLE_TAGS" | grep "^${MINOR_TAG%.*}" | sort -r | head -n 1)
58+
VERSIONS_CONTENT="${VERSIONS_CONTENT}| ${MINOR_TAG} | [Documention](versions/${LATEST_BUG_FIX}/) |
59+
"
60+
fi
61+
done
62+
63+
# Add the Archived Versions section manually
64+
VERSIONS_CONTENT="${VERSIONS_CONTENT}
65+
# Archived Versions
66+
Documentation for archived versions is available on our deprecated documentation site.
67+
68+
| | |
69+
| --- | --- |
70+
| v0.31.0 | [Documention](../v0.31.4/) |
71+
| v0.30.0 | [Documention](../v0.30.9/) |
72+
| v0.29.0 | [Documention](../v0.29.3/) |
73+
| v0.28.0 | [Documention](../v0.28.3/) |
74+
| v0.27.0 | [Documention](../v0.27.0/) |
75+
| v0.26.0 | [Documention](../v0.26.6/) |
76+
| v0.25.0 | [Documention](../v0.25.3/) |
77+
| v0.24.0 | [Documention](../v0.29.4/) |
78+
"
79+
80+
# Write the content to the versions.qmd file
81+
echo "$VERSIONS_CONTENT" > versions.qmd

0 commit comments

Comments
 (0)