Skip to content

Commit b5dc8b4

Browse files
leoafariasnex3
andauthored
Fix Chocolatey deployment (#56)
Closes #49 Co-authored-by: Natalie Weizenbaum <[email protected]>
1 parent 7102d39 commit b5dc8b4

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.0.0-beta.12
2+
3+
* Deploy Chocolatey packages as source files rather than a zip file, to avoid
4+
validation errors around the need for a `VERIFICATION` file.
5+
16
# 1.0.0-beta.11
27

38
* Properly load the Dart SDK license when it's in the directory above the SDK,

lib/src/chocolatey.dart

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import 'dart:convert';
1616
import 'dart:io';
1717

18-
import 'package:archive/archive.dart';
1918
import 'package:grinder/grinder.dart';
2019
import 'package:meta/meta.dart';
2120
import 'package:path/path.dart' as p;
@@ -213,31 +212,28 @@ Future<void> _build() async {
213212
dir.createSync(recursive: true);
214213

215214
writeString("build/chocolatey/$_chocolateyName.nuspec", _nuspec.toString());
216-
Directory("build/chocolatey/tools").createSync();
215+
Directory("build/chocolatey/tools/source").createSync(recursive: true);
216+
217217
writeString("build/chocolatey/tools/LICENSE", await license);
218218

219-
var sourceFiles = Archive()
220-
..addFile(fileFromString(
221-
"source/pubspec.yaml",
222-
// Don't download useless dev dependencies to users' computers.
223-
json.encode(Map.of(rawPubspec)
224-
..remove('dev_dependencies')
225-
..remove('dependency_overrides'))));
219+
writeString(
220+
'build/chocolatey/tools/source/pubspec.yaml',
221+
json.encode(Map.of(rawPubspec)
222+
..remove('dev_dependencies')
223+
..remove('dependency_overrides')));
224+
226225
for (var path in chocolateyFiles.value) {
227226
var relative = p.relative(path);
228227
if (relative == 'pubspec.yaml') continue;
229-
sourceFiles.addFile(file(p.join('source', relative), path));
228+
229+
safeCopy(
230+
relative, p.join('build/chocolatey/tools/source', p.dirname(path)));
230231
}
231-
writeBytes(
232-
"build/chocolatey/tools/source.zip", ZipEncoder().encode(sourceFiles));
233232

234233
var install = StringBuffer("""
235234
\$ToolsDir = (Split-Path -parent \$MyInvocation.MyCommand.Definition)
236-
Get-ChocolateyUnzip -PackageName '$_chocolateyName' `
237-
-File "\$ToolsDir\\source.zip" -Destination \$PackageFolder
238-
239235
Write-Host "Fetching Dart dependencies..."
240-
\$SourceDir = "\$PackageFolder\\source"
236+
\$SourceDir = "\$ToolsDir\\source"
241237
Push-Location -Path \$SourceDir
242238
pub get --no-precompile | Out-Null
243239
Pop-Location
@@ -276,10 +272,16 @@ Future<void> _nupkg() async {
276272

277273
/// Deploys the Chocolatey package to Chocolatey.
278274
Future<void> _deploy() async {
279-
var nupkgPath = "build/$_chocolateyName.$_chocolateyVersion.nupkg";
275+
var nupkgPath = p.join("build", "$_chocolateyName.$_chocolateyVersion.nupkg");
280276
log("choco push --source https://chocolatey.org --key=... $nupkgPath");
281-
var process = await Process.start("choco",
282-
["push", "--source", "https://chocolatey.org", "--key", nupkgPath]);
277+
var process = await Process.start("choco", [
278+
"push",
279+
nupkgPath,
280+
"--source",
281+
"https://chocolatey.org",
282+
"--key",
283+
"$chocolateyToken"
284+
]);
283285
LineSplitter().bind(utf8.decoder.bind(process.stdout)).listen(log);
284286
LineSplitter().bind(utf8.decoder.bind(process.stderr)).listen(log);
285287
if (await process.exitCode != 0) fail("choco push failed");

lib/src/utils.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ void writeBytes(String path, List<int> contents) {
280280
/// Like Grinder's [copy], but without Windows bugs (google/grinder.dart#345).
281281
void safeCopy(String source, String destination) {
282282
log("copying $source to $destination");
283+
Directory(destination).createSync(recursive: true);
283284
File(source).copySync(p.join(destination, p.basename(source)));
284285
}
285286

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cli_pkg
2-
version: 1.0.0-beta.11
2+
version: 1.0.0-beta.12
33
description: Grinder tasks for releasing Dart CLI packages.
44
homepage: https://github.com/google/dart_cli_pkg
55

0 commit comments

Comments
 (0)