Skip to content

Commit

Permalink
ci: github action
Browse files Browse the repository at this point in the history
  • Loading branch information
see committed Sep 3, 2022
1 parent 3fd5055 commit 4fe1e7d
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 60 deletions.
60 changes: 0 additions & 60 deletions .github/workflows/release-android.yml

This file was deleted.

163 changes: 163 additions & 0 deletions .github/workflows/release_draft_github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Draft Github Release
on:
# Enable manual run
workflow_dispatch:
inputs:
version:
description: "Tag to create (e.g. v2.10.0). Must include 'v' and must match pubspec"
required: true
default: "v2.10.0"
type: string
prerelease:
description: "Prerelease"
required: false
default: false
type: boolean

# Declare default permissions as read only.
permissions: read-all

jobs:
draft-release:
name: Draft Github release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Draft release with release notes
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.FLUTTER_BOILERPLATE_BOT_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
prerelease: ${{ github.event.inputs.prerelease == 'true' }}

create-build:
name: Create ${{ matrix.target }} build
runs-on: ${{ matrix.os }}
strategy:
matrix:
target: [macOS, Windows, Linux, Android, Android_Appbundle]
include:
- os: macos-latest
target: macOS
build_target: macos
build_path: build/macos/Build/Products/Release
asset_extension: .zip
asset_content_type: application/zip
- os: windows-latest
target: Windows
build_target: windows
build_path: build\windows\runner\Release
asset_extension: .zip
asset_content_type: application/zip
- os: ubuntu-latest
target: Linux
build_target: linux
build_path: build/linux/x64/release/bundle
asset_extension: .tar.gz
asset_content_type: application/gzip
- os: ubuntu-latest
target: Android
build_target: apk
build_path: build/app/outputs/flutter-apk
asset_extension: .apk
asset_content_type: application/vnd.android.package-archive
- os: ubuntu-latest
target: Android_Appbundle
build_target: appbundle
build_path: build/app/outputs/bundle/release
asset_extension: .aab
asset_content_type: application/x-authorware-bin
# Disable fail-fast as we want results from all even if one fails.
fail-fast: false
needs: draft-release
steps:
# Set up Flutter.
- name: Clone Flutter repository with master channel
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Install Linux dependencies
if: matrix.target == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libx11-dev pkg-config cmake ninja-build libblkid-dev
- name: Install Android dependencies
if: matrix.target == 'Android' || matrix.target == 'Android_Appbundle'
uses: actions/setup-java@v3
with:
java-version: "17.x"
distribution: temurin
- name: Enable desktop support
if: matrix.target != 'Android' && matrix.target != 'Android_Appbundle'
run: |
flutter config --enable-linux-desktop
flutter config --enable-macos-desktop
flutter config --enable-windows-desktop
- run: flutter doctor -v
# Checkout code, recreate missing files, and get packages.
- name: Checkout code
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- run: flutter pub get

- name: Configure Keystore for Android
if: matrix.target == 'Android' || matrix.target == 'Android_Appbundle'
run: |
echo "$PLAY_STORE_UPLOAD_KEY" | base64 --decode > app/upload-keystore.jks
echo "storeFile=upload-keystore.jks" >> key.properties
echo "keyAlias=$KEYSTORE_KEY_ALIAS" >> key.properties
echo "storePassword=$KEYSTORE_STORE_PASSWORD" >> key.properties
echo "keyPassword=$KEYSTORE_KEY_PASSWORD" >> key.properties
env:
PLAY_STORE_UPLOAD_KEY: ${{ secrets.PLAY_STORE_UPLOAD_KEY }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
working-directory: android

# Build the application.
- run: flutter build -v ${{ matrix.build_target }} --release --no-tree-shake-icons

# Package the build.
- name: Copy VC redistributables to release directory for Windows
if: matrix.target == 'Windows'
run: |
Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\msvcp140.dll') .
Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140.dll') .
Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140_1.dll') .
working-directory: ${{ matrix.build_path }}
- name: Rename build for Android
if: matrix.target == 'Android'
run: mv app-release.apk $GITHUB_WORKSPACE/flutter_boilerplate_${{ matrix.target }}.apk
working-directory: ${{ matrix.build_path }}
- name: Rename build for Android Appbundle
if: matrix.target == 'Android_Appbundle'
run: mv app-release.aab $GITHUB_WORKSPACE/flutter_boilerplate_${{ matrix.target }}.aab
working-directory: ${{ matrix.build_path }}
- name: Compress build for Linux
if: matrix.target == 'Linux'
run: tar czf $GITHUB_WORKSPACE/flutter_boilerplate_${{ matrix.target }}.tar.gz *
working-directory: ${{ matrix.build_path }}
- name: Compress build for macOS
if: matrix.target == 'macOS'
run: ditto -c -k --sequesterRsrc --keepParent flutter_template_ns.app $GITHUB_WORKSPACE/flutter_boilerplate_${{ matrix.target }}.zip
working-directory: ${{ matrix.build_path }}
- name: Compress build for Windows
if: matrix.target == 'Windows'
run: compress-archive -Path * -DestinationPath ${env:GITHUB_WORKSPACE}\flutter_boilerplate_${{ matrix.target }}.zip
working-directory: ${{ matrix.build_path }}

- name: Add packaged build to release draft
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.FLUTTER_BOILERPLATE_BOT_TOKEN }}
with:
upload_url: ${{ needs.draft-release.outputs.upload_url }}
asset_path: ./flutter_boilerplate_${{ matrix.target }}${{ matrix.asset_extension }}
asset_name: flutter_boilerplate_${{ matrix.target }}${{ matrix.asset_extension }}
asset_content_type: ${{ matrix.asset_content_type }}

0 comments on commit 4fe1e7d

Please sign in to comment.