|
1 | 1 | using Pkg |
2 | 2 | Pkg.activate(@__DIR__) |
3 | 3 |
|
4 | | -using Downloads, Tar, ArtifactUtils, Artifacts, Dates, Pkg |
| 4 | +using Downloads, Tar, ArtifactUtils, Artifacts, Dates, JSON3 |
5 | 5 |
|
6 | 6 | #-----------------------------------------------------------------------------# Start from scratch |
7 | | -for file in readdir(@__DIR__) |
8 | | - if endswith(file, ".tar") || endswith(file, ".gz") |
9 | | - rm(joinpath(@__DIR__, file), force=true) |
10 | | - end |
11 | | -end |
| 7 | +rm("plotlylight_artifacts.tar.gz", force=true) |
| 8 | +dir = mkpath(joinpath(@__DIR__, "plotly_artifacts")) |
12 | 9 |
|
13 | 10 | #-----------------------------------------------------------------------------# Templates |
14 | 11 | # Need to install plotly.py in order to get themes because they are generated in python |
15 | | -# run(`conda create -n conda_jl python conda`) |
16 | | -# ENV["CONDA_JL_HOME"] = "/opt/homebrew/Caskroom/miniconda/base/envs/conda_jl" |
17 | | -# Pkg.build("Conda") |
18 | | -# using Conda |
19 | | -# Conda.add("plotly") |
20 | | - |
21 | | -dir = "/opt/homebrew/Caskroom/miniconda/base/envs/conda_jl/pkgs" |
22 | | -templates = joinpath(dir, filter(x -> startswith(x, "plotly"), readdir(dir))[1], "site-packages/plotly/package_data/templates") |
23 | | - |
24 | | - |
25 | | -run(`gzip $(Tar.create(templates, joinpath(@__DIR__, "templates.tar")))`) |
26 | | - |
| 12 | +run(`conda env remove -n _plotly_artifacts`) # start from scratch |
| 13 | +run(`conda create -n _plotly_artifacts -y`) # create env |
| 14 | +run(`conda install -y plotly -n _plotly_artifacts`) |
| 15 | + |
| 16 | +# get path of `_plotly_artifacts` env |
| 17 | +io = IOBuffer() |
| 18 | +# run(pipeline(`conda info --json`, stdout=io)) |
| 19 | +run(pipeline(`conda list -n _plotly_artifacts --json`; stdout=io)) |
| 20 | +pkgs = JSON3.read(String(take!(io))) |
| 21 | +metadata = only(filter(x -> x.name == "plotly", pkgs)) |
| 22 | +template_dir = "/opt/homebrew/Caskroom/miniconda/base/pkgs/$(metadata.dist_name)/lib/python3.10/site-packages/plotly/package_data/templates/" |
| 23 | +for file in readdir(template_dir) |
| 24 | + cp(joinpath(template_dir, file), joinpath(dir, file)) |
| 25 | +end |
27 | 26 |
|
28 | | -#-----------------------------------------------------------------------------# Plotly.js |
29 | | -url = "https://cdn.plot.ly/plotly-2.14.0.min.js" |
| 27 | +#-----------------------------------------------------------------------------# plotly.min.js |
| 28 | +url = "https://cdn.plot.ly/plotly-2.16.1.min.js" |
30 | 29 | file = basename(url) |
31 | | -dir = mkpath(joinpath(@__DIR__, "plotlyjs")) |
32 | 30 | Downloads.download(url, joinpath(dir, file)) |
33 | 31 |
|
34 | | -run(`gzip $(Tar.create(dir, joinpath(@__DIR__, "plotly.tar")))`) |
| 32 | +#-----------------------------------------------------------------------------# schema |
| 33 | +schema_url = "https://api.plot.ly/v2/plot-schema?format=json&sha1=%27%27" |
| 34 | +Downloads.download(schema_url, joinpath(dir, "schema.json")) |
| 35 | + |
| 36 | +#-----------------------------------------------------------------------------# tar it up |
| 37 | +run(`gzip $(Tar.create(dir, joinpath(@__DIR__, "plotly_artifacts.tar")))`) |
35 | 38 |
|
36 | 39 | #-----------------------------------------------------------------------------# upload |
37 | 40 | try |
38 | 41 | artifacts_today = "artifacts_$(today())" |
39 | 42 |
|
40 | | - run(`gh release create $artifacts_today $(joinpath(@__DIR__, "templates.tar.gz")) $(joinpath(@__DIR__, "plotly.tar.gz")) --title $artifacts_today --notes ""`) |
| 43 | + run(`gh release create $artifacts_today $(joinpath(@__DIR__, "plotly_artifacts.tar.gz")) --title $artifacts_today --notes ""`) |
41 | 44 |
|
42 | 45 | @info "Sleeping so artifacts are ready on GitHub..." |
43 | 46 | sleep(10) |
44 | 47 | add_artifact!( |
45 | 48 | "Artifacts.toml", |
46 | | - "plotly.min.js", |
47 | | - "https://github.com/joshday/PlotlyLight.jl/releases/download/$artifacts_today/plotly.tar.gz", |
48 | | - force=true, |
49 | | - ) |
50 | | - add_artifact!( |
51 | | - "Artifacts.toml", |
52 | | - "plotly_templates", |
53 | | - "https://github.com/joshday/PlotlyLight.jl/releases/download/$artifacts_today/templates.tar.gz", |
| 49 | + "plotlylight", |
| 50 | + "https://github.com/joshday/PlotlyLight.jl/releases/download/$artifacts_today/plotly_artifacts.tar.gz", |
54 | 51 | force=true, |
55 | 52 | ) |
56 | 53 | catch ex |
|
0 commit comments