fix post Comment #227
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' | |
# - 'build' | |
tags: | |
- v* | |
- '!v*ios' | |
- '!v*apk' | |
- '!v*mac' | |
- '!v*win' | |
- '!v*.flutter2' | |
- '!v*.bot' | |
env: | |
APP_DEV_PROVISION_PATH: '/tmp/app_dev.mobileprovision' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
Build_and_upload: | |
name: Build releases | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: android | |
os: ubuntu-latest | |
flutter_version: '3.13' | |
flutter_channel: 'stable' | |
artifact_name: release-apk | |
artifact_path: build/app/outputs/apk/release/*.apk | |
- target: ios | |
os: macos-12 | |
flutter_version: '3.13' | |
flutter_channel: 'stable' | |
artifact_name: release-ios | |
artifact_path: build/**/*.ipa | |
- target: macos | |
os: macos-12 | |
flutter_version: '3.13' | |
flutter_channel: 'stable' | |
artifact_name: release-mac | |
artifact_path: build/macos/*.zip | |
- target: windows | |
os: windows-latest | |
flutter_version: '3.13' | |
flutter_channel: 'stable' | |
artifact_name: release-windows | |
artifact_path: build/windows/*.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 Flutter (Linux) | |
# if: matrix.os == 'ubuntu-latest' | |
# uses: actions/cache@v3 | |
# with: | |
# key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }} | |
# path: /opt/hostedtoolcache/flutter | |
# restore-keys: | | |
# ${{ runner.os }}-flutter- | |
# | |
# - name: Cache Flutter (MacOS) | |
# if: matrix.os == 'macos-12' | |
# uses: actions/cache@v3 | |
# with: | |
# key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }} | |
# path: /Users/runner/hostedtoolcache/flutter | |
# restore-keys: | | |
# ${{ runner.os }}-flutter- | |
# | |
# - name: Cache Flutter (Windows) | |
# if: matrix.os == 'windows-latest' | |
# uses: actions/cache@v3 | |
# with: | |
# key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }} | |
# path: 'C:\hostedtoolcache\windows\flutter' | |
# restore-keys: | | |
# ${{ runner.os }}-flutter- | |
# - name: Cache Gradle packages (Android) | |
# if: matrix.target == 'android' | |
# uses: actions/cache@v3 | |
# with: | |
# path: | | |
# ~/.gradle/caches | |
# ~/.gradle/wrapper | |
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
# restore-keys: | | |
# ${{ runner.os }}-gradle- | |
- 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-12' | |
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 11 (Android) | |
if: matrix.target == 'android' | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
cache: gradle | |
# 安装 Flutter | |
- name: Flutter action | |
uses: subosito/flutter-action@v2 | |
with: | |
# flutter-version: ${{ matrix.flutter_version }} | |
channel: ${{ matrix.flutter_channel }} | |
- name: Build resolve Swift dependencies | |
if: matrix.os == 'macos-12' | |
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme Runner -configuration Release | |
# - name: replace isar | |
# if: matrix.target == 'windows' | |
# shell: bash | |
# run: | | |
# sed -i "s#isar: ^3.0.2'#isar: 3.0.0-dev.8#g" pubspec.yaml | |
# git stash | |
- name: Flutter pub get | |
run: | | |
git config --global core.longpaths true | |
flutter pub get | |
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' | |
cd ios && pod update && pod install && cd .. | |
flutter build ios --release --no-codesign | |
- 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 FEhViewer_${{ 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/FEhViewer_${{ env.app_version }}_macos.zip fehviewer.app | |
- name: Build windows | |
if: matrix.target == 'windows' | |
run: | | |
flutter build windows --release | |
$DestDir = "build\windows\FEhViewer" | |
$SrcDir = "build\windows\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\FEhViewer_${{ 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,/tmp/artifacts/release-windows/*.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="[FEhViewer_${{ github.ref_name }}](https://github.com/honjow/FEhViewer/releases/tag/${{ github.ref_name }}) | |
# $changelog" \ | |
# -d disable_web_page_preview=true |