From 2f1ecf64b2503ca262ebf1bb9099ab26603faebc Mon Sep 17 00:00:00 2001 From: Thomas Kam Date: Wed, 25 Sep 2024 18:09:31 -0400 Subject: [PATCH] fix github actions (#548) * fix github actions * another script * permissions * use env-var instead * reposition keys * typo * v4.3.3pre * v4.3.3-20240801 * tag change * fix pipeline runs * remove broken job * update kotlin versions * update kotlin versions --- .github/workflows/prerelease.yml | 42 +++++++++++-------- .github/workflows/release.yml | 32 +++++++++----- android/build.gradle | 4 +- example/android/app/build.gradle | 2 +- example/android/build.gradle | 2 +- .../lib/presentation/date_time_picker.dart | 2 +- .../presentation/pages/calendar_event.dart | 11 +++-- .../presentation/pages/calendar_events.dart | 6 +-- example/lib/presentation/pages/calendars.dart | 4 +- example/pubspec.yaml | 5 ++- pubspec.yaml | 4 +- 11 files changed, 66 insertions(+), 48 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index b836df6a..cbe13b2c 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -7,6 +7,8 @@ on: # Triggers the workflow on push or pull request events but only for the develop branch push: branches: [release, hotfix] + tags: + - "[0-9]+.[0-9]+.[0-9]+*" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -18,33 +20,39 @@ jobs: # The type of runner that the job will run on runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job + permissions: + id-token: write steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - uses: subosito/flutter-action@v1 - with: - channel: "stable" + - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 - run: dart --version - run: flutter --version + - name: Get Git Tag + id: get_tag + run: echo "TAG=$(git describe --tags)" >> $GITHUB_ENV - name: Edit pubspec.ymal for dev release run: | - sed -i "s/version.*/&-$GITHUB_RUN_ID/" pubspec.yaml + sed -i "s/version:.*/version: ${{ env.TAG }}/" pubspec.yaml - name: Get Changelog Entry id: changelog_reader uses: mindsers/changelog-reader-action@v2.0.0 - name: Edit changelog.md for dev release run: | - sed -i "0,/\#\# \[.*/s//## [${{steps.changelog_reader.outputs.version}}-$GITHUB_RUN_ID]/" CHANGELOG.md + sed -i "0,/\#\# \[.*/s//## [${{env.TAG}}]/" CHANGELOG.md cat CHANGELOG.md - - name: Setup credentials - run: | - cat < $PUB_CACHE/credentials.json - ${{ secrets.CREDENTIALS }} - EOF - - name: Publish package - run: flutter pub publish --force - - name: Add entry to Github release - uses: softprops/action-gh-release@v1 + # copied from https://github.com/dart-lang/setup-dart/issues/68#issuecomment-2251116730 + - name: 🪪 Get Id Token + uses: actions/github-script@v6 with: - tag_name: ${{ steps.changelog_reader.outputs.version }}+${{ github.run_id }} - prerelease: true \ No newline at end of file + script: | + let pub_token = await core.getIDToken('https://pub.dev') + core.exportVariable('PUB_TOKEN', pub_token) + - name: 📦 Install dependencies + run: flutter pub get + - name: 🌵 Dry Run + run: flutter pub publish --dry-run + - name: 📢 Publish + run: | + flutter pub token add https://pub.dev --env-var PUB_TOKEN + flutter pub publish -f diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 35967b42..7b260810 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,8 @@ on: # Triggers the workflow on push or pull request events but only for the develop branch push: branches: [master] + tags: + - "v[0-9]+.[0-9]+.[0-9]+*" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -16,22 +18,30 @@ jobs: release: # The type of runner that the job will run on runs-on: ubuntu-latest + permissions: + id-token: write # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - uses: subosito/flutter-action@v1 - with: - channel: "stable" + - uses: actions/checkout@v4 + # copied from https://github.com/dart-lang/setup-dart/issues/68#issuecomment-2251116730 + - uses: subosito/flutter-action@v2 - run: dart --version - run: flutter --version - - name: Setup credentials + - name: 🪪 Get Id Token + uses: actions/github-script@v6 + with: + script: | + let pub_token = await core.getIDToken('https://pub.dev') + core.exportVariable('PUB_TOKEN', pub_token) + - name: 📦 Install dependencies + run: flutter pub get + - name: 🌵 Dry Run + run: flutter pub publish --dry-run + - name: 📢 Publish run: | - cat < $PUB_CACHE/credentials.json - ${{ secrets.CREDENTIALS }} - EOF - - name: Publish package - run: flutter pub publish --force + flutter pub token add https://pub.dev --env-var PUB_TOKEN + flutter pub publish -f - name: Get Changelog Entry id: changelog_reader uses: mindsers/changelog-reader-action@v2.0.0 @@ -39,4 +49,4 @@ jobs: uses: softprops/action-gh-release@v1 with: tag_name: ${{ steps.changelog_reader.outputs.version }} - body: ${{ steps.changelog_reader.outputs.changes }} \ No newline at end of file + body: ${{ steps.changelog_reader.outputs.changes }} diff --git a/android/build.gradle b/android/build.gradle index 584dc4ae..76ab5ef2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,7 +2,7 @@ group 'com.builttoroam.devicecalendar' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.6.0' + ext.kotlin_version = '1.7.10' repositories { google() mavenCentral() @@ -25,7 +25,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 33 + compileSdkVersion 34 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 11cc8cb1..3b531cd0 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 33 + compileSdkVersion 34 ndkVersion '22.1.7171670' sourceSets { diff --git a/example/android/build.gradle b/example/android/build.gradle index d3f65307..d1b666ac 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.6.0' + ext.kotlin_version = '1.7.10' repositories { google() mavenCentral() diff --git a/example/lib/presentation/date_time_picker.dart b/example/lib/presentation/date_time_picker.dart index dc11e8d9..449b82e8 100644 --- a/example/lib/presentation/date_time_picker.dart +++ b/example/lib/presentation/date_time_picker.dart @@ -45,7 +45,7 @@ class DateTimePicker extends StatelessWidget { @override Widget build(BuildContext context) { - final valueStyle = Theme.of(context).textTheme.headline6; + final valueStyle = Theme.of(context).textTheme.titleLarge; return Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ diff --git a/example/lib/presentation/pages/calendar_event.dart b/example/lib/presentation/pages/calendar_event.dart index e834773b..89a17205 100644 --- a/example/lib/presentation/pages/calendar_event.dart +++ b/example/lib/presentation/pages/calendar_event.dart @@ -15,11 +15,12 @@ import 'event_reminders.dart'; enum RecurrenceRuleEndType { Indefinite, MaxOccurrences, SpecifiedEndDate } class CalendarEventPage extends StatefulWidget { - late final Calendar _calendar; + final Calendar _calendar; final Event? _event; final RecurringEventDialog? _recurringEventDialog; - CalendarEventPage(this._calendar, [this._event, this._recurringEventDialog]); + const CalendarEventPage(this._calendar, + [this._event, this._recurringEventDialog]); @override _CalendarEventPageState createState() { @@ -721,10 +722,8 @@ class _CalendarEventPageState extends State { _recurrenceFrequency) .data != null - ? Text(_recurrenceFrequencyToText( - _recurrenceFrequency) - .data! + - ' on the ') + ? Text( + '${_recurrenceFrequencyToText(_recurrenceFrequency).data!} on the ') : const Text('')), ), Padding( diff --git a/example/lib/presentation/pages/calendar_events.dart b/example/lib/presentation/pages/calendar_events.dart index 584458e3..38bd4946 100644 --- a/example/lib/presentation/pages/calendar_events.dart +++ b/example/lib/presentation/pages/calendar_events.dart @@ -156,11 +156,11 @@ class _CalendarEventsPageState extends State { builder: (BuildContext context) { return AlertDialog( title: const Text('Warning'), - content: SingleChildScrollView( + content: const SingleChildScrollView( child: ListBody( children: [ - const Text('This will delete this calendar'), - const Text('Are you sure?'), + Text('This will delete this calendar'), + Text('Are you sure?'), ], ), ), diff --git a/example/lib/presentation/pages/calendars.dart b/example/lib/presentation/pages/calendars.dart index 4dbf22e3..ab712805 100644 --- a/example/lib/presentation/pages/calendars.dart +++ b/example/lib/presentation/pages/calendars.dart @@ -46,7 +46,7 @@ class _CalendarsPageState extends State { padding: const EdgeInsets.all(10.0), child: Text( 'WARNING: some aspects of saving events are hardcoded in this example app. As such we recommend you do not modify existing events as this may result in loss of information', - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.titleLarge, ), ), Expanded( @@ -77,7 +77,7 @@ class _CalendarsPageState extends State { Text( "${_calendars[index].id}: ${_calendars[index].name!}", style: - Theme.of(context).textTheme.subtitle1, + Theme.of(context).textTheme.titleMedium, ), Text( "Account: ${_calendars[index].accountName!}"), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 5b8b0fe0..6f41fb9b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ version: 3.2.0 publish_to: none environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.12.0 <4.0.0" dependencies: flutter: @@ -19,12 +19,13 @@ dependencies: device_calendar: path: ../ + collection: ^1.18.0 dev_dependencies: integration_test: sdk: flutter flutter_test: sdk: flutter - flutter_lints: ^2.0.1 + flutter_lints: ^4.0.0 # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec diff --git a/pubspec.yaml b/pubspec.yaml index b2e16785..bcdbd014 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.1 + flutter_lints: ^4.0.0 # The following section is specific to Flutter. flutter: @@ -26,5 +26,5 @@ flutter: pluginClass: DeviceCalendarPlugin environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.12.0 <4.0.0" flutter: ">=1.12.13"