Skip to content

Dev

Dev #153

Workflow file for this run

name: Build Gagaku
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
workflow_dispatch:
inputs:
tagName:
description: 'Tag name'
type: string
default: ''
required: false
doRelease:
description: 'Publish new release'
type: boolean
default: false
required: false
jobs:
build:
if: github.event.pull_request.draft == false
strategy:
fail-fast: true
matrix:
builder: [windows, linux, android]
include:
- builder: windows
os: windows-latest
pkg: windows
- builder: linux
os: ubuntu-latest
pkg: linux
- builder: android
os: ubuntu-latest
pkg: apk
name: Build Gagaku
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Setup Java
if: matrix.builder == 'android'
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "main"
cache: true
- name: Set up Packages (Linux)
if: matrix.builder == 'linux'
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev
flutter config --enable-linux-desktop
- name: Set up Packages (Windows)
if: matrix.builder == 'windows'
run: flutter config --enable-windows-desktop
- run: flutter pub get
- run: dart run build_runner build --delete-conflicting-outputs
- name: Build Project
run: flutter build ${{ matrix.pkg }}
- name: Package Gagaku (Windows)
id: windows-pkg
if: matrix.builder == 'windows'
run: |
$RELEASE_PACKAGE_FILE = "gagaku-windows.zip"
Compress-Archive build/windows/x64/runner/Release/* $RELEASE_PACKAGE_FILE
$release_filepath = Get-ChildItem $RELEASE_PACKAGE_FILE | %{$_[0].FullName}
echo "artifact_slug=$release_filepath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Upload Build Artifact (Windows)
if: matrix.builder == 'windows'
uses: actions/upload-artifact@v4
with:
name: gagaku-windows
path: ${{ steps.windows-pkg.outputs.artifact_slug }}
if-no-files-found: error
retention-days: 1
- name: Upload Build Artifact (Android)
if: matrix.builder == 'android'
uses: actions/upload-artifact@v4
with:
name: gagaku-apk
path: build/app/outputs/flutter-apk/app-release.apk
if-no-files-found: error
retention-days: 1
publish_release:
name: Publish release
if: ${{ !cancelled() && github.event.inputs.doRelease == 'true' && github.event.inputs.tagName != '' && needs.build.result == 'success' }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
id: create_release
run: |
set -xe
shopt -s nullglob
RELDATE="$(date +'%Y-%m-%d %H:%M')"
NAME="${{ github.event.inputs.tagName }}"
TAGNAME="${{ github.event.inputs.tagName }}"
gh release create "$TAGNAME" --target "master" --title "$NAME" artifacts/**/*.{zip,tar.xz,.apk}
echo "tag_name=${TAGNAME}" >> $GITHUB_OUTPUT
echo "rel_date=${RELDATE}" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ github.token }}