Skip to content

Build & Release

Build & Release #2

Workflow file for this run

name: Build & Release
on:
pull_request:
branches:
- master
workflow_dispatch:
jobs:
build-apk:
runs-on: ubuntu-latest
name: Build APK
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set Up Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.1'
- name: Install Dependencies
run: flutter pub get
- name: Decode Keystore
run: |
echo "${{ secrets.ANDROID_KJS }}" | base64 --decode > android/app/key.jks
- name: Create local.properties
run: |
echo "storePassword=${{ secrets.ANDROID_STORE_PASSWORD }}" > android/local.properties
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/local.properties
- name: Build APK
run: flutter build apk --release --obfuscate --split-debug-info=splitMap
- name: Upload APK Artifact
uses: actions/upload-artifact@v3
with:
name: android-apk
path: build/app/outputs/flutter-apk/app-release.apk
build-msix:
runs-on: windows-latest
name: Build MSIX
needs: build-apk
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.1'
- name: Install Dependencies
run: flutter pub get
- name: Build MSIX
run: flutter build windows --release
- name: Upload MSIX Artifact
uses: actions/upload-artifact@v3
with:
name: windows-msix
path: build/windows/runner/Release/*.msix
# build-ios-macos:
# runs-on: macos-latest
# name: Build iOS & macOS
# needs: build-apk
#
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v3
#
# - name: Set Up Flutter
# uses: subosito/flutter-action@v2
# with:
# flutter-version: '3.27.0-0.2.pre'
#
# - name: Install Dependencies
# run: flutter pub get
#
# - name: Set Up Certificates and Profiles
# run: |
# echo "${{ secrets.CERTIFICATE }}" | base64 --decode > signing_certificate.p12
# echo "${{ secrets.PROFILE }}" | base64 --decode > provisioning_profile.mobileprovision
#
# - name: Build iOS
# run: flutter build ipa --release
#
# - name: Build macOS
# run: flutter build macos --release
#
# - name: Upload iOS Artifact
# uses: actions/upload-artifact@v3
# with:
# name: ios-ipa
# path: build/ios/ipa/*.ipa
#
# - name: Upload macOS Artifact
# uses: actions/upload-artifact@v3
# with:
# name: macos-app
# path: build/macos/Build/Products/Release/*.app
release:
runs-on: ubuntu-latest
name: Publish Release
needs: [ build-apk, build-msix ]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
# 下载构建产物
- name: Download APK Artifact
uses: actions/download-artifact@v3
with:
name: android-apk
path: artifacts/android
- name: Download MSIX Artifact
uses: actions/download-artifact@v3
with:
name: windows-msix
path: artifacts/windows
# - name: Download iOS Artifact
# uses: actions/download-artifact@v3
# with:
# name: ios-ipa
# path: artifacts/ios
#
# - name: Download macOS Artifact
# uses: actions/download-artifact@v3
# with:
# name: macos-app
# path: artifacts/macos
# 提取版本号
- name: Extract Version
id: extract_version
run: |
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
echo "VERSION=$version" >> $GITHUB_ENV
# 重命名构建产物
- name: Rename Artifacts
run: |
mkdir -p renamed-artifacts
mv artifacts/android/app-release.apk renamed-artifacts/moodiary-${{ env.VERSION }}-android-arm64.apk
mv artifacts/windows/*.msix renamed-artifacts/moodiary-${{ env.VERSION }}-windows-x64.msix
# mv artifacts/ios/*.ipa renamed-artifacts/moodiary-${{ env.VERSION }}-ios.ipa
# mv artifacts/macos/*.app renamed-artifacts/moodiary-${{ env.VERSION }}-macos.app
# 生成 Release Notes
- name: Generate Release Notes
id: release_notes
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
# 发布 Release
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: renamed-artifacts/*
tag: v${{ env.VERSION }}