mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 12:42:34 +00:00
156 lines
5.0 KiB
YAML
156 lines
5.0 KiB
YAML
name: Prepare
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
flavor:
|
|
type: string
|
|
required: true
|
|
|
|
outputs:
|
|
build-flavor:
|
|
description: "Build Flavor"
|
|
value: ${{ jobs.build-details.outputs.build-flavor }}
|
|
build-motd:
|
|
description: "Build MOTD"
|
|
value: ${{ jobs.build-details.outputs.build-motd }}
|
|
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 }}
|
|
|
|
secrets:
|
|
FIREBASE_TOKEN:
|
|
required: true
|
|
SENTRY_DSN:
|
|
required: true
|
|
|
|
jobs:
|
|
build-details:
|
|
name: Build Details
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
build-motd: ${{ steps.build-motd.outputs.result }}
|
|
build-flavor: ${{ steps.build-flavor.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@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Count Commits
|
|
id: commit-count
|
|
run: |
|
|
COUNT=`git rev-list HEAD --count`
|
|
echo "commit-count=$COUNT" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build Flavor
|
|
id: build-flavor
|
|
uses: actions/github-script@v6
|
|
env:
|
|
FLAVOR: ${{ inputs.flavor }}
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
const flavor = process.env.FLAVOR;
|
|
if (flavor) switch (flavor) {
|
|
case 'edge':
|
|
case 'beta':
|
|
case 'stable':
|
|
return flavor;
|
|
}
|
|
return 'edge';
|
|
|
|
- name: Build MOTD
|
|
id: build-motd
|
|
uses: actions/github-script@v6
|
|
env:
|
|
FLAVOR: ${{ steps.build-flavor.outputs.result }}
|
|
with:
|
|
result-encoding: string
|
|
script: return `Thank you for testing ${process.env.FLAVOR} release builds! All changes can be found within the application.`;
|
|
|
|
- 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@main
|
|
|
|
- name: Build Title
|
|
id: build-title
|
|
run: |
|
|
HASH=`git rev-parse --short ${{ github.sha }}`
|
|
TITLE="v${{ steps.build-version.outputs.current-version }}-${{ steps.build-flavor.outputs.result }}-${{ steps.build-number.outputs.result }}-$HASH"
|
|
echo "output=$TITLE" >> $GITHUB_OUTPUT
|
|
|
|
- name: Log Build Details
|
|
env:
|
|
FLAVOR: ${{ steps.build-flavor.outputs.result }}
|
|
MOTD: ${{ steps.build-motd.outputs.result }}
|
|
NUMBER: ${{ steps.build-number.outputs.result }}
|
|
TITLE: ${{ steps.build-title.outputs.output }}
|
|
VERSION: ${{ steps.build-version.outputs.current-version }}
|
|
run: |
|
|
echo "Build MOTD: $MOTD"
|
|
echo "Build Flavor: $FLAVOR"
|
|
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=${{ needs.build-details.outputs.build-flavor }}
|
|
export COMMIT=${{ github.sha }}
|
|
export BUILD=${{ needs.build-details.outputs.build-number }}
|
|
export SENTRY_DSN=${{ secrets.SENTRY_DSN }}
|
|
flutter packages pub run environment_config:generate
|
|
|
|
- name: Generate Localization
|
|
run: dart ${{github.workspace }}/scripts/generate_localization.dart
|
|
|
|
- name: Generate Changelog
|
|
run: dart ${{github.workspace }}/scripts/generate_changelog.dart ${{ needs.build-details.outputs.build-flavor }}
|
|
|
|
- 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/changelog.json
|
|
${{ github.workspace }}/assets/localization
|
|
${{ github.workspace }}/lib/**/*.g.dart
|
|
${{ github.workspace }}/lib/system/environment.dart
|