Improvements to docs infrastructure #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Turing.jl version | |
on: | |
push: | |
branches: | |
- master | |
- backport-* | |
pull_request: | |
branches: | |
- master | |
- backport-* | |
workflow_dispatch: | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
# Determine whether the target branch is master. If so, also make sure to check that the | |
# version matches the latest release of Turing.jl. | |
env: | |
TARGET_IS_MASTER: ${{ (github.event_name == 'push' && github.ref_name == 'master') || (github.event_name == 'pull_request' && github.base_ref == 'master') }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Julia | |
uses: julia-actions/setup-julia@v2 | |
- name: Log GitHub context variables | |
run: | | |
echo github.event_name: ${{ github.event_name }} | |
echo github.ref_name: ${{ github.ref_name }} | |
echo github.base_ref: ${{ github.base_ref }} | |
echo TARGET_IS_MASTER: ${{ env.TARGET_IS_MASTER }} | |
- name: Check version consistency between Project.toml / _quarto.yml ${{ env.TARGET_IS_MASTER && ' / latest release' || '' }} | |
shell: julia --color=yes --project=. {0} | |
run: | | |
using Pkg | |
Pkg.activate(temp=true) | |
Pkg.add(["YAML", "TOML", "JSON", "HTTP"]) | |
import YAML | |
import TOML | |
import JSON | |
import HTTP | |
function major_minor_match(v1::VersionNumber, v2::VersionNumber) | |
return v1.:major == v2.:major && v1.:minor == v2.:minor | |
end | |
quarto_yaml = YAML.load_file("_quarto.yml") | |
quarto_version = VersionNumber(quarto_yaml["website"]["navbar"]["right"][1]["text"]) | |
println("_quarto.yml version: ", quarto_version) | |
project_toml = TOML.parsefile("Project.toml") | |
project_version = VersionNumber(project_toml["compat"]["Turing"]) | |
println("Project.toml version: ", project_version) | |
if ENV["TARGET_IS_MASTER"] == "true" | |
resp = HTTP.get("https://api.github.com/repos/TuringLang/Turing.jl/releases/latest") | |
latest_version = VersionNumber(JSON.parse(String(resp.body))["tag_name"]) | |
println("Latest Turing.jl version: ", latest_version) | |
if !major_minor_match(latest_version, project_version) || !major_minor_match(latest_version, quarto_version) | |
error("The latest version of Turing.jl (as determined from GitHub releases) is $latest_version. | |
* Please update Project.toml and/or _quarto.yml to match this version.") | |
end | |
else | |
if !major_minor_match(quarto_version, project_version) | |
error("The versions of Turing.jl in _quarto.yml and Project.toml do not match.") | |
end | |
end |