Merge branch 'master' of github.com:MCDFsteve/FnipaPlay #9
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 | |
# Trigger on push to master branch or with a tag | |
on: | |
push: | |
branches: | |
- '**' | |
tags: | |
- '0.*' | |
# If previous workflow is still running, we push again, we will cancel the previous workflow | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
Build: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: Android | |
os: ubuntu-latest | |
artifact_name: release-Android | |
artifact_path: build/app/outputs/apk/release/*.apk | |
- target: Windows | |
os: windows-latest | |
artifact_name: release-Windows | |
artifact_path: build/windows/*.zip | |
- target: Linux | |
os: ubuntu-latest | |
artifact_name: release-Linux | |
artifact_path: build/linux/*.deb | |
- target: iOS | |
os: macos-latest | |
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_pod_key: macos-pods | |
cache_pod_path: macos/Pods | |
cache_pod_restore_keys_hash_file: macos/Podfile.lock | |
artifact_name: release-macOS | |
artifact_path: /Users/runner/work/FnipaPlay/FnipaPlay/*.dmg | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
runs-on: ${{ matrix.os }} | |
env: | |
FLUTTER_VERSION: 3.22.3 | |
steps: | |
# Checkout branch | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Setup Android keystore (for Android) | |
- name: Setup Android keystore | |
if: matrix.target == 'Android' | |
run: | | |
echo "${{ secrets.ENCODED_KEYSTORE }}" | base64 -di > android/app/upload-keystore.jks | |
echo "${{ secrets.KEY_PROPERTIES }}" > android/key.properties | |
# Setup Flutter | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2.12.0 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
channel: 'stable' | |
cache: true | |
# Cache CocoaPods (for iOS/macOS) | |
- name: Cache Pod | |
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_pod_key }}-${{ hashFiles(matrix.cache_pod_restore_keys_hash_file) }} | |
# Setup JDK for Android | |
- name: Setup JDK 17 (Android) | |
if: matrix.target == 'Android' | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
cache: gradle | |
# Xcode build for iOS/macOS | |
- name: Build Xcode (iOS/macOS) | |
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 | |
# Get app version | |
- name: Get app version | |
id: get_version | |
run: | | |
echo "::set-output name=version::$(grep '^version:' pubspec.yaml | cut -d ' ' -f 2)" | |
# Build Android .apk | |
- name: Build Android | |
if: matrix.target == 'Android' | |
run: | | |
flutter build apk --release --split-per-abi | |
cd build/app/outputs/apk/release | |
mv app-arm64-v8a-release.apk FnipaPlay-${{ steps.get_version.outputs.version }}-arm64-v8a.apk | |
mv app-armeabi-v7a-release.apk FnipaPlay-${{ steps.get_version.outputs.version }}-armeabi-v7a.apk | |
mv app-x86_64-release.apk FnipaPlay-${{ steps.get_version.outputs.version }}-x86_64.apk | |
# Build iOS .ipa | |
- name: Build iOS | |
if: matrix.target == 'iOS' | |
run: | | |
cd ios | |
pod update | |
cd .. | |
flutter build ios --release --no-codesign | |
sh thin-payload.sh build/ios/iphoneos/*.app | |
cd build | |
mkdir -p Payload | |
mv ios/iphoneos/*.app Payload | |
zip -9 FnipaPlay_${{ steps.get_version.outputs.version }}.ipa -r Payload | |
# Build macOS .dmg | |
- name: Build macOS | |
if: matrix.target == 'macOS' | |
run: | | |
cd macos | |
pod update | |
cd .. | |
sh dmg.sh | |
# Build Windows .zip | |
- name: Build Windows | |
if: matrix.target == 'Windows' | |
run: | | |
flutter build windows --release | |
$DestDir = "build\windows\FnipaPlay_${{ steps.get_version.outputs.version }}" | |
$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\FnipaPlay_${{ steps.get_version.outputs.version }}_Windows.zip | |
# Build Linux .deb | |
- name: Build Linux | |
if: matrix.target == 'Linux' | |
run: | | |
# Install mpv and dependencies | |
sudo apt-get update -y | |
sudo apt-get install -y mpv libmpv-dev pkg-config clang cmake libgtk-3-dev ninja-build libasound2-dev libass-dev | |
# Build Flutter for Linux | |
flutter config --enable-linux-desktop | |
flutter build linux --release | |
# Create Debian package | |
mkdir -p build/linux/FnipaPlay-${{ steps.get_version.outputs.version }}-Linux-amd64 | |
cd build/linux/FnipaPlay-${{ steps.get_version.outputs.version }}-Linux-amd64 | |
mkdir -p opt/fnipaplay | |
mkdir -p usr/share/applications | |
mkdir -p usr/share/icons/hicolor/512x512/apps | |
cp -r ../x64/release/bundle/* opt/fnipaplay | |
cp -r ../../../assets/linux/DEBIAN . | |
chmod 0755 DEBIAN/postinst | |
chmod 0755 DEBIAN/postrm | |
cat > DEBIAN/control <<EOF | |
Maintainer: madoka773 <valigarmanda55@gmail.com> | |
Package: Fnipaplay | |
Version: ${{ steps.get_version.outputs.version }} | |
Section: x11 | |
Priority: optional | |
Architecture: amd64 | |
Essential: no | |
Installed-Size: 34648 | |
Description: A cross platform danmaku video player. | |
Homepage: https://github.com/MCDFsteve/FnipaPlay | |
Depends: ffmpeg, libass9 | |
EOF | |
cp ../../../assets/linux/io.github.MCDFsteve.FnipaPlay.desktop usr/share/applications | |
cp ../../../assets/images/logo512.png usr/share/icons/hicolor/512x512/apps/io.github.MCDFsteve.FnipaPlay.png | |
cd .. | |
dpkg-deb --build --root-owner-group FnipaPlay-${{ steps.get_version.outputs.version }}-Linux-amd64 | |
# Upload Artifacts | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.artifact_name }} | |
path: ${{ matrix.artifact_path }} | |
Publish: | |
if: startsWith(github.ref, 'refs/tags/') | |
name: Publish | |
needs: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Make tmp dir | |
run: mkdir /tmp/artifacts | |
- name: Download all Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: /tmp/artifacts | |
- name: List all Artifacts | |
run: ls -R /tmp/artifacts | |
- name: Upload to release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ github.ref_name }} | |
allowUpdates: true | |
artifacts: /tmp/artifacts/release-Android/*.apk,/tmp/artifacts/release-iOS/*.ipa,/tmp/artifacts/release-macOS/*.dmg,/tmp/artifacts/release-Windows/*.zip,/tmp/artifacts/release-Linux/*.deb | |
artifactErrorsFailBuild: true | |
replacesArtifacts: true |