Skip to content

Commit b92b0c3

Browse files
Update workflows to run on development branch instead of flutter_app
1 parent 55826f3 commit b92b0c3

File tree

3 files changed

+377
-0
lines changed

3 files changed

+377
-0
lines changed

.github/workflows/pull_request.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Badge Magic PR CI
2+
3+
on:
4+
pull_request:
5+
branches: [ "development" ]
6+
7+
env:
8+
ANDROID_EMULATOR_API: 34
9+
ANDROID_EMULATOR_ARCH: x86_64
10+
IPHONE_DEVICE_MODEL: iPhone 16 Pro Max
11+
IPAD_DEVICE_MODEL: iPad Pro 13-inch (M4)
12+
13+
jobs:
14+
common:
15+
name: Common Build
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Common Workflow
21+
uses: ./.github/actions/common
22+
23+
- name: Save PR number
24+
run: |
25+
mkdir -p ./pr
26+
echo ${{ github.event.number }} > ./pr/NR
27+
28+
- uses: actions/upload-artifact@v4
29+
with:
30+
name: pr
31+
path: pr/
32+
33+
android:
34+
name: Android Flutter Build
35+
needs: common
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Android Workflow
41+
uses: ./.github/actions/android
42+
43+
ios:
44+
name: iOS Flutter Build
45+
needs: common
46+
runs-on: macos-latest
47+
steps:
48+
- name: Set up Xcode
49+
uses: maxim-lobanov/[email protected]
50+
with:
51+
xcode-version: latest
52+
53+
- uses: actions/checkout@v4
54+
55+
- name: iOS Workflow
56+
uses: ./.github/actions/ios
57+
58+
screenshots-android:
59+
name: Screenshots (Android)
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Android Screenshot Workflow
65+
uses: ./.github/actions/screenshot-android
66+
with:
67+
ANDROID_EMULATOR_API: ${{ env.ANDROID_EMULATOR_API }}
68+
ANDROID_EMULATOR_ARCH: ${{ env.ANDROID_EMULATOR_ARCH }}
69+
70+
screenshots-ios:
71+
name: Screenshots (iOS)
72+
runs-on: macos-latest
73+
steps:
74+
- name: Set up Xcode
75+
uses: maxim-lobanov/[email protected]
76+
with:
77+
xcode-version: latest
78+
79+
- uses: actions/checkout@v4
80+
81+
- name: iOS Screenshot Workflow
82+
uses: ./.github/actions/screenshot-ios
83+
with:
84+
IPHONE_DEVICE_MODEL: ${{ env.IPHONE_DEVICE_MODEL }}
85+
IPAD_DEVICE_MODEL: ${{ env.IPAD_DEVICE_MODEL }}
86+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Delete Screenshots
2+
3+
on:
4+
pull_request_target:
5+
branches: [ "development" ]
6+
types:
7+
- closed
8+
9+
env:
10+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11+
12+
jobs:
13+
delete_screenshots:
14+
name: Delete Screenshots
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Delete Screenshots
18+
run: |
19+
git config --global user.name "github-actions[bot]"
20+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
21+
22+
git clone --branch=pr-screenshots --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} pr-screenshots
23+
cd pr-screenshots
24+
25+
rm -f ${{ github.event.number }}_*.png
26+
27+
# Force push to pr-screenshots branch
28+
git checkout --orphan temporary
29+
git add --all .
30+
git commit -am "[Auto] Delete screenshots for #${{ github.event.number }} ($(date +%Y-%m-%d.%H:%M:%S))"
31+
git branch -D pr-screenshots
32+
git branch -m pr-screenshots
33+
git push --force origin pr-screenshots

