Skip to content

Commit a1c83cf

Browse files
committed
first commit
0 parents  commit a1c83cf

21 files changed

+774
-0
lines changed

.flutter-plugins

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This is a generated file; do not edit or check into version control.
2+
path_provider_linux=/Users/robmllze/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/
3+
path_provider_windows=/Users/robmllze/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/
4+
shared_preferences=/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences-2.3.1/
5+
shared_preferences_android=/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.0/
6+
shared_preferences_foundation=/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.0/
7+
shared_preferences_linux=/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.0/
8+
shared_preferences_web=/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.1/
9+
shared_preferences_windows=/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.0/

.flutter-plugins-dependencies

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"shared_preferences_foundation","path":"/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"shared_preferences_android","path":"/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"shared_preferences_foundation","path":"/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/robmllze/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.0/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/robmllze/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.0/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"shared_preferences_web","path":"/Users/robmllze/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.1/","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-08-06 20:32:04.100878","version":"3.24.0-1.0.pre.461","swift_package_manager_enabled":false}

.github/_README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Workflow for Managing Pub.dev Packages
2+
3+
## Workflows
4+
5+
**This repository contains GitHub Actions workflows that simplify the management of your pub.dev packages:**
6+
7+
- The `prepare.yaml` workflow triggers on every push to the main branch. It automatically updates the CHANGELOG.md, formats the Dart code, and applies Dart fixes with each push.
8+
- The `publish.yaml` workflow activates upon the creation of a new release, automatically handling the package's publication to pub.dev.
9+
10+
## Setup Instructions
11+
12+
**1. Navigate to your project:**
13+
14+
```zsh
15+
cd your_project
16+
```
17+
18+
**2. Clone this repo into a `.github/` folder:**
19+
20+
```zsh
21+
git clone https://github.com/robmllze/pub.dev_package_workflow.git .github
22+
```
23+
24+
**3. Remove the `/.git` folder to include it to your project:**
25+
26+
*On macOS and Linux:*
27+
```zsh
28+
rm -rf .github/.git/
29+
```
30+
31+
*On Windows:*
32+
```cmd
33+
rmdir /s /q .github/.git/
34+
```
35+
36+

.github/scripts/update_changelog.dart

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
//.title
2+
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
3+
//
4+
// Dart/Flutter (DF) Packages by DevCetra.com & contributors. See LICENSE file
5+
// in root directory.
6+
//
7+
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
8+
//.title~
9+
10+
import 'dart:io';
11+
12+
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
13+
14+
void main(List<String> args) {
15+
final version = args.isNotEmpty ? args[0] : '0.1.0';
16+
final newReleaseNotes = args.length > 1 ? args[1] : 'Initial commit';
17+
final changelogPath = 'CHANGELOG.md';
18+
final file = File(changelogPath);
19+
if (!file.existsSync()) {
20+
print('$changelogPath does not exist.');
21+
exit(1);
22+
}
23+
var contents = file.readAsStringSync();
24+
contents = contents.replaceAll('# Changelog', '').trim();
25+
final sections = extractSections(contents);
26+
final versionExist = sections.where((e) => e.version == version).isNotEmpty;
27+
if (versionExist) {
28+
sections.where((e) => e.version == version).forEach((e) {
29+
e.addUpdate(newReleaseNotes);
30+
});
31+
} else {
32+
sections.add(
33+
_VersionSection(
34+
version: version,
35+
releasedAt: DateTime.now().toUtc(),
36+
updates: {newReleaseNotes},
37+
),
38+
);
39+
}
40+
contents = '# Changelog\n\n${(sections.toList()..sort((a, b) {
41+
return b.version.compareTo(a.version);
42+
})).map((e) => e.toString()).join('\n')}';
43+
44+
file.writeAsStringSync(contents);
45+
print('Changelog updated with version $version.');
46+
}
47+
48+
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
49+
50+
Set<_VersionSection> extractSections(String contents) {
51+
final headerPattern = RegExp(r'## \[\d+\.\d+\.\d+(\+\d+)?\]');
52+
final allVersionMatches = headerPattern.allMatches(contents).toList();
53+
final results = <_VersionSection>{};
54+
for (var i = 0; i < allVersionMatches.length; i++) {
55+
final start = allVersionMatches[i].end;
56+
final end = i + 1 < allVersionMatches.length ? allVersionMatches[i + 1].start : contents.length;
57+
final sectionContents = contents.substring(start, end).trim();
58+
final lines = sectionContents.split('\n').where((line) => line.isNotEmpty).toList();
59+
final version =
60+
allVersionMatches[i].group(0)!.substring(4, allVersionMatches[i].group(0)!.length - 1);
61+
var releasedAt = DateTime.now().toUtc();
62+
final updates = <String>{};
63+
final old = lines
64+
.map((e) => e.trim())
65+
.where((e) => e.isNotEmpty)
66+
.map((e) => e.startsWith('-') ? e.substring(1) : e)
67+
.map((e) => e.trim())
68+
.where((e) => e.isNotEmpty);
69+
for (var line in old) {
70+
if (line.contains('Released @')) {
71+
final temp = line.split('Released @').last.trim();
72+
releasedAt = DateTime.tryParse(temp) ?? releasedAt;
73+
} else {
74+
updates.add(line);
75+
}
76+
}
77+
results.add(
78+
_VersionSection(
79+
version: version,
80+
releasedAt: releasedAt,
81+
updates: updates,
82+
),
83+
);
84+
}
85+
86+
return results;
87+
}
88+
89+
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
90+
91+
class _VersionSection {
92+
//
93+
//
94+
//
95+
96+
String version;
97+
DateTime releasedAt;
98+
Set<String> updates;
99+
100+
//
101+
//
102+
//
103+
104+
_VersionSection({
105+
required this.version,
106+
required this.releasedAt,
107+
this.updates = const {},
108+
});
109+
110+
//
111+
//
112+
//
113+
114+
void addUpdate(String update) {
115+
this.updates.add(update);
116+
this.releasedAt = DateTime.now().toUtc();
117+
}
118+
119+
//
120+
//
121+
//
122+
123+
@override
124+
String toString() {
125+
final updatesString = updates.map((update) => '- $update').join('\n');
126+
return '## [$version]\n\n- Released @ ${releasedAt.month}/${releasedAt.year} (UTC)\n$updatesString\n';
127+
}
128+
}

