ci(publishing): fix passing the version content to the update package version script

pull/1919/head
Ellet 10 months ago
parent 62c655b880
commit a7f4604b43
  1. 3
      .github/workflows/publish.yml
  2. 22
      scripts/update_package_version.dart

@ -91,6 +91,9 @@ jobs:
exit 1 exit 1
fi fi
- name: 🖌 Create required version content file to use in the next step
run: echo "${{ fromJson(steps.fetch-release-notes-request.outputs.response).body }}" > ./build/versionContent.md
- name: 📝 Update version and CHANGELOG for all the packages - name: 📝 Update version and CHANGELOG for all the packages
run: dart ./scripts/update_package_version.dart ${{ steps.extract_version.outputs.VERSION }} '${{ fromJson(steps.fetch-release-notes-request.outputs.response).body }}' run: dart ./scripts/update_package_version.dart ${{ steps.extract_version.outputs.VERSION }} '${{ fromJson(steps.fetch-release-notes-request.outputs.response).body }}'

@ -3,6 +3,8 @@
import 'dart:convert' show jsonDecode, jsonEncode; import 'dart:convert' show jsonDecode, jsonEncode;
import 'dart:io' show File, exit; import 'dart:io' show File, exit;
// ignore: depend_on_referenced_packages
import 'package:path/path.dart' as path;
import 'package:yaml_edit/yaml_edit.dart' show YamlEditor; import 'package:yaml_edit/yaml_edit.dart' show YamlEditor;
/// The list of the packages that which will be used to update the `CHANGELOG.md` /// The list of the packages that which will be used to update the `CHANGELOG.md`
@ -16,7 +18,8 @@ final _packages = [
'./quill_pdf_converter', './quill_pdf_converter',
]; ];
const _usage = 'Usage: ./script <version> <changelog-version-content>'; const _usage = 'Usage: ./script <version>';
const _versionContentFileName = 'versionContent.md';
/// A script that should run in the root folder and not inside any other folder /// A script that should run in the root folder and not inside any other folder
/// it has one task, which update the version for `pubspec.yaml` and /// it has one task, which update the version for `pubspec.yaml` and
@ -34,11 +37,11 @@ const _usage = 'Usage: ./script <version> <changelog-version-content>';
/// this script designed to run in CI to automate the process of updating /// this script designed to run in CI to automate the process of updating
/// the package /// the package
Future<void> main(List<String> args) async { Future<void> main(List<String> args) async {
if (args.isEmpty || args.length < 2) { if (args.isEmpty) {
print('Missing required arguments ($args). $_usage'); print('Missing required arguments ($args). $_usage');
exit(1); exit(1);
} }
if (args.length > 2) { if (args.length > 1) {
print('Too many arguments ($args). $_usage'); print('Too many arguments ($args). $_usage');
exit(1); exit(1);
} }
@ -47,14 +50,17 @@ Future<void> main(List<String> args) async {
print('The version is empty ($args). $_usage'); print('The version is empty ($args). $_usage');
exit(1); exit(1);
} }
final passedVersionContent = args[1]; final versionContentFile = File(path.join('build', _versionContentFileName));
if (passedVersionContent.isEmpty) { if (!(await versionContentFile.exists())) {
print('The version content is empty ($args). $_usage'); print(
'The file "$_versionContentFileName" in ${versionContentFile.path} does not exist.',
);
exit(1); exit(1);
} }
final versionContent = await versionContentFile.readAsString();
print( print(
'The version is $passedVersion and the content is:\n$passedVersionContent', 'The version is "$passedVersion" and the content is:\n$versionContent',
); );
// A file that will be used to build the `CHANGELOG.md` files // A file that will be used to build the `CHANGELOG.md` files
@ -63,7 +69,7 @@ Future<void> main(List<String> args) async {
await _replaceVersion( await _replaceVersion(
sourceChangeLogFile: sourceChangeLogFile, sourceChangeLogFile: sourceChangeLogFile,
version: passedVersion, version: passedVersion,
versionContent: passedVersionContent, versionContent: versionContent,
); );
final sourceChangeLog = jsonDecode(await sourceChangeLogFile.readAsString()) final sourceChangeLog = jsonDecode(await sourceChangeLogFile.readAsString())
as Map<String, Object?>; as Map<String, Object?>;

Loading…
Cancel
Save