-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcf3d99
commit 24062d5
Showing
4 changed files
with
191 additions
and
220 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
name: Build & Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
tags: | ||
- v* | ||
|
||
# 1. If we push to master with a tag, we will trigger workflow twice, use [concurrency] to prevent this | ||
# 2. If last workflow is still running, we push again, we will cancel the previous workflow | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
Build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- target: Android | ||
os: ubuntu-latest | ||
cache_key: android-flutter | ||
cache_path: /opt/hostedtoolcache/flutter | ||
cache_restore_keys_hash_file: pubspec.lock | ||
artifact_name: release-Android | ||
artifact_path: build/app/outputs/apk/release/*.apk | ||
- target: Windows | ||
os: windows-latest | ||
cache_key: windows-flutter | ||
cache_path: C:\hostedtoolcache\windows\flutter | ||
cache_restore_keys_hash_file: pubspec.lock | ||
artifact_name: release-Windows | ||
artifact_path: build/windows/*.zip | ||
- target: iOS | ||
os: macos-latest | ||
cache_key: ios-flutter | ||
cache_path: /Users/runner/hostedtoolcache/flutter | ||
cache_restore_keys_hash_file: pubspec.lock | ||
cache_pod_key: ios-pods | ||
cache_pod_path: ios/Pods | ||
cache_pod_restore_keys_hash_file: ios/Podfile.lock | ||
artifact_name: release-iOS | ||
artifact_path: build/**/*.ipa | ||
- target: macOS | ||
os: macos-latest | ||
cache_key: macos-flutter | ||
cache_path: /Users/runner/hostedtoolcache/flutter | ||
cache_restore_keys_hash_file: pubspec.lock | ||
cache_pod_key: macos-pods | ||
cache_pod_path: macos/Pods | ||
cache_pod_restore_keys_hash_file: macos/Podfile.lock | ||
artifact_name: release-macOS | ||
artifact_path: build/macos/*.zip | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
FLUTTER_VERSION: 3.3.1 | ||
steps: | ||
# Checkout branch | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
# Cache Flutter | ||
- name: Cache ${{matrix.target}} | ||
uses: actions/cache@v3 | ||
with: | ||
key: ${{ matrix.cache_key }} | ||
path: ${{ matrix.cache_path }} | ||
restore-keys: ${{ matrix.cache_key }}-${{ hashFiles(matrix.cache_restore_keys_hash_file)}} | ||
# Cache Pod | ||
- name: Cache Pod ${{matrix.target}} | ||
if: matrix.cache_pod_key != null | ||
uses: actions/cache@v3 | ||
with: | ||
key: ${{ matrix.cache_pod_key }} | ||
path: ${{ matrix.cache_pod_path }} | ||
restore-keys: ${{ matrix.cache_key }}-${{ hashFiles(matrix.cache_pod_restore_keys_hash_file)}} | ||
# Setup JDK | ||
- name: Setup JDK 11 (Android) | ||
if: matrix.target == 'Android' | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: '11' | ||
cache: gradle | ||
# Setup Flutter | ||
- name: Setup Flutter | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: ${{ env.FLUTTER_VERSION }} | ||
# Xcodebuild | ||
- name: Build Xcode | ||
if: matrix.os == 'macos-latest' | ||
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme Runner -configuration Release | ||
# Flutter Pub Get | ||
- name: Flutter Pub Get | ||
run: | | ||
git config --global core.longpaths true | ||
flutter pub get | ||
# Build Android .apk | ||
- name: Build apk | ||
if: matrix.target == 'Android' | ||
run: flutter build apk -t lib/src/main.dart --release --split-per-abi | ||
# Build iOS .app | ||
- name: Build iOS app | ||
if: matrix.target == 'ios' | ||
run: | | ||
cd ios | ||
pod update | ||
pod install | ||
cd .. | ||
flutter build ios -t lib/src/main.dart --release --no-codesign | ||
# Thin iOS .app | ||
- name: Thin iOS app | ||
if: matrix.target == 'iOS' | ||
run: sh thin-payload.sh build/ios/iphoneos/*.app | ||
# Build iOS .ipa | ||
- name: Build iOS ipa | ||
if: matrix.target == 'iOS' | ||
run: | | ||
version=$(head -n 5 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2) | ||
cd build | ||
mkdir -p Payload | ||
mv ios/iphoneos/*.app Payload | ||
zip -9 JHenTai_${version}.ipa -r Payload | ||
# Build macOS .app | ||
- name: Build macOS app | ||
if: matrix.target == 'macOS' | ||
run: | | ||
version=$(head -n 5 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2) | ||
cd macos | ||
pod update | ||
pod install | ||
cd .. | ||
flutter build macos -t lib/src/main.dart --release | ||
cp -a build/macos/Build/Products/Release/jhentai.app ./build | ||
cd build | ||
zip -qroy macos/JHenTai_${version}_macOS.zip jhentai.app | ||
- name: Build Windows | ||
if: matrix.target == 'Windows' | ||
run: | | ||
version=$(head -n 5 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2) | ||
flutter build windows -t lib/src/main.dart --release | ||
$DestDir = "build\windows\JHenTai" | ||
$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\JHenTai_${version}_windows.zip | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.artifact_name }} | ||
path: ${{ matrix.artifact_path }} | ||
Publish: | ||
if: startsWith(github.ref, 'refs/tag/') | ||
name: Publish | ||
needs: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Mkdir | ||
run: mkdir /tmp/artifacts | ||
- name: Download all Artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: /tmp/artifacts | ||
- run: ls -R /tmp/artifacts | ||
# - 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 }} | ||
# prerelease: true | ||
# allowUpdates: true | ||
# token: ${{ secrets.RELEASE_TOKEN }} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.