diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dc9ad461..436dfc73 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -91,6 +91,9 @@ jobs: exit 1 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 run: dart ./scripts/update_package_version.dart ${{ steps.extract_version.outputs.VERSION }} '${{ fromJson(steps.fetch-release-notes-request.outputs.response).body }}' diff --git a/scripts/update_package_version.dart b/scripts/update_package_version.dart index 0e831b53..61c33ef1 100644 --- a/scripts/update_package_version.dart +++ b/scripts/update_package_version.dart @@ -3,6 +3,8 @@ import 'dart:convert' show jsonDecode, jsonEncode; 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; /// The list of the packages that which will be used to update the `CHANGELOG.md` @@ -16,7 +18,8 @@ final _packages = [ './quill_pdf_converter', ]; -const _usage = 'Usage: ./script '; +const _usage = 'Usage: ./script '; +const _versionContentFileName = 'versionContent.md'; /// 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 @@ -34,11 +37,11 @@ const _usage = 'Usage: ./script '; /// this script designed to run in CI to automate the process of updating /// the package Future main(List args) async { - if (args.isEmpty || args.length < 2) { + if (args.isEmpty) { print('Missing required arguments ($args). $_usage'); exit(1); } - if (args.length > 2) { + if (args.length > 1) { print('Too many arguments ($args). $_usage'); exit(1); } @@ -47,14 +50,17 @@ Future main(List args) async { print('The version is empty ($args). $_usage'); exit(1); } - final passedVersionContent = args[1]; - if (passedVersionContent.isEmpty) { - print('The version content is empty ($args). $_usage'); + final versionContentFile = File(path.join('build', _versionContentFileName)); + if (!(await versionContentFile.exists())) { + print( + 'The file "$_versionContentFileName" in ${versionContentFile.path} does not exist.', + ); exit(1); } + final versionContent = await versionContentFile.readAsString(); 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 @@ -63,7 +69,7 @@ Future main(List args) async { await _replaceVersion( sourceChangeLogFile: sourceChangeLogFile, version: passedVersion, - versionContent: passedVersionContent, + versionContent: versionContent, ); final sourceChangeLog = jsonDecode(await sourceChangeLogFile.readAsString()) as Map;