-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugin-version-upload.php
More file actions
61 lines (53 loc) · 1.68 KB
/
plugin-version-upload.php
File metadata and controls
61 lines (53 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
// Load Composer Dependencies
require __DIR__ . '/vendor/autoload.php';
// Autoload Requests library internal classes
Requests::register_autoloader();
// Set your email and password here. For security purposes,
// you should probably read these in from environment variables.
$email = $argv[1];
$password = $argv[2];
// Plugin ID that we'll uploading a version for.
// You can find this ID by going to the plugin list page in Kernl.
$pluginId = $argv[3];
// The path to zip file for your version.
$filePath = $argv[4];
// The version number
$version = $argv[5];
// Make an authentication request
$authURL = 'https://kernl.us/api/v1/auth';
$authPostData = array(
'email' => $email,
'password' => $password
);
$authResponse = Requests::post($authURL, array(), $authPostData);
if($authResponse->status_code != 200) {
die("\nInvalid email or password.\n\n");
}
$authToken = $authResponse->body;
// Create a CURl request and upload the new version
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https:/kernl.us/api/v1/plugins/$pluginId/versions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array(
'file'=> new CURLFILE($filePath),
'changelog' => 'none',
'fileSize' => '0',
's3Url' => 'none',
'version' => $version),
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $authToken"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>