Skip to content

Windows & Android release #139

Windows & Android release

Windows & Android release #139

Workflow file for this run

name: Windows & Android release
on:
workflow_dispatch:
inputs:
android:
type: boolean
description: 'Билд для Android.'
required: false
default: true
windows:
type: boolean
description: 'Билд для Windows.'
required: false
default: true
telegram:
type: boolean
description: 'Указывает, будет ли создаваться публикация в Telegram-канале.'
required: false
default: true
create-release:
type: boolean
description: 'Указывает, что будет создаваться Github Release.'
required: false
default: true
pre-release:
type: boolean
description: 'Указывает, что создаваемый Github Release будет иметь плашку pre-release.'
required: false
default: true
debug:
type: boolean
description: 'Запуск данного Action с SSH-подключением в случае, если билд оказался неудачным (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
build_android:
if: ${{ inputs.android }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
cache: true
channel: beta
flutter-version-file: pubspec.yaml
- name: Get dependencies
run: flutter pub get
- name: Sign Android release
run: |
echo '${{ secrets.ANDROID_KEYSTORE_FILE_BASE64 }}' | base64 --decode > android/app/upload-keystore.jks
echo '${{ secrets.ANDROID_KEY_PROPERTIES }}' > android/key.properties
- name: Build Android release
run: |
mkdir app-build
if [ "${{ inputs.pre-release }}" = "true" ]; then
flutter build apk --release --dart-define PRERELEASE=1
flutter build apk --release --split-per-abi --dart-define PRERELEASE=1
else
flutter build apk --release
flutter build apk --release --split-per-abi
fi
cp ./build/app/outputs/flutter-apk/app-release.apk "./app-build/Flutter VK Android.apk"
cp ./build/app/outputs/flutter-apk/app-arm64-v8a-release.apk "./app-build/Flutter VK Android (arm64-v8a).apk"
cp ./build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk "./app-build/Flutter VK Android (armeabi-v7a).apk"
cp ./build/app/outputs/flutter-apk/app-x86_64-release.apk "./app-build/Flutter VK Android (x86_64).apk"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Flutter VK Android.apk
path: ./app-build/Flutter VK Android.apk
retention-days: 3
- uses: actions/upload-artifact@v4
with:
name: Flutter VK Android (arm64-v8a).apk
path: ./app-build/Flutter VK Android (arm64-v8a).apk
retention-days: 3
- uses: actions/upload-artifact@v4
with:
name: Flutter VK Android (armeabi-v7a).apk
path: ./app-build/Flutter VK Android (armeabi-v7a).apk
retention-days: 3
- uses: actions/upload-artifact@v4
with:
name: Flutter VK Android (x86_64).apk
path: ./app-build/Flutter VK Android (x86_64).apk
retention-days: 3
- name: Debug with SSH on fail
if: ${{ failure() && inputs.debug }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
build_windows:
if: ${{ inputs.windows }}
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
cache: true
channel: beta
flutter-version-file: pubspec.yaml
- name: Get dependencies
run: flutter pub get
- name: Build Windows release
run: |
if ('${{ inputs.pre-release }}' -eq 'true') {
flutter build windows --release --dart-define PRERELEASE=1
} else {
flutter build windows --release
}
- name: Build installer and portable .7z archive
shell: bash
run: |
echo "Creating portable 7z archive"
"/c/Program Files/7-Zip/7z.exe" a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on "./build/Flutter VK portable.7z" "./build/Windows/x64/runner/Release/"
echo "Downloading and installing Inno installer"
make innoinstall
echo "Creating Windows installer"
make inno
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Flutter VK installer.exe
path: ./build/Flutter VK installer.exe
retention-days: 3
- uses: actions/upload-artifact@v4
with:
name: Flutter VK portable.7z
path: ./build/Flutter VK portable.7z
retention-days: 3
- name: Debug with SSH on fail
if: ${{ failure() && inputs.debug }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
publish:
runs-on: ubuntu-latest
if: ${{ inputs.create-release || inputs.telegram }}
needs: [build_android, build_windows]
steps:
- name: Checkout code
uses: actions/checkout@v3
- id: read-version
uses: NiklasLehnfeld/flutter-version-number-action@main
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: build/
merge-multiple: true
- name: Publish in Telegram
if: ${{ inputs.telegram }}
shell: pwsh
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }}
PRERELEASE: ${{ inputs.pre-release }}
run: |
$telegramToken = $env:TELEGRAM_TOKEN
$telegramTo = $env:TELEGRAM_TO
$preRelease = $env:PRERELEASE
$version = "${{ steps.read-version.outputs.version-number }}"
echo "Starting Telegram Local Bot API"
docker compose -f scripts/uploader/docker-compose.yml up -d
echo "Installing Python requirements"
pip install -r scripts/uploader/requirements.txt
echo "Uploading files to Telegram"
python scripts/uploader/main.py $telegramToken $telegramTo $version $preRelease http://localhost:8081 "build/Flutter VK Android.apk" "build/Flutter VK installer.exe" "build/Flutter VK portable.7z"
# TODO: Учитывать случай, если какой-то из билдов не был создан (android/windows), поскольку тут мы считаем, что все эти файлы есть.
- name: Create a GitHub release
if: ${{ inputs.create-release }}
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ""
custom_tag: ${{ steps.read-version.outputs.version-number }}
- if: ${{ inputs.create-release }}
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Flutter VK v${{ steps.tag_version.outputs.new_tag }}
prerelease: ${{ inputs.pre-release }}
bodyFile: CHANGELOG.md
artifacts: "build/*.*"
- name: Debug with SSH on fail
if: ${{ failure() && inputs.debug }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true