Fix ci #395
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Release | |
on: | |
push: | |
branches: | |
- 'master' | |
tags: | |
- v* | |
- '!v*ios' | |
- '!v*apk' | |
- '!v*mac' | |
- '!v*win' | |
- '!v*.flutter2' | |
- '!v*.bot' | |
- '!v*.linux' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
env: | |
PACKAGE_NAME: Eros-FE | |
jobs: | |
Build_and_upload: | |
name: Build releases | |
strategy: | |
fail-fast: false | |
matrix: | |
target: ["android", "ios", "macos", "windows"] | |
flutter_version: ["3.22.x"] | |
flutter_channel: ["stable"] | |
include: | |
- target: android | |
os: ubuntu-latest | |
artifact_name: release-apk | |
artifact_path: build/app/outputs/apk/release/Eros-FE*.apk | |
- target: ios | |
os: macos-14 | |
artifact_name: release-ios | |
artifact_path: build/**/Eros-FE*.ipa | |
- target: ios | |
suffix: -canvas | |
os: macos-14 | |
artifact_name: release-ios-canvas | |
artifact_path: build/**/Eros-FE*.ipa | |
- target: macos | |
os: macos-14 | |
artifact_name: release-mac | |
artifact_path: build/macos/Eros-FE*.zip | |
- target: windows | |
os: windows-latest | |
artifact_name: release-windows | |
artifact_path: build/windows/Eros-FE*.zip | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
# Get app version | |
- name: Get app version | |
id: get_version | |
shell: bash | |
run: | | |
app_version=$(head -n 5 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2) | |
echo "app_version=${app_version}" >> $GITHUB_ENV | |
- name: show version | |
run: echo ${{ env.app_version }} | |
# - name: Cache Pods (build macos) | |
# uses: actions/cache@v3 | |
# if: matrix.target == 'macos' | |
# with: | |
# path: | | |
# macos/Pods | |
# key: ${{ runner.os }}-pods-${{ hashFiles('macos/Podfile.lock') }} | |
# restore-keys: | | |
# ${{ runner.os }}-pods- | |
# - name: Cache Pods (build ios) | |
# uses: actions/cache@v3 | |
# if: matrix.target == 'ios' | |
# with: | |
# path: | | |
# ios/Pods | |
# key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }} | |
# restore-keys: | | |
# ${{ runner.os }}-pods- | |
# git-crypt unlock | |
- name: Unlock secrets (MacOS) | |
if: matrix.os == 'macos-14' | |
run: | | |
brew install git-crypt | |
echo $GIT_CRYPT_KEY | base64 -d -o grypt.key | |
git-crypt unlock grypt.key | |
env: | |
GIT_CRYPT_KEY: ${{ secrets.ENCODED_GIT_CRYPT }} | |
- name: Unlock secrets (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
uses: sliteteam/[email protected] | |
env: | |
GIT_CRYPT_KEY: ${{ secrets.ENCODED_GIT_CRYPT }} | |
- name: Unlock secrets (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
Invoke-WebRequest -Uri https://github.com/AGWA/git-crypt/releases/download/0.7.0/git-crypt-0.7.0-x86_64.exe -OutFile git-crypt.exe | |
echo "${{ secrets.ENCODED_GIT_CRYPT }}" | openssl base64 -d -out git-crypt.key | |
.\git-crypt.exe unlock .\git-crypt.key | |
- name: Decode keystore | |
if: matrix.target == 'android' | |
run: | | |
echo $ENCODED_KEYSTORE | base64 -di > android/app/keystore.jks | |
env: | |
ENCODED_KEYSTORE: ${{ secrets.ENCODED_KEYSTORE }} | |
# 安装 JDK | |
- name: Setup Java JDK (Android) | |
if: matrix.target == 'android' | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
# cache: gradle | |
# 安装 Flutter | |
- name: Flutter action | |
uses: subosito/[email protected] | |
with: | |
flutter-version: ${{ matrix.flutter_version }} | |
channel: ${{ matrix.flutter_channel }} | |
- name: Flutter version | |
run: flutter --version | |
- name: Build resolve Swift dependencies | |
if: matrix.target == 'macos' | |
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme Runner -configuration Release | |
# - name: replace cronet_http | |
# if: matrix.target == 'macos' | |
# shell: bash | |
# run: | | |
# brew install gnu-sed | |
# export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" | |
# which sed | |
# which gsed | |
# gsed -i "s,#cronet_http: ^0.2.1,cronet_http: ^0.2.1,g" pubspec.yaml | |
# grep cronet_http pubspec.yaml | |
# git stash | |
- name: ios disable impeller | |
if: matrix.target == 'ios' && matrix.suffix == '-canvas' | |
run: | | |
sed -i '' '/FLTEnableImpeller/{n; s/true/false/;}' ios/Runner/Info.plist | |
- name: Flutter pub get | |
run: | | |
git config --global core.longpaths true | |
flutter pub get && flutter pub upgrade | |
flutter pub run build_runner build --delete-conflicting-outputs | |
flutter pub run intl_utils:generate | |
# 打包 apk | |
- name: Collect Apks | |
if: matrix.target == 'android' | |
run: flutter build apk --release | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD}} | |
# 打包 ipa | |
- name: Build ios app | |
if: matrix.target == 'ios' | |
run: | | |
sed -i '' 's/dev2.cn.honjow.fehv/cn.honjow.fehv/g' 'ios/Runner.xcodeproj/project.pbxproj' | |
rm ios/Podfile.lock | |
cd ios && pod update && pod install --repo-update && cd .. | |
flutter build ios --release --no-codesign | |
- name: upload-symbols | |
if: matrix.target == 'ios' | |
run: find build/ios/Release-iphoneos -name "*.dSYM" | xargs -I \{\} ios/Pods/FirebaseCrashlytics/upload-symbols -gsp ios/Runner/GoogleService-Info.plist -p ios \{\} | |
- name: Thin app | |
if: matrix.target == 'ios' | |
run: sh scripts/thin-payload.sh build/ios/iphoneos/*.app | |
- name: Build ipa file | |
if: matrix.target == 'ios' | |
run: | | |
cd build | |
mkdir -p Payload | |
mv ios/iphoneos/*.app Payload | |
zip -9 ${{ env.PACKAGE_NAME }}${{ matrix.suffix }}_${{ env.app_version }}.ipa -r Payload | |
# 打包 mac | |
- name: Build mac app | |
if: matrix.target == 'macos' | |
run: | | |
cd macos && pod update && pod install && cd .. | |
flutter build macos --release | |
APP_PATH=build/macos/Build/Products/Release/fehviewer.app | |
cp -a $APP_PATH ./build | |
cd build && zip -qroy macos/${{ env.PACKAGE_NAME }}_${{ env.app_version }}_macos.zip fehviewer.app | |
- name: Build windows | |
if: matrix.target == 'windows' | |
run: | | |
flutter build windows --release | |
$DestDir = "build\windows\${{ env.PACKAGE_NAME }}" | |
$SrcDir = "build\windows\x64\runner\Release" | |
New-Item -Path $DestDir -ItemType Directory | |
Copy-Item $SrcDir\* -Recurse $DestDir | |
Copy-Item -Filter *.dll -Path windows\* -Destination $DestDir -Force | |
Compress-Archive $DestDir build\windows\${{ env.PACKAGE_NAME }}_${{ env.app_version }}_windows.zip | |
- name: Publish Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.artifact_name }} | |
path: ${{ matrix.artifact_path }} | |
Publish_releases: | |
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha') && !contains(github.ref, 'rc') | |
name: Publish releases | |
needs: Build_and_upload | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- run: mkdir /tmp/artifacts | |
- name: Download all Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: /tmp/artifacts | |
- run: ls -R /tmp/artifacts | |
# Get app version | |
- name: Get app version | |
id: get_version | |
shell: bash | |
run: | | |
app_version=$(head -n 5 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2) | |
echo "app_version=${app_version}" >> $GITHUB_ENV | |
- name: Upload to release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "/tmp/artifacts/release-apk/*.apk,/tmp/artifacts/release-ios*/*.ipa,/tmp/artifacts/release-mac/*.zip" | |
tag: ${{ github.ref_name }} | |
bodyFile: changelog/v${{ env.app_version }}.md | |
prerelease: contains(github.ref, 'pre') | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
replacesArtifacts: true | |
# - name: Post release notes | |
# run: | | |
# changelog=$(cat changelog/v${{ env.app_version }}.md) | |
# curl 'https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage' \ | |
# --header 'Content-Type: application/x-www-form-urlencoded' \ | |
# -d parse_mode=markdown \ | |
# -d chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }} \ | |
# --data-urlencode text="[Eros-FE_${{ github.ref_name }}](https://github.com/honjow/FEhViewer/releases/tag/${{ github.ref_name }}) | |
# $changelog" \ | |
# -d disable_web_page_preview=true |