Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.

Commit 7afeed2

Browse files
committed
Merge branch 'mh/assets-artifact' of https://github.com/MichaelHatherly/AbstractPlotting.jl into MichaelHatherly-mh/assets-artifact
2 parents 2fffa97 + 3c832a8 commit 7afeed2

File tree

6 files changed

+74
-2
lines changed

6 files changed

+74
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ phases.0001_print.jpg
1212
**/._*
1313
Manifest.toml
1414
!docs/Manifest.toml
15+
/build
1516

1617
\.DS_Store

Artifacts.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[assets]
2+
git-tree-sha1 = "a74800f299f6bdade309e459b999442f303aa64d"
3+
4+
[[assets.download]]
5+
sha256 = "aa8d3e891da5c0757620f0bad9f9cd78e2e843bbc31773b5759e4f54e4f92b2b"
6+
url = "https://github.com/JuliaPlots/AbstractPlotting.jl/releases/download/assets-0.1.0/assets-0.1.0.tar.gz"

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ version = "0.18.2"
55

66
[deps]
77
Animations = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
8+
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
89
ColorBrewer = "a2cac450-b92f-5266-8821-25eda20663c8"
910
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
1011
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"

artifacts.jl

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Artifact generator for the assets directory.
2+
#
3+
# Requires:
4+
#
5+
# - A github token stored in `ENV["GITHUB_AUTH"]` with access to `repo` read/write.
6+
# - Extra packages: `ghr_jll` for release uploading.
7+
#
8+
# Usage:
9+
#
10+
# - Update files in `/assets` directory.
11+
# - Bump the `version` variable below.
12+
# - Run `rebuild_artifacts()` to create new tarball and update Artifacts.toml.
13+
# - Commit the changes.
14+
# - Run `release_artifacts()` to create a new release and upload the new tarball.
15+
#
16+
17+
using Pkg.Artifacts
18+
using ghr_jll
19+
using LibGit2
20+
21+
version = v"0.1.0"
22+
user = "JuliaPlots"
23+
repo = "AbstractPlotting.jl"
24+
host = "https://github.com/$user/$repo/releases/download"
25+
26+
build_path = joinpath(@__DIR__, "build")
27+
assets_path = joinpath(@__DIR__, "assets")
28+
artifact_toml = joinpath(@__DIR__, "Artifacts.toml")
29+
30+
function rebuild_artifacts()
31+
ispath(build_path) && rm(build_path, force=true, recursive=true)
32+
mkpath(build_path)
33+
34+
product_hash = create_artifact() do artifact_dir
35+
cp(assets_path, artifact_dir; force = true)
36+
end
37+
38+
archive_filename = "assets-$version.tar.gz"
39+
download_hash = archive_artifact(product_hash, joinpath(build_path, archive_filename))
40+
41+
bind_artifact!(
42+
artifact_toml,
43+
"assets",
44+
product_hash,
45+
force = true,
46+
download_info = Tuple[
47+
(
48+
"$host/assets-$version/$archive_filename",
49+
download_hash,
50+
),
51+
],
52+
)
53+
end
54+
55+
function release_artifacts()
56+
name = "Release assets $(version)"
57+
commit = string(LibGit2.GitHash(LibGit2.GitCommit(LibGit2.GitRepo(@__DIR__), "HEAD")))
58+
token = ENV["GITHUB_AUTH"]
59+
tag = "assets-$version"
60+
ghr() do bin
61+
run(`$bin -u $user -r $repo -n $name -c $commit -t $token $tag $build_path`)
62+
end
63+
end

src/AbstractPlotting.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module AbstractPlotting
22

3+
using Artifacts
34
using Random
45
using FFMPEG # get FFMPEG on any system!
56
using Observables, GeometryBasics, IntervalSets, PlotUtils
@@ -242,7 +243,7 @@ export cgrad, available_gradients, showgradients
242243

243244
export Pattern
244245

245-
assetpath(files...) = normpath(joinpath(@__DIR__, "..", "assets", files...))
246+
assetpath(files...) = normpath(joinpath(artifact"assets", files...))
246247

247248
export assetpath
248249
# default icon for Makie

src/conversions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ function convert_attribute(x::Union{Symbol, String}, k::key"font")
915915
end
916916
end
917917

918-
fontpath = joinpath(@__DIR__, "..", "assets", "fonts")
918+
fontpath = assetpath("fonts")
919919
font = FreeTypeAbstraction.findfont(str; additional_fonts=fontpath)
920920
if font === nothing
921921
@warn("Could not find font $str, using Dejavu Sans")

0 commit comments

Comments
 (0)