Skip to content

Commit

Permalink
ci: less automated publishing workflow (#2367)
Browse files Browse the repository at this point in the history
* ci: changing the publishing workflow, CHANGELOG.md and README.md changes are automated by a script that run by the maintainer, publish.yml expect a release tag and will create a GitHub release, avoid hardcoding the master branch in checkout step

* chore: check the pubspec.yaml version after updating the version in the script
  • Loading branch information
EchoEllet authored Nov 10, 2024
1 parent de856f9 commit 9b5d55b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
13 changes: 9 additions & 4 deletions scripts/publish_flutter_quill.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import 'dart:io';

import './update_changelog_version.dart' as update_changelog_version;
import './update_pubspec_version.dart' as update_pubspec_version;
import './update_changelog_version.dart';
import './update_pubspec_version.dart';
import 'pubspec_version_check.dart';

// NOTE: This script is for the maintainers.

Expand Down Expand Up @@ -51,11 +52,15 @@ void main(List<String> args) {
'The Git working tree is not clean. Commit your changes and run again.');
exit(1);
}
update_pubspec_version.updatePubspecVersion(
updatePubspecVersion(
newVersion: version,
pubspecFilePath: _targetPubspecYaml,
);
update_changelog_version.updateChangelogVersion(
checkPubspecVersion(
expectedVersion: version,
pubspecFilePath: _targetPubspecYaml,
);
updateChangelogVersion(
newVersion: version,
changelogFilePath: _targetChangelog,
);
Expand Down
42 changes: 15 additions & 27 deletions scripts/pubspec_version_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,33 @@ import 'dart:io';

import 'package:yaml/yaml.dart';

const _usage =
'Usage: ./pubspec_version_check.dart <version> <pubspec-file-path>';

/// Validate a version to match with the version in pubspec.yaml file
void main(List<String> args) {
print('The passed args: $args');
if (args.isEmpty) {
print('Missing required arguments. $_usage');
exit(1);
}
if (args.length > 2) {
print('Too many arguments. $_usage');
exit(1);
}
if (args.length != 2) {
print('Should only pass 2 arguments. $_usage');
exit(1);
}
final version = args[0];
if (version.isEmpty) {
print('The version is empty. $_usage');
void checkPubspecVersion({
required String expectedVersion,
required String pubspecFilePath,
}) {
if (expectedVersion.isEmpty) {
print('The version is empty.');
exit(1);
}
final pubspecPath = args[1];
if (pubspecPath.isEmpty) {
print('The pubspec file path is empty. $_usage');

if (pubspecFilePath.isEmpty) {
print('The pubspec file path is empty.');
exit(1);
}
final pubspecFile = File(pubspecPath);
final pubspecFile = File(pubspecFilePath);
if (!pubspecFile.existsSync()) {
print('The pubspec file does not exist: ${pubspecFile.absolute.path}');
exit(1);
}
final pubspecYaml = loadYaml(pubspecFile.readAsStringSync());
final pubspecVersion = pubspecYaml['version'];
if (version != pubspecVersion) {
if (expectedVersion != pubspecVersion) {
print(
'The version ($version) does not match the version in pubspec.yaml ($pubspecVersion).');
'The version ($expectedVersion) does not match the version in pubspec.yaml ($pubspecVersion).\n'
'The pubspec.yaml file is located at: ${pubspecFile.absolute.path}',
);
exit(1);
}
print('The version ($version) match the version in pubspec.yaml');
print('The version ($expectedVersion) match the version in pubspec.yaml');
}

0 comments on commit 9b5d55b

Please sign in to comment.