1+ name : " Release Build APK"
2+ on :
3+ workflow_dispatch :
4+
5+ jobs :
6+ build-release :
7+ name : " Build Release APK"
8+ runs-on : ubuntu-latest
9+ steps :
10+ - name : " Checkout repository"
11+ uses : actions/checkout@v4
12+
13+ # Caching strategies
14+ - name : " Flutter cache"
15+ uses : actions/cache@v3
16+ with :
17+ path : |
18+ ~/.pub-cache
19+ .dart_tool/
20+ build/
21+ key : ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
22+ restore-keys : ${{ runner.os }}-flutter-
23+
24+ - name : " Java cache"
25+ uses : actions/cache@v3
26+ with :
27+ path : |
28+ ~/.gradle/caches
29+ ~/.gradle/wrapper
30+ key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
31+ restore-keys : ${{ runner.os }}-gradle-
32+
33+ - name : " Set up Java"
34+ uses : actions/setup-java@v4
35+ with :
36+ distribution : " oracle"
37+ java-version : " 22"
38+ cache : " gradle"
39+
40+ - name : " Set up Flutter"
41+ uses : subosito/flutter-action@v2
42+ with :
43+ channel : stable
44+ flutter-version-file : pubspec.yaml
45+ cache : true
46+
47+ - name : " Install Flutter dependencies"
48+ run : flutter pub get
49+
50+ - name : " Setup Ruby"
51+ uses : ruby/setup-ruby@v1
52+ with :
53+ ruby-version : ' 3.1'
54+ working-directory : ' android'
55+ bundler-cache : true
56+
57+ - name : " Find next release tag"
58+ id : find_tag
59+ run : |
60+ TAG_DATE=$(date +'%Y.%m.%d')
61+ TAG_PREFIX="Release-"
62+ BASE_TAG="$TAG_DATE"
63+ COUNT=0
64+ FULL_TAG="${TAG_PREFIX}${BASE_TAG}.${COUNT}"
65+
66+ git fetch --tags
67+
68+ while git ls-remote --tags origin | grep -q "refs/tags/$FULL_TAG"; do
69+ COUNT=$((COUNT + 1))
70+ FULL_TAG="${TAG_PREFIX}${BASE_TAG}.${COUNT}"
71+ done
72+
73+ echo "Next tag: $FULL_TAG"
74+ echo "VERSION_NAME=$FULL_TAG" >> $GITHUB_ENV
75+ echo "VERSION_CODE=$BASE_TAG.$COUNT" >> $GITHUB_ENV
76+
77+ - name : " Run Fastlane Release Build"
78+ working-directory : android
79+ run : bundle exec fastlane buildRelease
80+
81+ - name : " Upload Release APK"
82+ uses : actions/upload-artifact@v4
83+ with :
84+ name : movetopia-release
85+ path : android/fastlane/build/outputs/movetopia-release.apk
86+
87+ - name : " Get current date"
88+ id : date
89+ run : echo "date=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
90+
91+ - name : " Create release tag"
92+ uses : ncipollo/release-action@v1
93+ with :
94+ generateReleaseNotes : true
95+ prerelease : false
96+ tag : ${{ env.VERSION_NAME }}
97+ name : ${{ env.VERSION_NAME }}
98+ artifacts : " android/fastlane/build/outputs/movetopia-release.apk"
0 commit comments