-
Notifications
You must be signed in to change notification settings - Fork 101
133 lines (108 loc) · 4.3 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Render Docs Website
on:
push:
branches:
- master
- backport-v0.*
workflow_dispatch: # manual trigger for testing
concurrency:
group: docs
cancel-in-progress: true
permissions:
contents: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Julia
uses: julia-actions/setup-julia@v2
with:
version: '1.10'
- name: Load Julia packages from cache
uses: julia-actions/cache@v2
# Note: needs resolve() to fix #518
- name: Instantiate Julia environment
run: julia --project=. -e 'using Pkg; Pkg.instantiate(); Pkg.resolve()'
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
# Needs Quarto 1.6 to fix #533, which is currently a pre-release version
version: pre-release
- name: Install jq
run: sudo apt-get install jq
- name: Restore cached _freeze folder
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
./_freeze/
key: |
${{ runner.os }}-${{ hashFiles('**/Manifest.toml') }}-${{ hashFiles('**/index.qmd') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/Manifest.toml') }}
- 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 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=$(curl --silent "https://api.github.com/repos/TuringLang/Turing.jl/releases/latest" | jq -r .tag_name)
echo "LATEST=$latest" >> $GITHUB_ENV
- name: Run Changelog and Versions Scripts
if: env.version == env.LATEST
run: |
sh assets/scripts/changelog.sh
sh assets/scripts/versions.sh
- name: Render Quarto site
run: quarto render
- name: Rename original search index
run: mv _site/search.json _site/search_original.json
- name: Save _freeze folder
id: cache-save
uses: actions/cache/save@v4
with:
path: |
./_freeze/
key: ${{ runner.os }}-${{ hashFiles('**/Manifest.toml') }}-${{ hashFiles('**/index.qmd') }}
- name: Fetch search_original.json from main site
run: curl -O https://raw.githubusercontent.com/TuringLang/turinglang.github.io/gh-pages/search_original.json
- name: Convert main site search index URLs to relative URLs
run: |
jq 'map(
if .href then .href = "../" + .href else . end |
if .objectID then .objectID = "../" + .objectID else . end)' search_original.json > fixed_main_search.json
- name: Merge both search index
run: |
jq -s '.[0] + .[1]' _site/search_original.json fixed_main_search.json > _site/search.json
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- name: Update gh-pages branch
run: |
# Copy to versions/ subdirectory
mkdir -p gh-pages/versions/${{ env.version }}
cp -r _site/* gh-pages/versions/${{ env.version }}
# Find the latest version of the docs and copy that to the root
cd gh-pages/versions
LATEST_DOCS=$(ls -d * | sort -V | tail -n 1)
cp -r $LATEST_DOCS/* ../
# Commit and push
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Publish docs @ ${GITHUB_REPOSITORY}@${GITHUB_SHA}"
git push