FTP upload to Sourceforge with PowerShell
The release system of Sourceforge.net requires to upload your files by FTP to upload.sourceforge.net. The process is basically a pure pain, especially for small files:
-
sourceforge.net
is slow,upload.sourceforge.net
is slow too. -
you need to process your files by FTP whereas it could have been done much more easily through a simple web upload (at least for file that are less then 5MB which must account for 99% of the file released on sourceforge anyway).
-
if you want to re-upload your file, then you cant do it by FTP; you need to go through the SF.net web UI: first release the uploaded file, then delete the released file and finally re-upload your file (the process is maddening).
Anyway, here below is a PowerShell script that I am using to upload files by FTP to sourceforge.net. Save this script into ftp2sf.ps1, then from the PowerShell command-line, just type .\ftp2sf.ps1 'myPackage.zip'
and your file will get upload to sourceforge.net. Then, go through the sourceforge release interface and complete the process.
# ftp2sf.ps1 - FTP UPLOAD TO UPLOAD.SOURCEFORGE.NET
#
# Author: Joannès Vermorel
# https://blog.vermorel.com/
#
# USAGE:
# .\ftp2sf.ps1 'myLocaFile'`
Param( UploadFilePath="filename");UploadFilePath="filename");UploadFilePath = "filename" ); FtpUploadCommand = "PUT `"" + $UploadFilePath + "`"";
$FtpCommandFilePath = \[System.IO.Path\]::GetFullPath("FTPCommand.tmp");
FtpCommands=@("anonymous","myemail@example.com","cdincoming","bin","quotepasv",FtpCommands=@("anonymous","myemail@example.com","cdincoming","bin","quotepasv",FtpCommands = @( "anonymous", "myemail@example.com", "cd incoming" , "bin", "quote pasv", FtpUploadCommand, "quit" );
FtpCommand=\[String\]::Join("‘r‘n",FtpCommand=\[String\]::Join("‘r‘n",FtpCommand = \[String\]::Join( "\`r\`n", FtpCommands );
set-content FtpCommandFilePathFtpCommandFilePathFtpCommandFilePath FtpCommand;
ftp "-s:$FtpCommandFilePath" upload.sourceforge.net;
remove-item $FtpCommandFilePath;