Files
lunasea/.github/workflows/prepare.yml
2022-04-03 16:09:40 -04:00

131 lines
3.7 KiB
YAML

name: Prepare
on:
workflow_call:
inputs:
flavor:
type: string
required: true
outputs:
build-number:
description: "Build Number"
value: ${{ jobs.build-number.outputs.build-number }}
build-title:
description: "Build Title"
value: ${{ jobs.build-title.outputs.build-title }}
build-version:
description: "Build Version"
value: ${{ jobs.build-version.outputs.build-version }}
secrets:
FIREBASE_TOKEN:
required: true
jobs:
build-number:
name: Build Number
runs-on: ubuntu-latest
outputs:
build-number: ${{ steps.output.outputs.build-number }}
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: Run Script
id: script
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: Set Output
id: output
run: |
echo ${{ steps.script.outputs.result }}
echo "::set-output name=build-number::${{ steps.script.outputs.result }}"
build-version:
name: Build Version
runs-on: ubuntu-latest
outputs:
build-version: ${{ steps.output.outputs.build-version }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Get Version
id: version
uses: martinbeentjes/npm-get-version-action@v1.1.0
- name: Set Output
id: output
run: |
echo ${{ steps.version.outputs.current-version }}
echo "::set-output name=build-version::${{ steps.version.outputs.current-version }}"
build-title:
name: Build Title
needs: [ build-number, build-version ]
runs-on: ubuntu-latest
outputs:
build-title: ${{ steps.output.outputs.build-title }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Determine Short Hash
id: hash
run: |
HASH=`git rev-parse --short ${{ github.sha }}`
echo "::set-output name=hash::$HASH"
- name: Set Output
id: output
run: |
TITLE="v${{ needs.build-version.outputs.build-version }}-${{ inputs.flavor }}-${{ needs.build-number.outputs.build-number }}-${{ steps.hash.outputs.hash }}"
echo $TITLE
echo "::set-output name=build-title::$TITLE"
generate-files:
name: Generate Files
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 Flavor Configuration
run: echo $'FLAVOR=${{ inputs.flavor }}\nCOMMIT=${{ github.sha }}' > .flavor
- name: Generate Localization
run: dart ./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 }}/.flavor
${{ github.workspace }}/assets/localization
${{ github.workspace }}/lib/**/*.g.dart