.github/workflows/prepare.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
##.title
2+
## ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
3+
##
4+
## Dart/Flutter (DF) Packages by DevCetra.com & contributors. ee LICENSE file
5+
## in root directory.
6+
##
7+
## For more about publishing, see: https://dart.dev/tools/pub/automated-publishing
8+
##
9+
## ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
10+
##.title~
11+
12+
name: Prepare version
13+
14+
## -----------------------------------------------------------------------------
15+
16+
on:
17+
push:
18+
branches:
19+
- main
20+
21+
## -----------------------------------------------------------------------------
22+
23+
jobs:
24+
prepare:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v3
29+
30+
- name: Set up Dart
31+
uses: dart-lang/setup-dart@v1.2
32+
33+
- name: Format Dart code
34+
run: dart format .
35+
36+
- name: Apply Dart fixes
37+
run: dart fix --apply
38+
39+
- name: Extract version from pubspec.yaml
40+
id: get_version
41+
run: |
42+
VERSION=$(grep "version:" pubspec.yaml | sed 's/version: //')
43+
echo "Extracted version: $VERSION"
44+
echo "::set-output name=extracted_version::$VERSION"
45+
46+
- name: Get commit messages
47+
id: get_commits
48+
run: |
49+
COMMIT_MESSAGES=$(git log --format=%B -n 1 HEAD)
50+
echo "::set-output name=messages::${COMMIT_MESSAGES}"
51+
52+
- name: Update CHANGELOG.md
53+
run: |
54+
RELEASE_NOTES="${{ steps.get_commits.outputs.messages }}"
55+
dart run .github/scripts/update_changelog.dart "${{ steps.get_version.outputs.extracted_version }}" "$RELEASE_NOTES"
56+
57+
- name: Commit and push changes
58+
run: |
59+
git config user.name github-actions
60+
git config user.email github-actions@github.com
61+
git add .
62+
git commit -m "Prepare version ${{ steps.get_version.outputs.extracted_version }}"
63+
git push

.github/workflows/publish.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
##.title
2+
## ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
3+
##
4+
## Dart/Flutter (DF) Packages by DevCetra.com & contributors. See MIT LICENSE
5+
## file in root directory.
6+
##
7+
## A workflow that publishes a Dart package to pub.dev. For more about
8+
## publishing, see: https://dart.dev/tools/pub/automated-publishing
9+
##
10+
## ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
11+
##.title~
12+
13+
name: Publish to pub.dev
14+
15+
## -----------------------------------------------------------------------------
16+
17+
on:
18+
push:
19+
tags:
20+
- "v[0-9]+.[0-9]+.[0-9]+*"
21+
22+
## -----------------------------------------------------------------------------
23+
24+
jobs:
25+
publish:
26+
permissions:
27+
id-token: write # Required for authentication using OIDC
28+
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
##.title
2+
## ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
3+
##
4+
## Dart/Flutter (DF) Packages by DevCetra.com & contributors. See LICENSE file
5+
## in root directory.
6+
##
7+
## ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
8+
##.title~
9+
10+
**/___generators/
11+
**/.dart_tool/
12+
**/.DS_Store
13+
**/build/
14+
**/pubspec.lock
15+
**/.github/.git

.vscode/tasks.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "▶️ Refetch workflow",
6+
"type": "shell",
7+
"command": "rm -rf .github && git clone https://github.com/robmllze/pub.dev_package_workflow.git .github && rm -rf .github/.git/"
8+
},
9+
{
10+
"label": "▶️ Publish to pub.dev",
11+
"type": "shell",
12+
"command": "dart pub publish"
13+
},
14+
]
15+
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
## [0.1.0]
4+
5+
- Released @ 8/2024 (UTC)
6+
- Initial release

0 commit comments

Comments
 (0)