This repository has been archived by the owner on Jul 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4601024
commit 3c832a8
Showing
2 changed files
with
53 additions
and
23 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,63 @@ | ||
# Artifact generator for the assets directory. | ||
# | ||
# Requires: | ||
# | ||
# - A github token stored in `ENV["GITHUB_AUTH"]` with access to `repo` read/write. | ||
# - Extra packages: `ghr_jll` for release uploading. | ||
# | ||
# Usage: | ||
# | ||
# - Update files in `/assets` directory. | ||
# - Bump the `version` variable below. | ||
# - Run `rebuild_artifacts()` to create new tarball and update Artifacts.toml. | ||
# - Commit the changes. | ||
# - Run `release_artifacts()` to create a new release and upload the new tarball. | ||
# | ||
|
||
using Pkg.Artifacts | ||
using URIs | ||
using ghr_jll | ||
using LibGit2 | ||
|
||
version = v"0.1.0" | ||
host = "https://github.com/JuliaPlots/AbstractPlotting.jl/releases/download" | ||
user = "JuliaPlots" | ||
repo = "AbstractPlotting.jl" | ||
host = "https://github.com/$user/$repo/releases/download" | ||
|
||
build_path = joinpath(@__DIR__, "build") | ||
assets_path = joinpath(@__DIR__, "assets") | ||
artifact_toml = joinpath(@__DIR__, "Artifacts.toml") | ||
|
||
function rebuild_artifacts() | ||
ispath(build_path) && rm(build_path, force=true, recursive=true) | ||
mkpath(build_path) | ||
|
||
product_hash = create_artifact() do artifact_dir | ||
cp(assets_path, artifact_dir; force = true) | ||
end | ||
|
||
ispath(build_path) && rm(build_path, force=true, recursive=true) | ||
mkpath(build_path) | ||
archive_filename = "assets-$version.tar.gz" | ||
download_hash = archive_artifact(product_hash, joinpath(build_path, archive_filename)) | ||
|
||
product_hash = create_artifact() do artifact_dir | ||
cp(joinpath(@__DIR__, "assets"), artifact_dir; force = true) | ||
bind_artifact!( | ||
artifact_toml, | ||
"assets", | ||
product_hash, | ||
force = true, | ||
download_info = Tuple[ | ||
( | ||
"$host/assets-$version/$archive_filename", | ||
download_hash, | ||
), | ||
], | ||
) | ||
end | ||
|
||
archive_filename = "assets-$version.tar.gz" | ||
artifact_toml = joinpath(@__DIR__, "Artifacts.toml") | ||
download_hash = archive_artifact(product_hash, joinpath(build_path, archive_filename)) | ||
|
||
bind_artifact!( | ||
artifact_toml, | ||
"assets", | ||
product_hash, | ||
force = true, | ||
download_info = Tuple[ | ||
( | ||
"$host/assets-$(escapeuri(string(version)))/$archive_filename", | ||
download_hash, | ||
), | ||
], | ||
) | ||
function release_artifacts() | ||
name = "Release assets $(version)" | ||
commit = string(LibGit2.GitHash(LibGit2.GitCommit(LibGit2.GitRepo(@__DIR__), "HEAD"))) | ||
token = ENV["GITHUB_AUTH"] | ||
tag = "assets-$version" | ||
ghr() do bin | ||
run(`$bin -u $user -r $repo -n $name -c $commit -t $token $tag $build_path`) | ||
end | ||
end |