Skip to content

Release and publish apps #78

Release and publish apps

Release and publish apps #78

Workflow file for this run

name: Release and publish apps
on:
workflow_dispatch:
jobs:
build-android:
name: Build for Android
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Ninja
run: sudo apt-get install -y ninja-build
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- run: flutter pub get
- run: dart run pdfrx:remove_wasm_modules
- name: Patch pdfrx
run: |
PDFRX_PATH=$(find $HOME/.pub-cache -type d -name "pdfium_flutter-*" | head -n 1)
CMAKE_FILE="$PDFRX_PATH/android/CMakeLists.txt"
if [ -f "$CMAKE_FILE" ]; then
sed -i '2i add_link_options("LINKER:--build-id=none")' "$CMAKE_FILE"
echo "Patched CMakeLists.txt in $CMAKE_FILE"
else
echo "CMakeLists.txt not found in expected location"
exit 1
fi
- name: Decode Keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/keystore.jks
- name: Create key.properties
run: |
echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" > android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties
echo "storeFile=keystore.jks" >> android/key.properties
- name: Build APK
run: flutter build apk --release
- name: Build appBundle
run: flutter build appbundle
- name: Prepare Android artifacts
run: |
mkdir -p release-artifacts
cp build/app/outputs/flutter-apk/app-release.apk release-artifacts/
cp build/app/outputs/bundle/release/app-release.aab release-artifacts/
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: android-artifacts
path: release-artifacts/
- name: Create google_service_account.json
run: |
echo "${{ secrets.GOOGLE_SERVICE_ACCOUNT }}" | base64 --decode > android/google_service_account.json
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0.2'
bundler-cache: true
working-directory: 'android'
- name: Deploy to Play Store
uses: maierj/fastlane-action@v3.1.0
with:
lane: deploy
subdirectory: android
build-macos:
name: Build for macOS
runs-on: macos-15
steps:
- uses: actions/checkout@v6
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- run: flutter pub get
- run: flutter build macos --release
- name: Codesign executable
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
MACOS_SIGN_IDENTITY: ${{ secrets.MACOS_SIGN_IDENTITY }}
run: |
echo "$MACOS_CERTIFICATE" | base64 --decode > certificate.p12
security create-keychain -p $KEYCHAIN_PASSWORD build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p $KEYCHAIN_PASSWORD build.keychain
security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $KEYCHAIN_PASSWORD build.keychain
security find-identity
/usr/bin/codesign --force --deep --options runtime --entitlements macos/Runner/Release.entitlements -s "$MACOS_SIGN_IDENTITY" build/macos/Build/Products/Release/Wispar.app
/usr/bin/codesign --verify --deep --strict --verbose=2 build/macos/Build/Products/Release/Wispar.app
- name: Notarize app
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
uses: lando/notarize-action@v2
with:
product-path: "build/macos/Build/Products/Release/Wispar.app"
appstore-connect-username: ${{ secrets.APPLE_ID }}
appstore-connect-password: ${{ secrets.APPLE_PASSWORD }}
appstore-connect-team-id: ${{ secrets.APPLE_TEAM_ID }}
- name: Staple notarization
run: |
xcrun stapler staple build/macos/Build/Products/Release/Wispar.app
- name: Create dmg
env:
MACOS_SIGN_IDENTITY: ${{ secrets.MACOS_SIGN_IDENTITY }}
run: |
brew install create-dmg
create-dmg \
--volname "Wispar" \
--window-size 800 529 \
--icon-size 130 \
--app-drop-link 540 250 \
"Wispar.dmg" \
build/macos/Build/Products/Release/Wispar.app
/usr/bin/codesign --force -s "$MACOS_SIGN_IDENTITY" Wispar.dmg
- uses: actions/upload-artifact@v7
with:
name: wispar-macos-dmg
path: Wispar.dmg
build-windows:
name: Build for Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Flutter pub get
run: flutter pub get
- name: Build Windows release
run: flutter build windows --release
- name: Copy required DLLs
shell: powershell
run: |
Copy-Item "C:\Windows\System32\msvcp140.dll" -Destination ".\build\windows\x64\runner\Release\"
Copy-Item "C:\Windows\System32\msvcp140_1.dll" -Destination ".\build\windows\x64\runner\Release\"
Copy-Item "C:\Windows\System32\msvcp140_2.dll" -Destination ".\build\windows\x64\runner\Release\"
Copy-Item "C:\Windows\System32\vcruntime140.dll" -Destination ".\build\windows\x64\runner\Release\"
Copy-Item "C:\Windows\System32\vcruntime140_1.dll" -Destination ".\build\windows\x64\runner\Release\"
- name: Install Inno Setup
shell: powershell
run: |
choco install innosetup -y
refreshenv
- name: Extract version from pubspec.yaml
shell: pwsh
id: extract_version
run: |
$pubspec = Get-Content pubspec.yaml
foreach ($line in $pubspec) {
if ($line -match '^version:\s*(.+)$') {
$version = $matches[1]
break
}
}
Write-Host "VERSION=$version"
echo "VERSION=$version" >> $env:GITHUB_ENV
- name: Patch ISS with correct version
shell: powershell
run: |
$issPath = ".\windows\wispar_setup.iss"
(Get-Content $issPath) -replace '#define MyAppVersion ".*"', '#define MyAppVersion "${{ env.VERSION }}"' | Set-Content $issPath
Write-Host "Patched ISS file with version ${{ env.VERSION }}"
- name: Create Windows installer
shell: powershell
run: |
$issPath = ".\windows\wispar_setup.iss"
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" $issPath
- name: Upload Windows installer
uses: actions/upload-artifact@v7
with:
name: windows-artifacts
path: windows\output\wispar_setup.exe
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build-android, build-macos, build-windows]
steps:
- uses: actions/checkout@v6
- name: Download Android artifacts
uses: actions/download-artifact@v8
with:
name: android-artifacts
path: android-artifacts
- name: Download macOS artifact
uses: actions/download-artifact@v8
with:
name: wispar-macos-dmg
path: macos-artifacts
- name: Download Windows artifact
uses: actions/download-artifact@v8
with:
name: windows-artifacts
path: windows-artifacts
- name: Extract version from pubspec.yaml
id: extract_version
run: |
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
echo "VERSION=$version" >> $GITHUB_ENV
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
artifacts: |
android-artifacts/app-release.apk,
android-artifacts/app-release.aab,
macos-artifacts/Wispar.dmg,
windows-artifacts/wispar_setup.exe
tag: v${{ env.VERSION }}
token: ${{ secrets.TOKEN }}
draft: true
generateReleaseNotes: true