Skip to content

Commit

Permalink
Add flutter support (#155)
Browse files Browse the repository at this point in the history
* Add flutter support

* Add changelog

* Rev version

* Fix small bug in health
  • Loading branch information
mosuem authored Aug 31, 2023
1 parent 65817bf commit 8fa89c6
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 73 deletions.
1 change: 1 addition & 0 deletions pkgs/base_repo
Submodule base_repo added at 65817b
3 changes: 3 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.3.26

- Add support for Flutter package auto-publishing, fixing [#154](https://github.com/dart-lang/ecosystem/issues/154).
## 0.3.25

- Switch to pub.dev API in `package:firehose`.
Expand Down
35 changes: 28 additions & 7 deletions pkgs/firehose/lib/firehose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati
print('Validating $package:${package.name}');

print('pubspec:');
var pubspecVersion = package.pubspec.version;
var pubspecVersion = package.pubspec.version?.toString();
if (pubspecVersion == null) {
var result = Result.fail(
package,
Expand Down Expand Up @@ -146,16 +146,15 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati
var result = Result.info(package, 'already published at pub.dev');
print(result);
results.addResult(result);
} else if (package.pubspec.isPreRelease) {
} else if (package.pubspec.version!.isPreRelease) {
var result = Result.info(
package,
'pre-release version (no publish necessary)',
);
print(result);
results.addResult(result);
} else {
var code = await runCommand('dart',
args: ['pub', 'publish', '--dry-run'], cwd: package.directory);
final code = await _runPublish(package, dryRun: true, force: false);

final ignoreWarnings = github.prLabels.contains(_ignoreWarningsLabel);

Expand Down Expand Up @@ -245,7 +244,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati
print('');

print('pubspec:');
var pubspecVersion = package.pubspec.version;
var pubspecVersion = package.pubspec.version?.toString();
print(' version: $pubspecVersion');

print('changelog:');
Expand All @@ -267,13 +266,35 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati
await runCommand('dart', args: ['pub', 'get'], cwd: package.directory);
print('');

var result = await runCommand('dart',
args: ['pub', 'publish', '--force'], cwd: package.directory);
var result = await _runPublish(package, dryRun: false, force: true);
if (result != 0) {
exitCode = result;
}
return result == 0;
}

Future<int> _runPublish(
Package package, {
required bool dryRun,
required bool force,
}) async {
String command;
if (package.pubspec.dependencies.containsKey('flutter')) {
command = 'flutter';
} else {
command = 'dart';
}
return await runCommand(
command,
args: [
'pub',
'publish',
if (dryRun) '--dry-run',
if (force) '--force',
],
cwd: package.directory,
);
}
}

class VerificationResults {
Expand Down
1 change: 1 addition & 0 deletions pkgs/firehose/lib/src/health/coverage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Coverage {

var filesOfInterest = files
.where((file) => path.extension(file.filename) == '.dart')
.where((file) => file.status != FileStatus.removed)
.where((file) => isInSomePackage(packages, file.relativePath))
.where((file) => isNotATest(packages, file.relativePath))
.toList();
Expand Down
31 changes: 0 additions & 31 deletions pkgs/firehose/lib/src/pubspec.dart

This file was deleted.

11 changes: 7 additions & 4 deletions pkgs/firehose/lib/src/repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'dart:io';

import 'package:firehose/src/changelog.dart';
import 'package:path/path.dart' as path;
import 'package:pubspec_parse/pubspec_parse.dart';
import 'package:yaml/yaml.dart' as yaml;

import 'github.dart';
import 'pubspec.dart';

class Repository {
final Directory baseDirectory;
Expand Down Expand Up @@ -90,13 +90,16 @@ class Package {
late final Changelog changelog;

Package(this.directory, this.repository) {
pubspec = Pubspec(directory);
changelog = Changelog(File(path.join(directory.path, 'CHANGELOG.md')));
pubspec = Pubspec.parse(_getPackageFile('pubspec.yaml').readAsStringSync());
changelog = Changelog(_getPackageFile('CHANGELOG.md'));
}

File _getPackageFile(String fileName) =>
File(path.join(directory.path, fileName));

String get name => pubspec.name;

String? get version => pubspec.version;
String? get version => pubspec.version?.toString();

@override
String toString() {
Expand Down
3 changes: 2 additions & 1 deletion pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
version: 0.3.25
version: 0.3.26
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand All @@ -16,6 +16,7 @@ dependencies:
http: ^0.13.0
path: ^1.8.0
pub_semver: ^2.1.0
pubspec_parse: ^1.2.3
yaml: ^3.1.0

dev_dependencies:
Expand Down
30 changes: 0 additions & 30 deletions pkgs/firehose/test/pubspec_test.dart

This file was deleted.

0 comments on commit 8fa89c6

Please sign in to comment.