Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for actual CI deploy #16

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
using Website
using Website.Bonito

begin
println("####################")
println(Website.img_asset())
println(readdir(Website.img_asset().local_path))
println(readdir(Website.img_asset("logos").local_path))
println("####################")
end

# Use for interactive dev
# routes, task, server = interactive_server(Website.asset_paths()) do
# return Routes(
Expand All @@ -30,15 +22,14 @@ routes = Routes(
dir = joinpath(@__DIR__, "build")
!isdir(dir) && mkdir(dir)
Bonito.export_static(dir, routes)
cp(joinpath(@__DIR__, "..", "assets", "images", "favicon.ico"), joinpath(dir, "favicon.ico"); force=true)

using Documenter

docs_url = "makie.org"
repo = "github.com/MakieOrg/Website.git"
push_preview = true
devbranch = "sd/jsserve"
devurl = "dev"
devbranch = "main"
devurl = "website"
include("utils.jl")

params = deployparameters(; repo, devbranch, devurl, push_preview)
Expand Down
43 changes: 1 addition & 42 deletions docs/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
function deployparameters(; repo, push_preview, devbranch, devurl)
cfg = Documenter.GitHubActions()
deploy_decision = Documenter.deploy_folder(cfg; repo, push_preview, devbranch, devurl)
@show deploy_decision.subfolder
(;
all_ok=deploy_decision.all_ok,
branch=deploy_decision.branch,
Expand Down Expand Up @@ -101,48 +102,6 @@ function push_build(;
# Copy docs to `subfolder` directory.
deploy_dir = subfolder === nothing ? dirname : joinpath(dirname, subfolder)
Documenter.gitrm_copy(target_dir, deploy_dir)

open(joinpath(deploy_dir, "siteinfo.js"), "w") do io
println(
io,
"""
var DOCUMENTER_CURRENT_VERSION = "$subfolder";
"""
)
end

all_folders = [x for x in readdir(dirname) if isdir(joinpath(dirname, x))]
version_folders = filter(all_folders) do x
tryparse(VersionNumber, x) !== nothing
end
sort!(version_folders, by=VersionNumber, rev=true)

max_version = version_folders[begin]

open(joinpath(dirname, "versions.js"), "w") do io
println(
io,
"""
var DOCUMENTER_NEWEST = "$max_version";
var DOCUMENTER_STABLE = "stable";
"""
)

println(io, "var DOC_VERSIONS = [")
for folder in ["stable"; version_folders; "dev"]
println(io, " \"", folder, "\",")
end
println(io, "];")
end

# generate the sitemap only for the highest version so google doesn't advertise old docs
generate_sitemap(dirname, max_version)

stablelink = joinpath(dirname, "stable")
rm(stablelink, force=true)
rm(stablelink, recursive=true, force=true)
symlink(max_version, stablelink; dir_target=true)

# Add, commit, and push the docs to the remote.
run(`$(git()) add -A .`)
if !success(`$(git()) diff --cached --exit-code`)
Expand Down
1 change: 1 addition & 0 deletions src/contributor.json

Large diffs are not rendered by default.

29 changes: 20 additions & 9 deletions src/github.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const GITHUB_OWNERS = Dict{String,GitHub.Owner}()

function gh_owner(name)
get!(GITHUB_OWNERS, name) do
println("api call")
GitHub.owner(name)
end
end
Expand All @@ -20,14 +19,26 @@ function all_contributors(repo::String)
repo(repo)
contributors(repo)
end
OWNERS = []
let
# # A bit shady, but a nice way to serialzie the owners at precompile
# # So we don't make any further requests to the github API while developing
# # which helps to not run into githus API limits
# makie_repo = GitHub.repo("MakieOrg/Makie.jl")

# contribs = GitHub.contributors(makie_repo)
const OWNERS = open(joinpath(@__DIR__, "contributor.json")) do io
array = GitHub.JSON.parse(io)
to_kw(o) = map(x -> Symbol(x[1]) => x[2], collect(pairs(o)))
map(o -> GitHub.Owner(; to_kw(o)...), array)
end

#=
# contributor.json Created with the following code:
to_value(uri::GitHub.URIs.URI) = string(uri)
to_value(x) = x
function to_dict(d)
o = d["contributor"]
pairs = [f => to_value(getproperty(o, f)) for f in propertynames(o)]
Dict(filter(((k, v),)-> (k!=:site_admin) && (!isnothing(v)), pairs))
end

# global OWNERS = [owner["contributor"] for owner in contribs[1]]
makie_repo = GitHub.repo("MakieOrg/Makie.jl")
contribs = GitHub.contributors(makie_repo)
open("contributor.json", "w") do io
JSON.print(io, map(to_dict, contribs[1]))
end
=#