This repository has been archived by the owner on Jun 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
97 lines (88 loc) · 3.21 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: "Build Flipper Application Package"
author: "Oleksii Kutuzov"
description: "Github Action that builds your fap with ufbt"
branding:
icon: "cpu"
color: "orange"
inputs:
path:
description: "Path to fap source code (if not in the root of repository)"
required: false
default: ""
lint_only:
description: "Whether you want to only lint your source code"
required: false
default: "false"
channel:
description: "SDK channel to use"
required: false
default: "dev"
runs:
using: "composite"
steps:
- name: Set fap source path
shell: bash
run: >
if [ -z ${{ inputs.path }} ]; then
echo "FAP_PATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
else
echo "FAP_PATH=$GITHUB_WORKSPACE/${{ inputs.path }}" >> $GITHUB_ENV
fi
- name: Get ufbt
shell: bash
run: >
git clone --depth 1 --branch dev https://github.com/flipperdevices/flipperzero-ufbt ${{ runner.temp }}/flipperzero-ufbt;
echo "${{ runner.temp }}/flipperzero-ufbt" >> $GITHUB_PATH
- name: Set channel
shell: bash
run: >
if [ ${{ inputs.channel }} = 'dev' ]; then
echo "CHANNEL=0" >> $GITHUB_ENV
elif [ ${{ inputs.channel }} = 'rc' ]; then
echo "CHANNEL=1" >> $GITHUB_ENV
elif [ ${{ inputs.channel }} = 'release' ]; then
echo "CHANNEL=2" >> $GITHUB_ENV
else
echo "::error::channel: Bad input!"; exit 1
fi
- name: Get commit id
shell: bash
run: >
curl -o directory.json https://update.flipperzero.one/firmware/directory.json;
echo "COMMIT_ID=$(jq -r '.channels[0].versions[0].version' directory.json)" >> $GITHUB_ENV
- name: Cache toolchain
id: cache-fbt
uses: actions/cache@v3
env:
cache-name: cache-ufbt
with:
path: ${{ runner.temp }}/flipperzero-ufbt/.ufbt/
key: ${{ runner.os }}-${{ env.cache-name }}-${{ inputs.channel }}-${{ env.COMMIT_ID }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ inputs.channel }}-${{ env.COMMIT_ID }}
- if: ${{ steps.cache-fbt.outputs.cache-hit != 'true' }}
name: Update ufbt if cache not found
shell: bash
run: ufbt update --channel=${{ inputs.channel }}
- name: Download problem_matcher.json
shell: bash
run: curl -o problem_matcher.json https://raw.githubusercontent.com/oleksiikutuzov/flipperzero-ufbt-action/main/problem_matcher.json
- name: Execute ufbt
shell: bash
run: >
if [ ${{ inputs.lint_only }} = 'false' ]; then
echo "::add-matcher::$GITHUB_WORKSPACE/problem_matcher.json";
cd ${{ env.FAP_PATH }}; ufbt;
echo "ARTIFACT=$(basename ${{ env.FAP_PATH }}/dist/*.fap)" >> $GITHUB_ENV;
elif [ ${{ inputs.lint_only }} = 'true' ]; then
echo "::add-matcher::$GITHUB_WORKSPACE/problem_matcher.json";
cd ${{ env.FAP_PATH }}; ufbt lint
else
echo "::error::lint_only: Bad input!"; exit 1
fi
- if: ${{ inputs.lint_only == 'false' }}
name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.FAP_PATH }}/dist/${{ env.ARTIFACT }}