Skip to content

Instantly share code, notes, and snippets.

@MaximeBouton
Last active February 26, 2020 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaximeBouton/8ddc2cff0bc9b664a34b3c165f35360d to your computer and use it in GitHub Desktop.
Save MaximeBouton/8ddc2cff0bc9b664a34b3c165f35360d to your computer and use it in GitHub Desktop.
JuliaPOMDP registration script
# 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()
@rejuvyesh
Copy link

We should probably move to using the register function from RegsitryTools.jl

@MaximeBouton
Copy link
Author

and also remove the pkg"add ..." line, which makes this script slow for me

@MaximeBouton
Copy link
Author

updated to RegistryTools

@rejuvyesh
Copy link

😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment