Skip to content

Commit f8dbd54

Browse files
committed
+chore: Update dependencies
1 parent 3bea074 commit f8dbd54

File tree

6 files changed

+87
-40
lines changed

6 files changed

+87
-40
lines changed

.github/scripts/update_changelog.dart

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'dart:io';
1616

1717
void main(List<String> args) {
1818
final version = args.isNotEmpty ? args[0] : '0.1.0';
19-
final newReleaseNotes = args.length > 1 ? args[1] : 'Initial commit';
19+
final comitMesssage = args.length > 1 ? args[1].replaceFirst('+', '') : '';
2020
final changelogPath = 'CHANGELOG.md';
2121
final file = File(changelogPath);
2222
if (!file.existsSync()) {
@@ -29,19 +29,19 @@ void main(List<String> args) {
2929
final versionExist = sections.where((e) => e.version == version).isNotEmpty;
3030
if (versionExist) {
3131
sections.where((e) => e.version == version).forEach((e) {
32-
e.addUpdate(newReleaseNotes);
32+
e.addUpdate(comitMesssage);
3333
});
3434
} else {
3535
sections.add(
3636
_VersionSection(
3737
version: version,
3838
releasedAt: DateTime.now().toUtc(),
39-
updates: {newReleaseNotes},
39+
updates: {comitMesssage},
4040
),
4141
);
4242
}
4343
contents = '# Changelog\n\n${(sections.toList()..sort((a, b) {
44-
return b.version.compareTo(a.version);
44+
return compareVersions(b.version, a.version);
4545
})).map((e) => e.toString()).join('\n')}';
4646

4747
file.writeAsStringSync(contents);
@@ -129,3 +129,35 @@ class _VersionSection {
129129
return '## [$version]\n\n- Released @ ${releasedAt.month}/${releasedAt.year} (UTC)\n$updatesString\n';
130130
}
131131
}
132+
133+
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
134+
135+
int compareVersions(String version1, String version2) {
136+
List<int> parseVersion(String version) {
137+
// Split by the '+' first to handle the build number
138+
final parts = version.split('+');
139+
final versionParts = parts[0].split('.').map(int.tryParse).map((e) => e ?? 0).toList();
140+
141+
// Add the build number as the last part (if it exists)
142+
if (parts.length > 1) {
143+
versionParts.add(int.tryParse(parts[1]) ?? 0);
144+
}
145+
146+
return versionParts;
147+
}
148+
149+
final v1 = parseVersion(version1);
150+
final v2 = parseVersion(version2);
151+
152+
final maxLength = v1.length > v2.length ? v1.length : v2.length;
153+
154+
for (var i = 0; i < maxLength; i++) {
155+
final part1 = i < v1.length ? v1[i] : 0;
156+
final part2 = i < v2.length ? v2[i] : 0;
157+
158+
if (part1 > part2) return 1;
159+
if (part1 < part2) return -1;
160+
}
161+
162+
return 0;
163+
}

.github/workflows/prepare.yml

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,70 @@ jobs:
2525
prepare:
2626
runs-on: ubuntu-latest
2727
steps:
28+
# Checkout the code from the repository
2829
- name: Checkout code
2930
uses: actions/checkout@v3
3031

32+
# Get the latest commit message
33+
- name: Get commit messages
34+
id: get_commits
35+
run: |
36+
COMMIT_MESSAGES=$(git log --format=%B -n 1 HEAD)
37+
echo "::set-output name=COMMIT_MESSAGES::${COMMIT_MESSAGES}"
38+
39+
# Check if the commit message starts with '+'
40+
- name: Check commit message
41+
id: check_message
42+
run: |
43+
if echo "${{ steps.get_commits.outputs.COMMIT_MESSAGES }}" | grep -q "^+"; then
44+
echo "::set-output name=PROCEED::true"
45+
else
46+
echo "::set-output name=PROCEED::false"
47+
fi
48+
49+
# Debug environment variables
50+
- name: Debug environment variables
51+
run: |
52+
echo "PROCEED=${{ steps.check_message.outputs.PROCEED }}"
53+
echo "COMMIT_MESSAGES=${{ steps.get_commits.outputs.COMMIT_MESSAGES }}"
54+
55+
# Set up Dart if the commit message check passed
3156
- name: Set up Dart
57+
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
3258
uses: dart-lang/setup-dart@v1.2
3359

60+
# Format Dart code if the commit message check passed
3461
- name: Format Dart code
62+
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
3563
run: dart format .
3664

65+
# Apply Dart fixes if the commit message check passed
3766
- name: Apply Dart fixes
67+
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
3868
run: dart fix --apply
3969

