Skip to content

Commit d0246ee

Browse files
authored
feat : added caching to workflow again (#95) [build.all] [clean]
* test 1 [build.all] [clean] * [build.all] test 2 * [build.ios] test 3 * [build.ios] test 4
1 parent 0c19864 commit d0246ee

File tree

1 file changed

+141
-54
lines changed

1 file changed

+141
-54
lines changed

.github/workflows/dart.yml

Lines changed: 141 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,48 @@ jobs:
2323
with:
2424
fetch-depth: 0
2525
# Cache Flutter dependencies
26-
# - uses: actions/cache@v4
27-
# with:
28-
# path: |
29-
# ~/.pub-cache
30-
# build/
31-
# .dart_tool/
32-
# key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
33-
# restore-keys: |
34-
# ${{ runner.os }}-flutter-
26+
- name: Cache Flutter dependencies (normal)
27+
if: ${{ !contains(github.event.head_commit.message, '[clean]') }}
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.pub-cache
32+
build/
33+
.dart_tool/
34+
key: v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
35+
restore-keys: |
36+
v1-${{ runner.os }}-flutter-
37+
clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
38+
- name: Cache Flutter dependencies (clean)
39+
if: contains(github.event.head_commit.message, '[clean]')
40+
uses: actions/cache@v4
41+
with:
42+
path: |
43+
~/.pub-cache
44+
build/
45+
.dart_tool/
46+
key: clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
3547

3648
# Cache Gradle dependencies
37-
# - uses: actions/cache@v4
38-
# with:
39-
# path: |
40-
# ~/.gradle/caches
41-
# ~/.gradle/wrapper
42-
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
43-
# restore-keys: |
44-
# ${{ runner.os }}-gradle-
49+
- name: Cache Gradle dependencies (normal)
50+
if: ${{!contains(github.event.head_commit.message, '[clean]')}}
51+
uses: actions/cache@v4
52+
with:
53+
path: |
54+
~/.gradle/caches
55+
~/.gradle/wrapper
56+
key: v1-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
57+
restore-keys: |
58+
v1-${{ runner.os }}-gradle-
59+
clean-v1-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
60+
- name: Cache Gradle dependencies (clean)
61+
if: contains(github.event.head_commit.message, '[clean]')
62+
uses: actions/cache@v4
63+
with:
64+
path: |
65+
~/.gradle/caches
66+
~/.gradle/wrapper
67+
key: clean-v1-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
4568
# Setup Cmake
4669
- name: Setup cmake
4770
uses: jwlawson/actions-setup-cmake@v2
@@ -184,10 +207,31 @@ jobs:
184207
185208
# Setup Flutter with caching
186209
- name: Setup Flutter
210+
id: setup-flutter
187211
uses: subosito/flutter-action@v2
188212
with:
189213
flutter-version: 3.32.5
190-
cache: true
214+
- name: Cache Flutter dependencies (normal)
215+
if: ${{!contains(github.event.head_commit.message, '[clean]')}}
216+
uses: actions/cache@v4
217+
with:
218+
path: |
219+
${{ steps.setup-flutter.outputs.pub-cache-path }}
220+
build
221+
.dart_tool
222+
key: v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
223+
restore-keys: |
224+
v1-${{ runner.os }}-flutter-
225+
clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
226+
- name: Cache Flutter dependencies (clean)
227+
if: contains(github.event.head_commit.message, '[clean]')
228+
uses: actions/cache@v4
229+
with:
230+
path: |
231+
${{ steps.setup-flutter.outputs.pub-cache-path }}
232+
build
233+
.dart_tool
234+
key: clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
191235
- name: Setup NuGet.exe for use with actions
192236
uses: NuGet/setup-nuget@v2.0.1
193237
with:
@@ -251,15 +295,25 @@ jobs:
251295
sudo apt-get install -y ninja-build libgtk-3-dev webkit2gtk-4.1 libmpv-dev pkg-config fuse
252296
253297
# Step 4: Cache Flutter dependencies
254-
# - name: Cache Flutter dependencies
255-
# uses: actions/cache@v3
256-
# with:
257-
# path: |
258-
# ~/.pub-cache
259-
# build/
260-
# key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.yaml') }}
261-
# restore-keys: |
262-
# ${{ runner.os }}-flutter-
298+
- name: Cache Flutter dependencies (normal)
299+
if: ${{!contains(github.event.head_commit.message, '[clean]')}}
300+
uses: actions/cache@v4
301+
with:
302+
path: |
303+
~/.pub-cache
304+
build/
305+
key: v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.yaml') }}
306+
restore-keys: |
307+
v1-${{ runner.os }}-flutter-
308+
clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.yaml') }}
309+
- name: Cache Flutter dependencies (clean)
310+
if: contains(github.event.head_commit.message, '[clean]')
311+
uses: actions/cache@v4
312+
with:
313+
path: |
314+
~/.pub-cache
315+
build/
316+
key: clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.yaml') }}
263317
# Create .env:
264318
- name: Setup env File
265319
env:
@@ -308,10 +362,31 @@ jobs:
308362

309363
# Step 2: Setup Flutter
310364
- name: Setup Flutter
365+
id: setup-flutter
311366
uses: subosito/flutter-action@v2
312367
with:
313368
flutter-version: 3.32.5
314-
cache: true
369+
- name: Cache Flutter dependencies (normal)
370+
if: ${{!contains(github.event.head_commit.message, '[clean]')}}
371+
uses: actions/cache@v4
372+
with:
373+
path: |
374+
${{ steps.setup-flutter.outputs.pub-cache-path }}
375+
build
376+
.dart_tool
377+
key: v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
378+
restore-keys: |
379+
v1-${{ runner.os }}-flutter-
380+
clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
381+
- name: Cache Flutter dependencies (clean)
382+
if: contains(github.event.head_commit.message, '[clean]')
383+
uses: actions/cache@v4
384+
with:
385+
path: |
386+
${{ steps.setup-flutter.outputs.pub-cache-path }}
387+
build
388+
.dart_tool
389+
key: clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
315390

316391
- name: Setup .env File for macOS
317392
env:
@@ -329,18 +404,20 @@ jobs:
329404
run: |
330405
flutter build ios --release --no-codesign
331406
cd build/ios/iphoneos
407+
# Remove old Payload directory to avoid cp error on cached runs
408+
rm -rf Payload
332409
mkdir -p Payload
333410
cd Payload
334-
ln -s ../Runner.app
411+
cp -R ../Runner.app .
335412
cd ..
336413
zip -r Dartotsu-iOS-${{ github.ref_name }}.ipa Payload
337414
#Step 5 Upload ipa file to google drive
338415
- name: Upload File To Google Drive
339416
id: gdriveUpload
340417
uses: hoatruongdev09/google-drive-file-upload-github-action@v1.1
341418
with:
342-
file-path: build/ios/iphoneos/Dartotsu-iOS-main.ipa
343-
upload-name: Dartotsu-iOS-main.ipa
419+
file-path: build/ios/iphoneos/Dartotsu-iOS-${{github.ref_name}}.ipa
420+
upload-name: Dartotsu-iOS-${{github.ref_name}}.ipa
344421
upload-to-folder-id: ${{secrets.GOOGLE_FOLDER_MAIN}}
345422
service-account-json: "${{secrets.GOOGLE_KEY}}"
346423
overrwrite: true
@@ -358,10 +435,31 @@ jobs:
358435
uses: actions/checkout@v4
359436

360437
- name: Setup Flutter
438+
id: setup-flutter
361439
uses: subosito/flutter-action@v2
362440
with:
363441
flutter-version: 3.32.5
364-
cache: true
442+
- name: Cache Flutter dependencies (normal)
443+
if: ${{!contains(github.event.head_commit.message, '[clean]')}}
444+
uses: actions/cache@v4
445+
with:
446+
path: |
447+
${{ steps.setup-flutter.outputs.pub-cache-path }}
448+
build
449+
.dart_tool
450+
key: v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
451+
restore-keys: |
452+
v1-${{ runner.os }}-flutter-
453+
clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
454+
- name: Cache Flutter dependencies (clean)
455+
if: contains(github.event.head_commit.message, '[clean]')
456+
uses: actions/cache@v4
457+
with:
458+
path: |
459+
${{ steps.setup-flutter.outputs.pub-cache-path }}
460+
build
461+
.dart_tool
462+
key: clean-v1-${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
365463
- name: Setup .env File for macOS
366464
env:
367465
SIMKL_SECRET: ${{ secrets.SIMKL_SECRET }}
@@ -420,8 +518,8 @@ jobs:
420518
COMMIT_LOGS=$(git log $LAST_SHA..HEAD --pretty=format:"● %s ~%an [֍](https://github.com/${{ github.repository }}/commit/%H)" --max-count=10)
421519
# URL-encode the newline characters for GitHub Actions
422520
COMMIT_LOGS="${COMMIT_LOGS//'%'/'%25'}"
423-
COMMIT_LOGS="${COMMIT_LOGS//$'\n'/'%0A'}"
424-
COMMIT_LOGS="${COMMIT_LOGS//$'\r'/'%0D'}"
521+
COMMIT_LOGS="${COMMIT_LOGS//'/'%0A'}"
522+
COMMIT_LOGS="${COMMIT_LOGS//'/'%0D'}"
425523
# Append the encoded commit logs to the COMMIT_LOG environment variable
426524
echo "COMMIT_LOG=${COMMIT_LOGS}" >> $GITHUB_ENV
427525
# Debugging: Print the variable to check its content
@@ -655,13 +753,7 @@ jobs:
655753
-F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID}}" \
656754
-F "message_thread_id=${{secrets.TELEGRAM_THREAD_ID}}" \
657755
-F "document=@last_sha.txt" \
658-
-F "caption=New Alpha-Build dropped 🔥
659-
660-
Commits:
661-
${telegram_commit_messages}
662-
Devs:
663-
${telegram_dev_info}
664-
version: ${VERSION}" \
756+
-F "caption=New Alpha-Build dropped 🔥\n\n Commits:\n ${telegram_commit_messages}\n Devs:\n ${telegram_dev_info}\n version: ${VERSION}" \
665757
-F "parse_mode=HTML")
666758
667759
- name: Upload Current SHA as Artifact
@@ -728,31 +820,26 @@ jobs:
728820
MESSAGE="🎉 *Build Notification* 🎉"
729821
730822
if [[ -n "${{ env.apk_message }}" ]]; then
731-
MESSAGE="$MESSAGE
732-
${{ env.apk_message }}"
823+
MESSAGE="$MESSAGE\n ${{ env.apk_message }}"
733824
fi
734825
if [[ -n "${{ env.windows_message }}" ]]; then
735-
MESSAGE="$MESSAGE
736-
${{ env.windows_message }}"
826+
MESSAGE="$MESSAGE\n ${{ env.windows_message }}"
737827
fi
738828
if [[ -n "${{ env.linux_message }}" ]]; then
739-
MESSAGE="$MESSAGE
740-
${{ env.linux_message }}"
829+
MESSAGE="$MESSAGE\n ${{ env.linux_message }}"
741830
fi
742831
if [[ -n "${{ env.ios_message }}" ]]; then
743-
MESSAGE="$MESSAGE
744-
${{ env.ios_message }}"
832+
MESSAGE="$MESSAGE\n ${{ env.ios_message }}"
745833
fi
746834
if [[ -n "${{ env.macos_message }}" ]]; then
747-
MESSAGE="$MESSAGE
748-
${{ env.macos_message }}"
835+
MESSAGE="$MESSAGE\n ${{ env.macos_message }}"
749836
fi
750837
751838
if [[ "$MESSAGE" != "🎉 *Build Notification* 🎉" ]]; then
752839
curl -sS -f -X POST \
753-
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKKEN }}/sendMessage" \
754-
-F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
755-
-F "message_thread_id=${{ secrets.TELEGRAM_THREAD_ID }}" \
840+
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKKEN}}/sendMessage" \
841+
-F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID}}" \
842+
-F "message_thread_id=${{ secrets.TELEGRAM_THREAD_ID}}" \
756843
-F parse_mode="Markdown" \
757844
-F disable_notification=true \
758845
-F "text=$MESSAGE"

0 commit comments

Comments
 (0)