Agustus 14, 2012

Working with GitHub and Clojars


This guide is used as a note for myself. If you can benefit from this note, that's fine. Here I just wish to document how I work with GitHub and Clojars. I need to do this since I have my own need for Ring middleware to reload automatically a server without restart whenever a namespace in Ring is modified. The original version was not maintained I think, since it uses Clojure 1.2.0.

GitHub

I forked the ring-reload-modified to my Github account. This can be done easily using step 1 and 2 from https://help.github.com/articles/fork-a-repo (I use only step 1 and 2 since I only want to fork and modified my forked version, not upstream version).

Let's say for this time I just want to edit the README.md and project.clj files. After I edit those files, I just put them in committed state:

[bpdp@bpdp-arch ring-reload-modified]$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add [file]..." to update what will be committed)
#   (use "git checkout -- [file]..." to discard changes in working directory)
#
# modified:   README.md
# modified:   project.clj
#
no changes added to commit (use "git add" and/or "git commit -a")
[bpdp@bpdp-arch ring-reload-modified]$

We can see from the status that it has 2 changes: README.md and project.clj but I haven't commit anything. Here's how to commit:

[bpdp@bpdp-arch ring-reload-modified]$ git commit -a
[master ada41aa] Adjust to latest Clojure version (1.4.0)
 2 files changed, 8 insertions(+), 4 deletions(-)
[bpdp@bpdp-arch ring-reload-modified]$ 

Then it's time to push the committed version to Github repository:

 [bpdp@bpdp-arch ring-reload-modified]$ git push origin master
 Username for 'https://github.com': bpdp
 Password for 'https://bpdp@github.com': 
 Counting objects: 7, done.
 Delta compression using up to 2 threads.
 Compressing objects: 100% (4/4), done.
 Writing objects: 100% (4/4), 721 bytes, done.
 Total 4 (delta 2), reused 0 (delta 0)
 To https://github.com/bpdp/ring-reload-modified.git
    6dfdc5c..ada41aa  master -> master
 [bpdp@bpdp-arch ring-reload-modified]$

Let's see the result in Github profile:



The result in Github project page (I have pushed another commit so the history is different with above).



Clojars

To upload the library, I need to prepare my ssh public key first:

[bpdp@bpdp-arch ring-reload-modified]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/bpdp/.ssh/id_rsa): 
/home/bpdp/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/bpdp/.ssh/id_rsa.
Your public key has been saved in /home/bpdp/.ssh/id_rsa.pub.
The key fingerprint is:
87:fc:8f:35:18:20:2e:8f:73:d2:b5:71:ea:0e:85:01 bpdp@bpdp-arch
The key's randomart image is:
+--[ RSA 2048]----+
|    E            |
|     .           |
|      o .        |
|     . = o       |
|    . o S +      |
|     = o B o     |
|    + = o o o    |
|     + o   + .   |
|       .o . .    |
+-----------------+
[bpdp@bpdp-arch ring-reload-modified]$

The public key should be put into the Clojars first. So, first we need to register by using http://clojars.org/register:



Now, it's time to upload to Clojars:

[bpdp@bpdp-arch ring-reload-modified]$ lein2 jar   
Created /home/bpdp/master/clojure/libs/ring-reload-modified/target/ring-reload-modified-0.1.2.jar
[bpdp@bpdp-arch ring-reload-modified]$ lein2 pom
Wrote /home/bpdp/master/clojure/libs/ring-reload-modified/pom.xml
[bpdp@bpdp-arch ring-reload-modified]$ scp pom.xml target/ring-reload-modified-0.1.2.jar clojars@clojars.org:
Enter passphrase for key '/home/bpdp/.ssh/id_rsa': 
Welcome to Clojars, bpdp!
pom.xml                                                           100% 2672     2.6KB/s   00:00    
ring-reload-modified-0.1.2.jar                                    100% 5328     5.2KB/s   00:00    

Deploying org.clojars.bpdp/ring-reload-modified 0.1.2

Success! Your jars are now available from http://clojars.org/
[bpdp@bpdp-arch ring-reload-modified]$

Now I can use the library that I upload to Clojars:



That's all big guy. Have a happy hacking!


0 comments:

Posting Komentar