Skip to content

Flutter Build

Flutter Build #117

Workflow file for this run

name: 1.Flutter Build
on: workflow_dispatch
permissions: write-all
env:
flutter_version: '3.24.2'
jobs:
build_android:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: tools/pnpm-lock.yaml
- name: Pnpm install
run: |
cd tools && pnpm i && cd ..
- name: Change version info
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
node tools/increment-build-number.mjs ${{ github.server_url }} ${{ github.repository }} ${{ github.run_id }} ${{ github.run_attempt }}
- name: Install JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.flutter_version }}
channel: stable
cache: true
- name: Setup Flutter
run: |
flutter config --no-cli-animations
- name: Build APK
run: |
flutter build apk --target-platform android-arm64,android-arm
- name: Sign APK
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: build/app/outputs/flutter-apk
signingKeyBase64: ${{ secrets.APK_SIGN_JKS_BASE64 }}
alias: ${{ secrets.APK_SIGN_ALIAS }}
keyStorePassword: ${{ secrets.APK_SIGN_PASS }}
keyPassword: ${{ secrets.APK_SIGN_ALIAS_PASS }}
env:
BUILD_TOOLS_VERSION: "34.0.0"
- name: Get Git info
id: get_git_info
run: |
git fetch --tags
echo "LATEST_VERSION="$(git tag --sort=-creatordate | head -n 1) >> "$GITHUB_ENV"
- name: Rename APK file
run: |
mkdir -p build/upload-artifacts/
mv build/app/outputs/flutter-apk/app-release-signed.apk build/upload-artifacts/sitlife-${{ env.LATEST_VERSION }}.apk
- name: Publish Android Artifact
uses: actions/upload-artifact@v4
with:
name: sitlife-Android-release
path: build/upload-artifacts/sitlife-${{ env.LATEST_VERSION }}.apk
build_ios:
runs-on: macos-14 # macos-latest is macos-12 actually, and iOS 17+ SDK not supported
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: tools/pnpm-lock.yaml
- name: Pnpm install
run: |
cd tools && pnpm i && cd ..
- name: Change version info
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
node tools/increment-build-number.mjs ${{ github.server_url }} ${{ github.repository }} ${{ github.run_id }} ${{ github.run_attempt }}
- name: Change Develop to Distribution
run: |
node tools/to-distro.mjs
- name: Install Apple Certificate
uses: apple-actions/import-codesign-certs@v3
with:
p12-file-base64: ${{ secrets.P12_BASE64 }}
p12-password: ${{ secrets.P12_PASSWORD }}
- name: Install the provisioning profile
env:
PROVISIONING_CERTIFICATE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }}
run: |
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode --output $PP_PATH
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.flutter_version }}
channel: stable
cache: true
- name: Setup Flutter
run: |
flutter config --no-cli-animations
- name: Build iOS
run: |
flutter build ios --release --no-codesign
- name: Build resolve Swift dependencies
run: |
xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme Runner -configuration Release
- name: Build xArchive
run: |
xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner -configuration Release DEVELOPMENT_TEAM="6MZL7DZ5BQ" -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE="516cedde-fe70-4902-bebe-438890797bf5" clean archive CODE_SIGN_IDENTITY="Apple Distribution: Chenchen Fan"
- name: Export ipa
run: |
xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/ExportOptions.plist
- name: Get Git info
id: get_git_info
run: |
git fetch --tags
echo "LATEST_VERSION="$(git tag --sort=-creatordate | head -n 1) >> "$GITHUB_ENV"
- name: Rename ipa file
run: |
mkdir -p build/upload-artifacts/
mv build-output/ios/life.mysit.SITLife.ipa build/upload-artifacts/sitlife-${{ env.LATEST_VERSION }}.ipa
- name: Publish iOS Artifact
uses: actions/upload-artifact@v4
with:
name: sitlife-iOS-release
path: build/upload-artifacts/sitlife-${{ env.LATEST_VERSION }}.ipa
after_build:
runs-on: macos-latest
needs: [ build_android, build_ios ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: tools/pnpm-lock.yaml
- name: Pnpm install
run: |
cd tools && pnpm i && cd ..
- name: Change version info
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
node tools/increment-build-number.mjs ${{ github.server_url }} ${{ github.repository }} ${{ github.run_id }} ${{ github.run_attempt }}
- name: Get Git info
id: get_git_info
run: |
git fetch --tags
echo "LATEST_VERSION="$(git tag --sort=-creatordate | head -n 1) >> "$GITHUB_ENV"
- name: Get iOS Artifact
if: github.repository == 'liplum-dev/mimir'
uses: actions/download-artifact@v4
with:
name: sitlife-iOS-release
path: build/
- name: Deploy to App Store (TestFlight)
if: github.repository == 'liplum-dev/mimir'
uses: apple-actions/upload-testflight-build@v1
with:
app-path: ${{ github.workspace }}/build/sitlife-${{ env.LATEST_VERSION }}.ipa
issuer-id: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
api-key-id: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}
api-private-key: ${{ secrets.APP_STORE_CONNECT_API_PRIVATE_KEY }}
- name: Get Android Artifact
if: github.repository == 'liplum-dev/mimir'
uses: actions/download-artifact@v4
with:
name: sitlife-Android-release
path: build/
- name: Upload preview file onto SIT-MC server
if: github.repository == 'liplum-dev/mimir'
continue-on-error: true
env:
SITMC_TEMP_SERVER_AUTH: ${{ secrets.SITMC_TEMP_SERVER_AUTH }}
run: |
node tools/upload-sitmc.mjs build/sitlife-${{ env.LATEST_VERSION }}.apk -d mimir-preview/latest.apk
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref }}
- name: Notify the latest building
if: github.repository == 'liplum-dev/mimir'
continue-on-error: true
env:
QQBOT_URL: ${{ secrets.gocq_sendgroupmsg_url }}
run: |
node tools/bot-notify-build.mjs -v ${{ env.LATEST_VERSION }}