Build and Deploy Releases #4
This file contains hidden or 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 and Deploy Releases | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_number: | |
| description: 'Release Version Number' | |
| required: true | |
| type: string | |
| android: | |
| description: 'Build Android Release' | |
| type: boolean | |
| default: true | |
| linux: | |
| description: 'Build Linux Release' | |
| type: boolean | |
| default: true | |
| windows: | |
| description: 'Build Windows Release' | |
| type: boolean | |
| default: true | |
| web: | |
| description: 'Build Web Release' | |
| type: boolean | |
| default: true | |
| env: | |
| FLUTTER_CHANNEL: "stable" | |
| RUBY_VERSION: "3.2.2" | |
| jobs: | |
| create_github_release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create a GitHub Release | |
| run: | | |
| if gh release view "${{ inputs.version_number }}" > /dev/null 2>&1; then | |
| echo "Release '${{ inputs.version_number }}' already exists. Skipping release creation." | |
| else | |
| echo "Release '${{ inputs.version_number }}' does not exist. Creating release..." | |
| gh release create "${{ inputs.version_number }}" --title "Version ${{ inputs.version_number }}" --generate-notes | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| build_web: | |
| if: ${{ inputs.web }} | |
| name: Build Web | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run Flutter tasks | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version-file: 'pubspec.yaml' | |
| channel: ${{ env.FLUTTER_CHANNEL }} | |
| - name: Generate Localizations | |
| run: flutter gen-l10n | |
| - uses: bluefireteam/flutter-gh-pages@v9 | |
| with: | |
| baseHref: /FlutterMarkdownEditor/ | |
| build_linux: | |
| if: ${{ inputs.linux }} | |
| name: Build Linux | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 40 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Run Flutter tasks | |
| uses: subosito/flutter-action@v2.16.0 | |
| with: | |
| flutter-version-file: 'pubspec.yaml' | |
| channel: ${{ env.FLUTTER_CHANNEL }} | |
| architecture: x64 | |
| cache: true | |
| - name: Install System Dependencies | |
| run: | | |
| sudo apt-get update -y && sudo apt-get upgrade -y | |
| sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev | |
| - name: Install Flutter Dependencies | |
| run: flutter pub get | |
| - name: Generate Localizations | |
| run: flutter gen-l10n | |
| - name: Install Fastforge | |
| run: dart pub global activate fastforge | |
| - name: Install Build Dependencies | |
| run: | | |
| sudo apt-get -y install libfuse-dev locate | |
| wget -q "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" -O /usr/local/bin/appimagetool | |
| chmod +x /usr/local/bin/appimagetool | |
| sudo apt-get -y install dpkg | |
| sudo apt-get -y install patchelf rpm | |
| - name: Build and release | |
| run: fastforge release --name production | |
| - name: "Publish Linux Release" | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| run: | | |
| REL_VER=$(grep "^version" pubspec.yaml | cut -d' ' -f2) | |
| for PKG in AppImage deb rpm; do | |
| mv "dist/${REL_VER}/markdown_editor-${REL_VER}-linux.${PKG}" "MarkdownEditor-Linux-${PKG}.${PKG}" | |
| gh release upload ${{ inputs.version_number }} "MarkdownEditor-Linux-${PKG}.${PKG}" --clobber | |
| done | |
| build_windows: | |
| if: ${{ inputs.windows }} | |
| name: Build Windows | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install yq | |
| run: choco install yq | |
| - name: Run Flutter tasks | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version-file: 'pubspec.yaml' | |
| channel: ${{ env.FLUTTER_CHANNEL }} | |
| - name: Generate Localizations | |
| run: flutter gen-l10n | |
| - name: Build Windows Release | |
| run: flutter build windows --release | |
| - name: Install Inno Setup | |
| run: | | |
| Invoke-WebRequest -Uri http://files.jrsoftware.org/is/6/innosetup-6.4.2.exe -OutFile build\installer.exe | |
| git clone https://github.com/DomGries/InnoDependencyInstaller.git build\inno-depend | |
| Start-Process -Wait -FilePath build\installer.exe -ArgumentList '/verysilent', '/allusers', '/dir=build\iscc' | |
| - name: Run Inno Setup to Build Installer | |
| run: | | |
| build\iscc\iscc.exe scripts\windows-setup.iss /DMyAppVersion=${{ inputs.version_number }} | |
| - name: Upload Windows Release Artifact to GitHub Release | |
| shell: cmd | |
| run: | | |
| gh release upload ${{ inputs.version_number }} D:\a\FlutterMarkdownEditor\FlutterMarkdownEditor\MarkdownEditor-Windows.exe | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| build_android: | |
| if: ${{ inputs.android }} | |
| name: Build Android | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 40 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ env.RUBY_VERSION }} | |
| bundler-cache: true | |
| working-directory: 'android' | |
| - name: Run Flutter tasks | |
| uses: subosito/flutter-action@v2.16.0 | |
| with: | |
| flutter-version-file: 'pubspec.yaml' | |
| channel: ${{ env.FLUTTER_CHANNEL }} | |
| cache: true | |
| - name: Create google_service_account.json | |
| run: | | |
| echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_BASE64 }}" | base64 --decode > google_service_account.json | |
| - name: Create key.jks | |
| run: | | |
| echo "${{ secrets.ANDROID_KEYSTORE_FILE_BASE64 }}" | base64 --decode > android/key.jks | |
| - name: Create key.properties | |
| run: | | |
| cat <<EOF > android/key.properties | |
| storePassword=${{ secrets.ANDROID_KEY_STORE_PASSWORD }} | |
| keyPassword=${{ secrets.ANDROID_KEY_STORE_PASSWORD }} | |
| keyAlias=upload | |
| storeFile=../key.jks | |
| EOF | |
| env: | |
| ANDROID_KEY_STORE_PASSWORD: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }} | |
| - name: Release To Play Store | |
| uses: maierj/fastlane-action@v3.1.0 | |
| with: | |
| lane: 'release_play_store' | |
| subdirectory: android | |
| options: '{ "version_number": "${{ inputs.version_number }}" }' | |
| env: | |
| APP_PACKAGE_NAME: ${{ secrets.APP_PACKAGE_NAME }} | |
| - name: Build APK | |
| uses: maierj/fastlane-action@v3.1.0 | |
| with: | |
| lane: 'build_apk' | |
| subdirectory: android | |
| options: '{ "version_number": "${{ inputs.version_number }}" }' | |
| - name: Upload APK Artifact to GitHub Release | |
| run: gh release upload ${{ inputs.version_number }} build/app/outputs/flutter-apk/MarkdownEditor-Android.apk | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} |