.github/workflows/push.yml

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
name: Badge Magic Push CI
2+
3+
on:
4+
push:
5+
branches: ["development"]
6+
7+
env:
8+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9+
ANDROID_EMULATOR_API: 34
10+
ANDROID_EMULATOR_ARCH: x86_64
11+
IPHONE_DEVICE_MODEL: iPhone 16 Pro Max
12+
IPAD_DEVICE_MODEL: iPad Pro 13-inch (M4)
13+
BARECHECK_GITHUB_APP_TOKEN: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}
14+
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
15+
ENCRYPTED_F10B5E0E5262_KEY: ${{ secrets.ENCRYPTED_F10B5E0E5262_KEY }}
16+
ENCRYPTED_IOS_IV: ${{ secrets.ENCRYPTED_IOS_IV }}
17+
ENCRYPTED_IOS_KEY: ${{ secrets.ENCRYPTED_IOS_KEY }}
18+
STORE_PASS: ${{ secrets.STORE_PASS }}
19+
ALIAS: ${{ secrets.ALIAS }}
20+
KEY_PASS: ${{ secrets.KEY_PASS }}
21+
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
22+
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
23+
24+
jobs:
25+
common:
26+
name: Common Build
27+
runs-on: ubuntu-latest
28+
outputs:
29+
VERSION_NAME: ${{ steps.flutter-version.outputs.VERSION_NAME }}
30+
VERSION_CODE: ${{ steps.flutter-version.outputs.VERSION_CODE }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Common Workflow
35+
uses: ./.github/actions/common
36+
37+
- name: Hydrate and Update Version
38+
id: flutter-version
39+
run: |
40+
git config --global user.name "github-actions[bot]"
41+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
42+
43+
# Get commit message
44+
commit_message=$(git log -1 --pretty=format:"%s")
45+
46+
git clone --branch=version https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} version
47+
cd version
48+
49+
# Read and increment version name
50+
IFS='.' read -r major minor patch < versionName.txt
51+
52+
if [[ "$commit_message" =~ ^feat: ]]; then
53+
next_minor=$((minor + 1))
54+
next_patch=0
55+
else
56+
next_minor=$((minor))
57+
next_patch=$((patch + 1))
58+
fi
59+
next_version_name="$major.$next_minor.$next_patch"
60+
echo "VERSION_NAME=$next_version_name" >> $GITHUB_OUTPUT
61+
echo "$next_version_name" > versionName.txt
62+
63+
# Read and increment version code
64+
read -r version_code < versionCode.txt
65+
66+
new_version_code=$((version_code + 1))
67+
echo "VERSION_CODE=$new_version_code" >> $GITHUB_OUTPUT
68+
echo "$new_version_code" > versionCode.txt
69+
70+
# Force push to version branch
71+
git checkout --orphan temporary
72+
git add --all .
73+
git commit -am "[Auto] Update versionName: $next_version_name & versionCode: $new_version_code ($(date +%Y-%m-%d.%H:%M:%S))"
74+
git branch -D version
75+
git branch -m version
76+
git push --force origin version
77+
78+
79+
android:
80+
name: Android Flutter Build
81+
needs: common
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- name: Prepare Build Keys
87+
if: ${{ github.repository == 'fossasia/badgemagic-app' }}
88+
env:
89+
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
90+
ENCRYPTED_F10B5E0E5262_KEY: ${{ secrets.ENCRYPTED_F10B5E0E5262_KEY }}
91+
run: |
92+
bash scripts/prep-android-key.sh
93+
94+
- name: Android Workflow
95+
uses: ./.github/actions/android
96+
with:
97+
STORE_PASS: ${{ secrets.STORE_PASS }}
98+
ALIAS: ${{ secrets.ALIAS }}
99+
KEY_PASS: ${{ secrets.KEY_PASS }}
100+
VERSION_NAME: ${{needs.common.outputs.VERSION_NAME}}
101+
VERSION_CODE: ${{needs.common.outputs.VERSION_CODE}}
102+
103+
- name: Upload APK
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: APK Generated
107+
path: build/app/outputs/flutter-apk
108+
109+
- name: Upload AAB Release
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: AAB Generated
113+
path: build/app/outputs/bundle
114+
115+
- name: Upload APK/AAB to apk branch
116+
if: ${{ github.repository == 'fossasia/badgemagic-app' }}
117+
run: |
118+
git config --global user.name "github-actions[bot]"
119+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
120+
121+
git clone --branch=apk https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} apk
122+
cd apk
123+
124+
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
125+
126+
echo "Removing previous files from branch"
127+
128+
rm -rf badge-magic-$branch*
129+
130+
ls
131+
132+
echo "Copying new build files"
133+
134+
find ../build/app/outputs/flutter-apk -type f \( -name '*.apk' -o -name '*.aab' \) -exec cp -v {} . \;
135+
find ../build/app/outputs/bundle -type f \( -name '*.apk' -o -name '*.aab' \) -exec cp -v {} . \;
136+
137+
ls
138+
139+
echo "Renaming new build files"
140+
141+
for file in app*; do
142+
mv $file badge-magic-$branch-${file#*-}
143+
done
144+
145+
ls
146+
147+
echo "Pushing to apk branch"
148+
149+
git checkout --orphan temporary
150+
git add --all .
151+
git commit -am "[Auto] Update APK/AAB's from $branch ($(date +%Y-%m-%d.%H:%M:%S))"
152+
git branch -D apk
153+
git branch -m apk
154+
git push --force origin apk
155+
156+
- name: Push app in open testing track
157+
if: ${{ github.repository == 'fossasia/badgemagic-app' }}
158+
run: |
159+
cd ./android
160+
git clone --branch=fastlane-android --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} fastlane
161+
fastlane uploadToOpenTesting
162+
if [[ $? -ne 0 ]]; then
163+
exit 1
164+
fi
165+
166+
ios:
167+
name: iOS Flutter Build
168+
needs: common
169+
runs-on: macos-latest
170+
steps:
171+
- name: Set up Xcode
172+
uses: maxim-lobanov/[email protected]
173+
with:
174+
xcode-version: latest
175+
176+
- uses: actions/checkout@v4
177+
178+
- name: Prepare Build Keys
179+
if: ${{ github.repository == 'fossasia/badgemagic-app' }}
180+
env:
181+
ENCRYPTED_IOS_IV: ${{ secrets.ENCRYPTED_IOS_IV }}
182+
ENCRYPTED_IOS_KEY: ${{ secrets.ENCRYPTED_IOS_KEY }}
183+
run: |
184+
bash scripts/prep-ios-key.sh
185+
186+
- name: Setup Certs
187+
if: ${{ github.repository == 'fossasia/badgemagic-app' }}
188+
env:
189+
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
190+
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
191+
run: |
192+
cd ./iOS
193+
git clone --branch=fastlane-ios --depth=1 https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} fastlane
194+
fastlane setupCertificates
195+
if [[ $? -ne 0 ]]; then
196+
exit 1
197+
fi
198+
199+
- name: iOS Workflow
200+
uses: ./.github/actions/ios
201+
with:
202+
VERSION_NAME: ${{needs.common.outputs.VERSION_NAME}}
203+
VERSION_CODE: ${{needs.common.outputs.VERSION_CODE}}
204+
205+
- name: Push app to testflight
206+
if: ${{ github.repository == 'fossasia/badgemagic-app' }}
207+
run: |
208+
cd ./iOS
209+
fastlane uploadToBeta
210+
if [[ $? -ne 0 ]]; then
211+
exit 1
212+
fi
213+
214+
update-release:
215+
name: Update Draft Release
216+
needs: [common, android, ios]
217+
runs-on: ubuntu-latest
218+
steps:
219+
- name: Download repository
220+
uses: actions/checkout@v4
221+
222+
- name: Run Release Drafter
223+
id: run-release-drafter
224+
uses: release-drafter/release-drafter@v6
225+
env:
226+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
227+
with:
228+
version: ${{ needs.common.outputs.VERSION_NAME }}
229+
230+
- name: Create and Upload Assets
231+
run: |
232+
echo "${{ needs.common.outputs.VERSION_CODE }}" > ./versionCode.txt
233+
git clone --branch=apk https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} apk
234+
gh release upload ${{ steps.run-release-drafter.outputs.tag_name }} apk/badge-magic-flutter_app-release.apk ./versionCode.txt --clobber
235+
236+
screenshots-android:
237+
name: Screenshots (Android)
238+
runs-on: ubuntu-latest
239+
steps:
240+
- uses: actions/checkout@v4
241+
242+
- name: Android Screenshot Workflow
243+
uses: ./.github/actions/screenshot-android
244+
with:
245+
ANDROID_EMULATOR_API: ${{ env.ANDROID_EMULATOR_API }}
246+
ANDROID_EMULATOR_ARCH: ${{ env.ANDROID_EMULATOR_ARCH }}
247+
248+
screenshots-ios:
249+
name: Screenshots (iOS)
250+
runs-on: macos-latest
251+
steps:
252+
- uses: actions/checkout@v4
253+
254+
- name: iOS Screenshot Workflow
255+
uses: ./.github/actions/screenshot-ios
256+
with:
257+
IPHONE_DEVICE_MODEL: ${{ env.IPHONE_DEVICE_MODEL }}
258+
IPAD_DEVICE_MODEL: ${{ env.IPAD_DEVICE_MODEL }}

0 commit comments

Comments
 (0)