@@ -33,17 +33,21 @@ jobs:
3333 - name : Run Tests
3434 run : flutter test
3535
36- # Build and release job
37- build-and-release :
38- name : Build & Release
36+ # Extract version information (shared by both build jobs)
37+ version :
38+ name : Extract Version
3939 if : github.event_name == 'push' && github.ref == 'refs/heads/main'
4040 runs-on : ubuntu-latest
41+ outputs :
42+ version : ${{ steps.version.outputs.version }}
43+ version_code : ${{ steps.version.outputs.version_code }}
44+ tag : ${{ steps.version.outputs.tag }}
45+ prev_tag : ${{ steps.version.outputs.prev_tag }}
4146 steps :
4247 - uses : actions/checkout@v4
4348 with :
4449 fetch-depth : 0
4550 fetch-tags : true
46- token : ${{ secrets.TOKEN }}
4751
4852 - name : Extract Version from pubspec.yaml
4953 id : version
@@ -64,22 +68,32 @@ jobs:
6468 echo "🔢 Version Code: $VERSION_CODE"
6569 echo "🏷️ Git Tag: $TAG"
6670
67- # Export to environment
68- echo "VERSION =$VERSION" >> $GITHUB_ENV
69- echo "VERSION_CODE =$VERSION_CODE" >> $GITHUB_ENV
70- echo "TAG =$TAG" >> $GITHUB_ENV
71+ # Set outputs
72+ echo "version =$VERSION" >> $GITHUB_OUTPUT
73+ echo "version_code =$VERSION_CODE" >> $GITHUB_OUTPUT
74+ echo "tag =$TAG" >> $GITHUB_OUTPUT
7175
7276 - name : Find Previous Release for Changelog
77+ id : prev_tag
7378 run : |
7479 # Get the most recent version tag for changelog comparison
7580 PREV_TAG=$(git tag -l 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -1)
7681
7782 if [ -n "$PREV_TAG" ]; then
78- echo "PREV_TAG =$PREV_TAG" >> $GITHUB_ENV
83+ echo "prev_tag =$PREV_TAG" >> $GITHUB_OUTPUT
7984 else
80- echo "PREV_TAG =" >> $GITHUB_ENV
85+ echo "prev_tag =" >> $GITHUB_OUTPUT
8186 fi
8287
88+ # Android build job
89+ build-android :
90+ name : Build Android
91+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
92+ needs : version
93+ runs-on : ubuntu-latest
94+ steps :
95+ - uses : actions/checkout@v4
96+
8397 - uses : actions/setup-java@v4
8498 with :
8599 distribution : ' zulu'
@@ -122,9 +136,41 @@ jobs:
122136 flutter build apk --release --split-per-abi
123137
124138 cd build/app/outputs/apk/release
125- mv app-armeabi-v7a-release.apk SysAdmin-v${{ env.VERSION }}-armeabi-v7a.apk
126- mv app-arm64-v8a-release.apk SysAdmin-v${{ env.VERSION }}-arm64-v8a.apk
127- mv app-x86_64-release.apk SysAdmin-v${{ env.VERSION }}-x86_64.apk
139+ mv app-armeabi-v7a-release.apk SysAdmin-v${{ needs.version.outputs.version }}-armeabi-v7a.apk
140+ mv app-arm64-v8a-release.apk SysAdmin-v${{ needs.version.outputs.version }}-arm64-v8a.apk
141+ mv app-x86_64-release.apk SysAdmin-v${{ needs.version.outputs.version }}-x86_64.apk
142+
143+ # Upload Android artifacts
144+ - name : Upload Android Artifacts
145+ uses : actions/upload-artifact@v4
146+ with :
147+ name : android-apks
148+ path : |
149+ build/app/outputs/apk/release/SysAdmin-v${{ needs.version.outputs.version }}-armeabi-v7a.apk
150+ build/app/outputs/apk/release/SysAdmin-v${{ needs.version.outputs.version }}-arm64-v8a.apk
151+ build/app/outputs/apk/release/SysAdmin-v${{ needs.version.outputs.version }}-x86_64.apk
152+
153+ # iOS build job
154+ build-ios :
155+ name : Build iOS
156+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
157+ needs : version
158+ runs-on : macos-latest
159+ steps :
160+ - uses : actions/checkout@v4
161+
162+ - uses : subosito/flutter-action@v2
163+ with :
164+ flutter-version : ' 3.29.2'
165+ channel : ' stable'
166+ architecture : x64
167+
168+ # Quality checks
169+ - name : Flutter Analyze
170+ run : flutter analyze
171+
172+ - name : Run Tests
173+ run : flutter test
128174
129175 # Build iOS
130176 - name : Build iOS App
@@ -133,36 +179,69 @@ jobs:
133179 cd build/ios/iphoneos
134180 mkdir -p Payload
135181 cp -r Runner.app Payload/
136- zip -r SysAdmin-v${{ env.VERSION }}.ipa Payload
182+ zip -r SysAdmin-v${{ needs.version.outputs.version }}.ipa Payload
183+
184+ # Upload iOS artifacts
185+ - name : Upload iOS Artifacts
186+ uses : actions/upload-artifact@v4
187+ with :
188+ name : ios-ipa
189+ path : build/ios/iphoneos/SysAdmin-v${{ needs.version.outputs.version }}.ipa
190+
191+ # Release job (runs after both builds complete)
192+ release :
193+ name : Create Release
194+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
195+ needs : [version, build-android, build-ios]
196+ runs-on : ubuntu-latest
197+ steps :
198+ - uses : actions/checkout@v4
199+ with :
200+ fetch-depth : 0
201+ fetch-tags : true
202+ token : ${{ secrets.TOKEN }}
203+
204+ # Download all artifacts
205+ - name : Download Android Artifacts
206+ uses : actions/download-artifact@v4
207+ with :
208+ name : android-apks
209+ path : android-artifacts
210+
211+ - name : Download iOS Artifacts
212+ uses : actions/download-artifact@v4
213+ with :
214+ name : ios-ipa
215+ path : ios-artifacts
137216
138217 # Create Tag if it doesn't exist
139218 - name : Create Tag
140219 run : |
141- if ! git rev-parse ${{ env.TAG }} >/dev/null 2>&1; then
220+ if ! git rev-parse ${{ needs.version.outputs.tag }} >/dev/null 2>&1; then
142221 git config --local user.email "action@github.com"
143222 git config --local user.name "GitHub Action"
144- git tag ${{ env.TAG }}
145- git push origin ${{ env.TAG }}
146- echo "Created new tag: ${{ env.TAG }}"
223+ git tag ${{ needs.version.outputs.tag }}
224+ git push origin ${{ needs.version.outputs.tag }}
225+ echo "Created new tag: ${{ needs.version.outputs.tag }}"
147226 else
148- echo "Tag ${{ env.TAG }} already exists, skipping tag creation"
227+ echo "Tag ${{ needs.version.outputs.tag }} already exists, skipping tag creation"
149228 fi
150229
151230 # Create Release
152231 - name : Create GitHub Release
153232 uses : ncipollo/release-action@v1
154233 with :
155234 artifacts : |
156- build/app/outputs/apk/release/ SysAdmin-v${{ env.VERSION }}-armeabi-v7a.apk
157- build/app/outputs/apk/release/ SysAdmin-v${{ env.VERSION }}-arm64-v8a.apk
158- build/app/outputs/apk/release/ SysAdmin-v${{ env.VERSION }}-x86_64.apk
159- build/ ios/iphoneos/ SysAdmin-v${{ env.VERSION }}.ipa
235+ android-artifacts/ SysAdmin-v${{ needs.version.outputs.version }}-armeabi-v7a.apk
236+ android-artifacts/ SysAdmin-v${{ needs.version.outputs.version }}-arm64-v8a.apk
237+ android-artifacts/ SysAdmin-v${{ needs.version.outputs.version }}-x86_64.apk
238+ ios-artifacts/ SysAdmin-v${{ needs.version.outputs.version }}.ipa
160239 token : ${{ secrets.TOKEN }}
161- tag : ${{ env.TAG }}
162- name : Release ${{ env.TAG }}
240+ tag : ${{ needs.version.outputs.tag }}
241+ name : Release ${{ needs.version.outputs.tag }}
163242 body : |
164- # Release ${{ env.TAG }}
243+ # Release ${{ needs.version.outputs.tag }}
165244 ${{ github.event.head_commit.message }}
166- #### Full Changelog: [${{ env.PREV_TAG }}...${{ env.TAG }}](https://github.com/${{ github.repository }}/compare/${{ env.PREV_TAG }}...${{ env.TAG }})
245+ #### Full Changelog: [${{ needs.version.outputs.prev_tag }}...${{ needs.version.outputs.tag }}](https://github.com/${{ github.repository }}/compare/${{ needs.version.outputs.prev_tag }}...${{ needs.version.outputs.tag }})
167246 draft : false
168- prerelease : false
247+ prerelease : false
0 commit comments