Skip to content

Commit

Permalink
pre render scripts in gh-actions (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
shravanngoswamii authored Jul 11, 2024
1 parent 99ebe58 commit 8aa4631
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
54 changes: 30 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
with:
version: pre-release

- name: Install jq
run: sudo apt-get install jq

- name: Restore cached _freeze folder
id: cache-primes-restore
uses: actions/cache/restore@v4
Expand All @@ -35,6 +38,33 @@ jobs:
restore-keys: |
${{ runner.os }}-primes
- 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

Expand All @@ -49,9 +79,6 @@ jobs:
_freeze/
key: ${{ runner.os }}-primes-${{ github.run_id }}

- name: Install jq
run: sudo apt-get install jq

- name: Fetch search_original.json from main site
run: curl -O https://raw.githubusercontent.com/TuringLang/turinglang.github.io/gh-pages/search_original.json

Expand All @@ -65,27 +92,6 @@ jobs:
run: |
jq -s '.[0] + .[1]' _site/search_original.json fixed_main_search.json > _site/search.json
- 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: Deploy versioned docs
uses: JamesIves/github-pages-deploy-action@v4
with:
Expand Down
3 changes: 0 additions & 3 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ project:
# Change port if it's busy in your system or just remove this line so that It will automatically use any free port
port: 4200
browser: true
pre-render:
- sh assets/scripts/changelog.sh
- sh assets/scripts/versions.sh

# These cannot be used as variables. They are reserved for the project configuration.
website:
Expand Down

0 comments on commit 8aa4631

Please sign in to comment.