phing: Publish PEAR package to channel

Publishing a PEAR package via a PEAR channel is normally done by uploading the package in the channels admin interface.
While not a being very complicated task it asks for automation when releasing regularly.

So I created a small phing task which uploads a package to a channel server:

   <target name="deploy" description="Upload package to channel server">
    <input propertyname="version" defaultValue="" promptChar="?">Version</input>
    <input propertyname="username" defaultValue="" promptChar="?">Channel-Benutzer</input>
    <input propertyname="password" defaultValue="" promptChar="?">Channel-Passwort</input>
    <property name="channel"></property>
    <property name="uploadFile">_build/PACKAGENAME-${version}.tgz</property>
    <exec command="curl -d "login=Submit&password=${password}&user=${username}" --cookie-jar /tmp/deployCookie -s ${channel} > /dev/null"></exec>
    <exec command="curl -F release=@${uploadFile} -F submitted=1 -F f=0 -F filename=${uploadFile} --cookie /tmp/deployCookie ${channel} > /tmp/deployCheck"></exec>  

I realize that this task lacks any error handling, so you might want to check your channel server afterwards. However so far this worked very well for me.

Pro tip: This is especially nice at the end of a Jenkins Build Pipeline.

This entry was posted in PHP and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s