Skip to content

Commit a734bdf

Browse files
authored
Daily Dev Bumps (flutter#4908)
This workflow will run a dev bump every day at midnight.
1 parent 618193a commit a734bdf

File tree

2 files changed

+93
-5
lines changed

2 files changed

+93
-5
lines changed

.github/workflows/daily-dev-bump.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Daily Dev Bump
2+
on:
3+
schedule:
4+
# * is a special character in YAML so you have to quote this string
5+
- cron: '0 0 * * *' # Run every day at midnight
6+
workflow_dispatch: # Allows for manual triggering if needed
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
14+
jobs:
15+
bump-dev-version:
16+
name: Bump Dev Version
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: git clone devtools
20+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
21+
with:
22+
ref: master
23+
24+
- uses: dart-lang/setup-dart@v1.3
25+
26+
- name: setup git config
27+
run: |
28+
29+
# TODO(https://github.com/flutter/devtools/issues/4949): Change the author to
30+
# a flutter owned account
31+
git config user.name "Dan Chevalier's GitHub Actions Bot"
32+
git config user.email "chevalier.dan@gmail.com"
33+
34+
- name: Bump the Dev Version
35+
id: version-bump
36+
run: |
37+
set -x
38+
pushd tool/
39+
dart pub get
40+
popd
41+
42+
CURRENT_VERSION=$(dart tool/update_version.dart current-version)
43+
if ! echo "$CURRENT_VERSION" |grep -Eq "\-dev\.[0-9]+" ; then
44+
ERROR_DESCRIPTION="Doing \
45+
a Dev bump on a release version ($CURRENT_VERSION) is not supported. \
46+
Ensure that that current version has been properly bumped to a '-dev.*' \
47+
pre-release version, in order to continue daily dev bumps."
48+
49+
echo "::error ,title=Cannot Bump A Release Version ($CURRENT_VERSION)::$ERROR_DESCRIPTION"
50+
exit 1;
51+
fi
52+
53+
# Get the commit message
54+
COMMIT_MESSAGE=$(dart tool/update_version.dart auto --dry-run --type dev)
55+
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
56+
57+
# Do the update
58+
dart tool/update_version.dart auto --type dev
59+
60+
- name: commit
61+
run: |
62+
# Stage the file, commit and push
63+
64+
git commit -a -m "$COMMIT_MESSAGE"
65+
git push
66+
env:
67+
COMMIT_MESSAGE: ${{ steps.version-bump.outputs.COMMIT_MESSAGE }}

tool/update_version.dart

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ void main(List<String> args) async {
2323
'A program for updating the devtools version',
2424
)
2525
..addCommand(ManualUpdateCommand())
26-
..addCommand(AutoUpdateCommand());
26+
..addCommand(AutoUpdateCommand())
27+
..addCommand(CurrentVersionCommand());
2728
runner.run(args).catchError((error) {
2829
if (error is! UsageException) throw error;
2930
print(error);
@@ -32,8 +33,11 @@ void main(List<String> args) async {
3233
return;
3334
}
3435

35-
Future<void> performTheVersionUpdate(
36-
{required String currentVersion, required String newVersion}) async {
36+
Future<void> performTheVersionUpdate({
37+
required String currentVersion,
38+
required String newVersion,
39+
bool modifyChangeLog = true,
40+
}) async {
3741
print('Updating pubspecs from $currentVersion to version $newVersion...');
3842

3943
for (final pubspec in _pubspecs) {
@@ -46,8 +50,10 @@ Future<void> performTheVersionUpdate(
4650
newVersion,
4751
);
4852

49-
print('Updating CHANGELOG to version $newVersion...');
50-
writeVersionToChangelog(File('CHANGELOG.md'), newVersion);
53+
if (modifyChangeLog) {
54+
print('Updating CHANGELOG to version $newVersion...');
55+
writeVersionToChangelog(File('CHANGELOG.md'), newVersion);
56+
}
5157

5258
print('Updating index.html to version $newVersion...');
5359
writeVersionToIndexHtml(
@@ -284,6 +290,18 @@ class ManualUpdateCommand extends Command {
284290
}
285291
}
286292

293+
class CurrentVersionCommand extends Command {
294+
@override
295+
final name = 'current-version';
296+
@override
297+
final description = 'Print the current devtools_app version.';
298+
299+
@override
300+
void run() async {
301+
print(versionFromPubspecFile());
302+
}
303+
}
304+
287305
class AutoUpdateCommand extends Command {
288306
@override
289307
final name = 'auto';
@@ -343,6 +361,7 @@ class AutoUpdateCommand extends Command {
343361
final type = argResults!['type'].toString();
344362
final isDryRun = argResults!['dry-run'];
345363
final currentVersion = versionFromPubspecFile();
364+
bool modifyChangeLog = true;
346365
String? newVersion;
347366
if (currentVersion == null) {
348367
throw 'Could not automatically determine current version.';
@@ -353,6 +372,7 @@ class AutoUpdateCommand extends Command {
353372
break;
354373
case 'dev':
355374
newVersion = incrementDevVersion(currentVersion);
375+
modifyChangeLog = false;
356376
break;
357377
default:
358378
newVersion = incrementVersionByType(currentVersion, type);
@@ -369,6 +389,7 @@ class AutoUpdateCommand extends Command {
369389
performTheVersionUpdate(
370390
currentVersion: currentVersion,
371391
newVersion: newVersion,
392+
modifyChangeLog: modifyChangeLog,
372393
);
373394
}
374395
}

0 commit comments

Comments
 (0)