Skip to content

Windows & Android release #82

Windows & Android release

Windows & Android release #82

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 Java and Flutter for Android
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
cache: gradle
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
- 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: |
flutter build apk --release
cp ./build/app/outputs/flutter-apk/app-release.apk "./build/Flutter VK Android.apk"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Flutter VK Android.apk
path: ./build/Flutter VK Android.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.12.0
with:
channel: "stable"
cache: true
- name: Get dependencies
run: flutter pub get
- name: Build Windows release
run: 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
run: |
$telegramToken = $env:TELEGRAM_TOKEN
$telegramTo = $env:TELEGRAM_TO
# Android
Invoke-RestMethod -Uri "https://api.telegram.org/bot$telegramToken/sendDocument" -Method Post -Form @{
chat_id = $telegramTo
caption = "<b>🚧 Новый билд для Android</b>.`n`n#Android"
parse_mode = 'HTML'
document = Get-Item -Path './build/Flutter VK Android.apk'
}
# Windows installer
Invoke-RestMethod -Uri "https://api.telegram.org/bot$telegramToken/sendDocument" -Method Post -Form @{
chat_id = $telegramTo
caption = "<b>🚧 Новый билд для Windows</b>.`n`n#Windows #installer"
parse_mode = 'HTML'
document = Get-Item -Path './build/Flutter VK installer.exe'
}
# Windows portable
Invoke-RestMethod -Uri "https://api.telegram.org/bot$telegramToken/sendDocument" -Method Post -Form @{
chat_id = $telegramTo
caption = "<b>🚧 Новый билд для Windows</b>.`n`n#Windows #portable"
parse_mode = 'HTML'
document = Get-Item -Path './build/Flutter VK portable.7z'
}
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }}
- name: Create 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 }}
- name: Create a GitHub release
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