Trouble publishing my first package to GitHub

Thanks @lmiq. The JuliaNotes page helped me get on the right path, and then I had to figure out a few things on my own. I also found this excellent tutorial for developing new packages, but unfortunately that page appears to be outdated and might lead to errors. Here are the steps that worked for me:

1. Make a new repo via the GitHub web interface.

Log in to GitHub, click the Repositories tab, and then click New.

Name the repository something ending in .jl, without spaces or special characters. If multiple words are in the package name, capitalize the first letter of each word (e.g., MyPackage.jl). Here, my package is named Foo, so I’ve named the repository Foo.jl:

On the same page, I set my repo to Private and clicked Create repository:

2. Initialize the package in Julia using PkgTemplates

Launch VS Code, press Ctrl+shift+p and click “Julia: Start REPL”. Then, in the REPL, add the PkgTemplates package if you haven’t already, and type:

using PkgTemplates 
t = Template(;user="chadagreene", plugins = [GitHubActions(), Codecov()])
t("/Users/cgreene/Documents/GitHub/Foo.jl")

Above, I entered my GitHub username, and I also specified the local directory where I want my package to exist on my computer. Specifying the local directory is important for me, as a beginner, because by default, the package management system puts everything in a hidden folder. If you want to see, explore, and easily interact with the files in your new package, specify the filepath to your preferred location as I’ve done above.

And of course, make sure the file path ends in the same name as the repo you just created on GitHub (above, you see that the path ends in Foo.jl).

The three lines of code above create a folder called Foo.jl on your local machine. Again, if you don’t specify a directory, it will end up in a hidden folder called ~/.julia/dev/Foo, but I’ve placed mine in my /Users/cgreene/Documents/GitHub/Foo folder.

Note: there’s some inconsistency in how PkgTemplates names the folder it creates. Although you need to specify the package name ending in .jl when using PkgTemplates, and you must also end the GitHub repo name with .jl, the folder that PkgTemplates creates will just be Foo, without the .jl.

3. Publish the new package via GitHub Desktop

Launch GitHub Desktop, click Add and Add Existing Repository, like this:

Now, specify the same directory that we entered into the Julia REPL, and click Add Repository:

Click Publish branch:

Screenshot 2023-01-22 at 5.51.04 PM

4. Check online to confirm existence of new repo:

Now if you refresh your Repositories tab online, you should see that the new package template has made it into your online repo:

10 Likes