Skip to content

Commit 93bc063

Browse files
authored
Add fastlane and GitHub actions (#44)
2 parents 5df93b5 + d587e57 commit 93bc063

8 files changed

Lines changed: 511 additions & 51 deletions

File tree

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

.github/workflows/nightly-build-apk.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

android/Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "https://rubygems.org"
2+
3+
gem "fastlane"

0 commit comments

Comments
 (0)