Last active
February 26, 2020 04:46
-
-
Save MaximeBouton/8ddc2cff0bc9b664a34b3c165f35360d to your computer and use it in GitHub Desktop.
JuliaPOMDP registration script
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
# usage: julia private_register.jl path/to/package | |
using Pkg | |
pkg"activate ." | |
# Make sure to use known good version of Registrator | |
pkg"add RegistryTools" | |
using RegistryTools | |
const general_reg_url = "https://github.com/JuliaRegistries/General" | |
# Change this to your own registry: | |
const private_reg_url = "https://github.com/JuliaPOMDP/Registry" | |
# const private_reg_url = "https://github.com/sisl/Registry" | |
# TODO: make the private registry the second argument, and let it be specified by name | |
# using the contents of ~/.julia/registries to identify which URL it is | |
function main() | |
println("🆕📦🔜") | |
length(ARGS) != 1 && error("invalid args ($ARGS).\nUsage private_register pathtopackage") | |
pkg_path = string(strip(expanduser(ARGS[1]))) | |
@show pkg_path | |
# Read the project file | |
project_file = Pkg.Types.projectfile_path(pkg_path) | |
project_file === nothing && error("project file for $(pkg_path) not found.") | |
project = Pkg.Types.read_project(project_file) | |
# For a tag: | |
#tree_hash = String(readchomp(`git -C $pkg_path rev-parse v$(project.version)^{tree}`)) | |
# For current HEAD | |
tree_hash = String(readchomp(`git -C $pkg_path rev-parse HEAD^\{tree\}`)) | |
pkg_url = String(readchomp(`git -C $pkg_path remote get-url origin`)) | |
# Register the package | |
# `register` creates local copies of the registries so do the work in a temporary directory | |
cd(mktempdir()) do | |
@show pkg_url | |
regbranch = RegistryTools.register(pkg_url, project, tree_hash; registry=private_reg_url, registry_deps=[general_reg_url], push=true) | |
println(regbranch) | |
end | |
end | |
main() |
and also remove the pkg"add ..."
line, which makes this script slow for me
updated to RegistryTools
😍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We should probably move to using the
register
function fromRegsitryTools.jl