70+
# Extract the version from pubspec.yaml if the commit message check passed
4071
- name: Extract version from pubspec.yaml
72+
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
4173
id: get_version
4274
run: |
4375
VERSION=$(grep "version:" pubspec.yaml | sed 's/version: //')
44-
echo "Extracted version: $VERSION"
45-
echo "::set-output name=extracted_version::$VERSION"
46-
47-
- name: Get commit messages
48-
id: get_commits
49-
run: |
50-
COMMIT_MESSAGES=$(git log --format=%B -n 1 HEAD)
51-
echo "::set-output name=messages::${COMMIT_MESSAGES}"
76+
echo "Version extracted from pubspec.yaml: $VERSION"
77+
echo "::set-output name=PUBSPEC_VERSION::${VERSION}"
5278
79+
# Update CHANGELOG.md if the commit message check passed
5380
- name: Update CHANGELOG.md
81+
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
5482
run: |
55-
RELEASE_NOTES="${{ steps.get_commits.outputs.messages }}"
56-
dart run .github/scripts/update_changelog.dart "${{ steps.get_version.outputs.extracted_version }}" "$RELEASE_NOTES"
83+
RELEASE_NOTES="${{ steps.get_commits.outputs.COMMIT_MESSAGES }}"
84+
dart run .github/scripts/update_changelog.dart "${{ steps.get_version.outputs.PUBSPEC_VERSION }}" "$RELEASE_NOTES"
5785
86+
# Commit and push changes if the commit message check passed
5887
- name: Commit and push changes
88+
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
5989
run: |
6090
git config user.name github-actions
6191
git config user.email github-actions@github.com
6292
git add .
63-
git commit -m "Prepare version ${{ steps.get_version.outputs.extracted_version }}"
93+
git commit -m "Prepare version ${{ steps.get_version.outputs.PUBSPEC_VERSION }}"
6494
git push

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ on:
2424
jobs:
2525
publish:
2626
permissions:
27-
id-token: write # Required for authentication using OIDC
27+
id-token: write
2828
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1

DEVELOPER_NOTES.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Developer Notes
22

3-
## Commmit Tag Descriptions
3+
## Some Commin Commmit Tags
44

55
- `feat`: New feature or enhancement
66
- `fix`: Bug fix or issue resolution
@@ -20,6 +20,10 @@
2020

2121
https://github.com/robmllze/YOUR_PROJECT_NAME/settings/actions
2222

23+
## Changelog
24+
25+
If your commit message starts with `+`, the `prepare.yml` workflow will automatically format and apply fixes to the code, and add the provided commit message to `CHANGELOG.md` under the current version specified in `pubspec.yaml`.
26+
2327
## Public Repo Setup
2428

2529
```sh
@@ -46,14 +50,6 @@ git push -u origin main
4650

4751
## macOS and Linux
4852

49-
### Fetching Generators
50-
51-
```bash
52-
rm -rf ___generators/
53-
git clone https://github.com/robmllze/___generators.git
54-
dart pub get -C ___generators
55-
```
56-
5753
### Adding the Workflow
5854

5955
```bash
@@ -71,15 +67,6 @@ find . -name '.DS_Store' -type f -delete
7167

7268
## Windows
7369

74-
### Fetching Generators
75-
76-
```bash
77-
rmdir /s /q ___generators/
78-
git clone https://github.com/robmllze/___generators.git
79-
dart pub get -C ___generators
80-
rmdir /s /q ___generators/.git
81-
```
82-
8370
### Adding the Workflow
8471

8572
```bash

lib/src/sc_on_num_extension.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13-
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
14-
1513
import 'scalable_app.dart';
1614

15+
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
16+
1717
extension ScOnNumExtension on num {
1818
/// Multiples the num with the current app scale.
1919
double get sc => this * (ScalableApp.snapshot ?? 1.0);

pubspec.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212

1313
name: df_scalable
1414
description: A package that provides a convenient method to scale your app UI up or down.
15-
version: 0.2.6
15+
version: 0.2.7
1616
repository: https://github.com/robmllze/df_scalable
17-
# homepage: TODO
18-
# documentation: TODO
1917
funding:
2018
- https://www.buymeacoffee.com/robmllze
2119
topics:
@@ -35,7 +33,7 @@ environment:
3533
dependencies:
3634
flutter:
3735
sdk: flutter
38-
df_pod: ^0.10.0
36+
df_pod: ^0.11.8
3937

4038
## -----------------------------------------------------------------------------
4139

0 commit comments

Comments
 (0)