Auto-release on Chocolatey

This commit is contained in:
Natalie Weizenbaum 2018-02-04 16:12:33 -08:00
parent 01e768c885
commit 92e8230e32
3 changed files with 60 additions and 1 deletions

View File

@ -42,3 +42,7 @@ git config --local user.name "Natalie Weizenbaum"
git config --local user.email "nweiz@google.com"
travis_cmd pub run grinder update_homebrew
travis_fold end homebrew
travis_fold start chocolatey
travis_cmd pub run grinder update_chocolatey
travis_fold end chocolatey

28
tool/godaddy.pem Normal file
View File

@ -0,0 +1,28 @@
-----BEGIN CERTIFICATE-----
MIIE0DCCA7igAwIBAgIBBzANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx
EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT
EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp
ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTExMDUwMzA3MDAwMFoXDTMxMDUwMzA3
MDAwMFowgbQxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH
EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjEtMCsGA1UE
CxMkaHR0cDovL2NlcnRzLmdvZGFkZHkuY29tL3JlcG9zaXRvcnkvMTMwMQYDVQQD
EypHbyBEYWRkeSBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IC0gRzIwggEi
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC54MsQ1K92vdSTYuswZLiBCGzD
BNliF44v/z5lz4/OYuY8UhzaFkVLVat4a2ODYpDOD2lsmcgaFItMzEUz6ojcnqOv
K/6AYZ15V8TPLvQ/MDxdR/yaFrzDN5ZBUY4RS1T4KL7QjL7wMDge87Am+GZHY23e
cSZHjzhHU9FGHbTj3ADqRay9vHHZqm8A29vNMDp5T19MR/gd71vCxJ1gO7GyQ5HY
pDNO6rPWJ0+tJYqlxvTV0KaudAVkV4i1RFXULSo6Pvi4vekyCgKUZMQWOlDxSq7n
eTOvDCAHf+jfBDnCaQJsY1L6d8EbyHSHyLmTGFBUNUtpTrw700kuH9zB0lL7AgMB
AAGjggEaMIIBFjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV
HQ4EFgQUQMK9J47MNIMwojPX+2yz8LQsgM4wHwYDVR0jBBgwFoAUOpqFBxBnKLbv
9r0FQW4gwZTaD94wNAYIKwYBBQUHAQEEKDAmMCQGCCsGAQUFBzABhhhodHRwOi8v
b2NzcC5nb2RhZGR5LmNvbS8wNQYDVR0fBC4wLDAqoCigJoYkaHR0cDovL2NybC5n
b2RhZGR5LmNvbS9nZHJvb3QtZzIuY3JsMEYGA1UdIAQ/MD0wOwYEVR0gADAzMDEG
CCsGAQUFBwIBFiVodHRwczovL2NlcnRzLmdvZGFkZHkuY29tL3JlcG9zaXRvcnkv
MA0GCSqGSIb3DQEBCwUAA4IBAQAIfmyTEMg4uJapkEv/oV9PBO9sPpyIBslQj6Zz
91cxG7685C/b+LrTW+C05+Z5Yg4MotdqY3MxtfWoSKQ7CC2iXZDXtHwlTxFWMMS2
RJ17LJ3lXubvDGGqv+QqG+6EnriDfcFDzkSnE3ANkR/0yBOtg2DZ2HKocyQetawi
DsoXiWJYRBuriSUBAA/NxBti21G00w9RKpv0vHP8ds42pM3Z2Czqrpv1KrKQ0U11
GIo/ikGQI31bS/6kA1ibRrLDYGCD+H1QQc7CoZDDu+8CL9IVVO5EFdkKrqeKM+2x
LXY2JtwE65/3YR8V3Idv7kaWKK2hJn0KCacuBKONvPi8BDAB
-----END CERTIFICATE-----

View File

@ -277,6 +277,33 @@ This package is Dart Sass, the new Dart implementation of Sass.
return builder.build() as xml.XmlDocument;
}
@Task('Upload the Chocolatey package to the current version.')
@Depends(chocolatey_package)
update_chocolatey() async {
// For some reason, although Chrome seems able to access it just fine,
// command-line tools don't seem to be able to verify the certificate for
// Chocolatey, so we need to manually add the intermediate GoDaddy certificate
// to the security context.
SecurityContext.defaultContext.setTrustedCertificates("tool/godaddy.pem");
var request = new http.MultipartRequest(
"PUT", Uri.parse("https://push.chocolatey.org/api/v2/package"));
request.headers["X-NuGet-Protocol-Version"] = "4.1.0";
request.headers["X-NuGet-ApiKey"] =
new File("choco").readAsStringSync().trim();
request.files.add(await http.MultipartFile
.fromPath("package", "build/sass.${_chocolateyVersion()}.nupkg"));
var response = await request.send();
if (response.statusCode ~/ 100 != 2) {
fail("${response.statusCode} error creating release:\n"
"${await response.stream.bytesToString()}");
} else {
log("Released Dart Sass ${_chocolateyVersion()} to Chocolatey.");
response.stream.listen(null).cancel();
}
}
/// The current Sass version, formatted for Chocolatey which doesn't allow dots
/// in prerelease versions.
String _chocolateyVersion() {
@ -494,7 +521,7 @@ github_release() async {
if (response.statusCode != 201) {
fail("${response.statusCode} error creating release:\n${response.body}");
} else {
log("Released Dart Sass $_version.");
log("Released Dart Sass $_version to GitHub.");
}
var uploadUrl = JSON