mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 04:32:32 +00:00
264 lines
8.8 KiB
YAML
264 lines
8.8 KiB
YAML
name: Prepare
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
flavor:
|
|
type: string
|
|
required: true
|
|
|
|
outputs:
|
|
build-changelog:
|
|
description: "Build Changelog"
|
|
value: ${{ jobs.build-details.outputs.build-changelog }}
|
|
build-number:
|
|
description: "Build Number"
|
|
value: ${{ jobs.build-details.outputs.build-number }}
|
|
build-title:
|
|
description: "Build Title"
|
|
value: ${{ jobs.build-details.outputs.build-title }}
|
|
build-version:
|
|
description: "Build Version"
|
|
value: ${{ jobs.build-details.outputs.build-version }}
|
|
enable-android:
|
|
description: "Is Android Enabled?"
|
|
value: ${{ jobs.platform-list.outputs.android }}
|
|
enable-ios:
|
|
description: "Is iOS Enabled?"
|
|
value: ${{ jobs.platform-list.outputs.ios }}
|
|
enable-linux:
|
|
description: "Is Linux Enabled?"
|
|
value: ${{ jobs.platform-list.outputs.linux }}
|
|
enable-macos:
|
|
description: "Is macOS Enabled?"
|
|
value: ${{ jobs.platform-list.outputs.macos }}
|
|
enable-windows:
|
|
description: "Is Windows Enabled?"
|
|
value: ${{ jobs.platform-list.outputs.windows }}
|
|
enable-web:
|
|
description: "Is Web Enabled?"
|
|
value: ${{ jobs.platform-list.outputs.web }}
|
|
|
|
secrets:
|
|
FIREBASE_TOKEN:
|
|
required: true
|
|
|
|
jobs:
|
|
platform-list:
|
|
name: Platform List
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
android: ${{ steps.android.outputs.result }}
|
|
ios: ${{ steps.ios.outputs.result }}
|
|
linux: ${{ steps.linux.outputs.result }}
|
|
macos: ${{ steps.macos.outputs.result }}
|
|
windows: ${{ steps.windows.outputs.result }}
|
|
web: ${{ steps.web.outputs.result }}
|
|
steps:
|
|
- name: Check Message for Any Keywords
|
|
id: exists
|
|
uses: actions/github-script@v6
|
|
env:
|
|
MESSAGE: ${{ github.event.head_commit.message || '' }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
return process.env.MESSAGE.includes("platform:");
|
|
|
|
- name: Android
|
|
id: android
|
|
uses: actions/github-script@v6
|
|
env:
|
|
EXISTS: ${{ steps.exists.outputs.result }}
|
|
MESSAGE: ${{ github.event.head_commit.message || '' }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
if (process.env.EXISTS === "false") return true;
|
|
return process.env.MESSAGE.includes("platform:android");
|
|
|
|
- name: iOS
|
|
id: ios
|
|
uses: actions/github-script@v6
|
|
env:
|
|
EXISTS: ${{ steps.exists.outputs.result }}
|
|
MESSAGE: ${{ github.event.head_commit.message || '' }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
if (process.env.EXISTS === "false") return true;
|
|
return process.env.MESSAGE.includes("platform:ios");
|
|
|
|
- name: Linux
|
|
id: linux
|
|
uses: actions/github-script@v6
|
|
env:
|
|
EXISTS: ${{ steps.exists.outputs.result }}
|
|
MESSAGE: ${{ github.event.head_commit.message || '' }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
if (process.env.EXISTS === "false") return true;
|
|
return process.env.MESSAGE.includes("platform:linux");
|
|
|
|
- name: macOS
|
|
id: macos
|
|
uses: actions/github-script@v6
|
|
env:
|
|
EXISTS: ${{ steps.exists.outputs.result }}
|
|
MESSAGE: ${{ github.event.head_commit.message || '' }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
if (process.env.EXISTS === "false") return true;
|
|
return process.env.MESSAGE.includes("platform:macos");
|
|
|
|
- name: Web
|
|
id: web
|
|
uses: actions/github-script@v6
|
|
env:
|
|
EXISTS: ${{ steps.exists.outputs.result }}
|
|
MESSAGE: ${{ github.event.head_commit.message || '' }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
if (process.env.EXISTS === "false") return true;
|
|
return process.env.MESSAGE.includes("platform:web");
|
|
|
|
- name: Windows
|
|
id: windows
|
|
uses: actions/github-script@v6
|
|
env:
|
|
EXISTS: ${{ steps.exists.outputs.result }}
|
|
MESSAGE: ${{ github.event.head_commit.message || '' }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
if (process.env.EXISTS === "false") return true;
|
|
return process.env.MESSAGE.includes("platform:windows");
|
|
|
|
- name: Log Platform List
|
|
env:
|
|
android: ${{ steps.android.outputs.result }}
|
|
ios: ${{ steps.ios.outputs.result }}
|
|
linux: ${{ steps.linux.outputs.result }}
|
|
macos: ${{ steps.macos.outputs.result }}
|
|
windows: ${{ steps.windows.outputs.result }}
|
|
web: ${{ steps.web.outputs.result }}
|
|
run: |
|
|
echo "Android: $android"
|
|
echo "iOS: $ios"
|
|
echo "Linux: $linux"
|
|
echo "macOS: $macos"
|
|
echo "Web: $web"
|
|
echo "Windows: $windows"
|
|
|
|
build-details:
|
|
name: Build Details
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
build-changelog: ${{ steps.build-changelog.outputs.result }}
|
|
build-number: ${{ steps.build-number.outputs.result }}
|
|
build-title: ${{ steps.build-title.outputs.output }}
|
|
build-version: ${{ steps.build-version.outputs.current-version }}
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Count Commits
|
|
id: commit-count
|
|
run: |
|
|
COUNT=`git rev-list HEAD --count`
|
|
echo "::set-output name=commit-count::$COUNT"
|
|
|
|
- name: Latest Commit Message
|
|
id: commit-message
|
|
run: |
|
|
MESSAGE=`git show -s --format=%s`
|
|
echo "::set-output name=commit-message::$MESSAGE"
|
|
|
|
- name: Build Changelog
|
|
id: build-changelog
|
|
uses: actions/github-script@v6
|
|
env:
|
|
FLAVOR: ${{ inputs.flavor }}
|
|
MESSAGE: ${{ steps.commit-message.outputs.commit-message }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
const defaultMessage = 'Thank you for testing pre-release builds of LunaSea! Please consider joining the Discord to give feedback to the developer.\n\nChanges can be found on GitHub or by going to settings/system!';
|
|
const isEdge = process.env.FLAVOR === 'edge';
|
|
if (isEdge) return process.env.MESSAGE ?? defaultMessage;
|
|
return defaultMessage;
|
|
|
|
- name: Build Number
|
|
id: build-number
|
|
uses: actions/github-script@v6
|
|
env:
|
|
COUNT: ${{ steps.commit-count.outputs.commit-count }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
const count = process.env.COUNT || "0";
|
|
const base = 1000000000;
|
|
return base + Number(count);
|
|
|
|
- name: Build Version
|
|
id: build-version
|
|
uses: martinbeentjes/npm-get-version-action@v1.1.0
|
|
|
|
- name: Build Title
|
|
id: build-title
|
|
run: |
|
|
HASH=`git rev-parse --short ${{ github.sha }}`
|
|
TITLE="v${{ steps.build-version.outputs.current-version }}-${{ inputs.flavor }}-${{ steps.build-number.outputs.result }}-$HASH"
|
|
echo "::set-output name=output::$TITLE"
|
|
|
|
- name: Log Build Details
|
|
env:
|
|
changelog: ${{ steps.build-changelog.outputs.result }}
|
|
number: ${{ steps.build-number.outputs.result }}
|
|
title: ${{ steps.build-title.outputs.output }}
|
|
version: ${{ steps.build-version.outputs.current-version }}
|
|
run: |
|
|
echo "Build Changelog: $changelog"
|
|
echo "Build Number: $number"
|
|
echo "Build Title: $title"
|
|
echo "Build Version: $version"
|
|
|
|
generate-files:
|
|
name: Generate Files
|
|
needs: build-details
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Setup Environment
|
|
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master
|
|
with:
|
|
firebase-token: ${{ secrets.FIREBASE_TOKEN }}
|
|
platform: test
|
|
skip-core: true
|
|
|
|
- name: Generate Environment Configuration
|
|
run: |
|
|
export FLAVOR=${{ inputs.flavor }}
|
|
export COMMIT=${{ github.sha }}
|
|
export BUILD=${{ needs.build-details.outputs.build-number }}
|
|
flutter packages pub run environment_config:generate
|
|
|
|
- name: Generate Localization
|
|
run: dart ${{github.workspace }}/scripts/generate_localization.dart
|
|
|
|
- name: Generate Build Runner Files
|
|
run: flutter packages pub run build_runner build
|
|
|
|
- name: Upload Core Files
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: core-files
|
|
path: |
|
|
${{ github.workspace }}/assets/localization
|
|
${{ github.workspace }}/lib/**/*.g.dart
|
|
${{ github.workspace }}/lib/system/environment.dart
|