You can do this using the gcloud command-line tool, deploy your function from the directory containing your function code with the gcloud functions deploy command:
gcloud functions deploy NAME --runtime RUNTIME TRIGGER [FLAGS...]
For more info refer to https://cloud.google.com/functions/docs/deploying/filesystem