Sfoglia il codice sorgente

Setup Default actions and misc.

Alex4386 1 anno fa
parent
commit
65bfe6e1e8

+ 25 - 0
.github/scripts/change_ver.sh

@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Check if $TAG_NAME is set
+if [ -z "$TAG_NAME" ]; then
+    echo "Error: \$TAG_NAME must be set"
+    exit 1
+fi
+
+# Extract the version from $TAG_NAME
+version="${TAG_NAME##v}"
+
+# Loop through all files in the current directory
+for file in *; do
+    # Check if the file is a regular file
+    if [ -f "$file" ]; then
+        # Make a temporary copy of the file
+        cp "$file" "$file.tmp"
+
+        # Perform the replacement
+        sed "s/fap_version=\"[0-9]*\.[0-9]*\"/fap_version=\"$version\"/" "$file.tmp" > "$file"
+
+        # Remove the temporary file
+        rm "$file.tmp"
+    fi
+done

+ 28 - 0
.github/scripts/renamer.sh

@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Check if $DIST_DIR and $FILE_SUFFIX are set
+if [ -z "$FILE_SUFFIX" ] || [ -z "$DIST_FILE" ]; then
+    echo "Error: \$DIST_DIR and \$FILE_SUFFIX must be set"
+    exit 1
+fi
+
+# $DIST_FILE
+DIST_FILE=$(echo "$DIST_FILE" | head -n 1)
+DIST_DIR=$(dirname "$DIST_FILE")
+
+# Loop through files in $DIST_DIR
+for file in "$DIST_DIR"/*; do
+    # Check if the item is a regular file
+    if [ -f "$file" ]; then
+        # Extract the filename and extension
+        filename=$(basename "$file")
+        extension="${filename##*.}"
+        name="${filename%.*}"
+
+        # Construct the new filename
+        new_filename="${name}-${FILE_SUFFIX}.${extension}"
+
+        # Rename the file
+        mv "$file" "$DIST_DIR/${new_filename}"
+    fi
+done

+ 17 - 0
.github/workflows/lint.yml

@@ -0,0 +1,17 @@
+name: Lint
+on:
+    - push
+    - pull_request
+
+jobs:
+    all:
+        runs-on: ubuntu-latest
+        name: Lint
+        steps:
+          - name: Checkout
+            uses: actions/checkout@v4
+          - name: Linting
+            uses: flipperdevices/flipperzero-ufbt-action@v0.1.3
+            with:
+                sdk-channel: release
+                task: lint

+ 41 - 0
.github/workflows/nightly.yml

@@ -0,0 +1,41 @@
+name: Nightly
+on:
+    push:
+        branches:
+            - main
+
+jobs:
+    all:
+        runs-on: ubuntu-latest
+        name: Nightly Build for ${{ matrix.name }}
+        strategy:
+            matrix:
+                include:
+                  - name: (Official) Release channel
+                    sdk-ident: official_release
+                    sdk-channel: release
+                  - name: (Unleashed) Release channel
+                    sdk-ident: unleashed_release
+                    sdk-index-url: https://up.unleashedflip.com/directory.json
+                    sdk-channel: release
+                  - name: (Official) Dev channel
+                    sdk-ident: official_dev
+                    sdk-channel: dev
+                  - name: (Unleashed) Development channel
+                    sdk-ident: unleashed_dev
+                    sdk-index-url: https://up.unleashedflip.com/directory.json
+                    sdk-channel: dev
+        steps:
+          - name: Checkout
+            uses: actions/checkout@v4
+          - name: Build for ${{ matrix.name }}
+            uses: flipperdevices/flipperzero-ufbt-action@v0.1.3
+            id: build-app
+            with:
+                sdk-channel: ${{ matrix.sdk-channel }}
+                sdk-index-url: ${{ matrix.sdk-index-url }}
+          - name: Upload app artifacts
+            uses: actions/upload-artifact@v3
+            with:
+                name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }} (${{ matrix.sdk-ident }})
+                path: ${{ steps.build-app.outputs.fap-artifacts }}

+ 56 - 0
.github/workflows/release.yml

@@ -0,0 +1,56 @@
+name: Build Release
+on:
+    release:
+        types: [created]
+
+jobs:
+    all:
+        runs-on: ubuntu-latest
+        name: Build Release for ${{ matrix.name }}
+        strategy:
+            matrix:
+                include:
+                  - name: (Official) Release channel
+                    sdk-ident: official_release
+                    sdk-channel: release
+                  - name: (Unleashed) Release channel
+                    sdk-ident: unleashed_release
+                    sdk-index-url: https://up.unleashedflip.com/directory.json
+                    sdk-channel: release
+                  - name: (Official) Dev channel
+                    sdk-ident: official_dev
+                    sdk-channel: dev
+                  - name: (Unleashed) Development channel
+                    sdk-ident: unleashed_dev
+                    sdk-index-url: https://up.unleashedflip.com/directory.json
+                    sdk-channel: dev
+        steps:
+          - name: Checkout
+            uses: actions/checkout@v4
+          - name: Change Version to ${{ github.event.release.tag_name }}
+            run: |
+                chmod +x ./.github/scripts/change_ver.sh
+                ./.github/scripts/change_ver.sh
+            env:
+                TAG_NAME: ${{ github.event.release.tag_name }}
+          - name: Build for ${{ matrix.name }}
+            uses: flipperdevices/flipperzero-ufbt-action@v0.1.3
+            id: build-app
+            with:
+                sdk-channel: ${{ matrix.sdk-channel }}
+                sdk-index-url: ${{ matrix.sdk-index-url }}
+          - name: Rename Built files for ${{ matrix.name }}
+            run: |
+                chmod +x ./.github/scripts/renamer.sh
+                ./.github/scripts/renamer.sh
+            env:
+                FILE_SUFFIX: ${{ matrix.sdk-ident }}
+                DIST_FILE: ${{ steps.build-app.outputs.fap-artifacts }}
+          - name: Upload packages to release
+            uses: svenstaro/upload-release-action@v2
+            with:
+                repo_token: ${{ secrets.GITHUB_TOKEN }}
+                file: ./dist/*
+                tag: ${{ github.ref }}
+                overwrite: true
+                file_glob: true

+ 46 - 0
README.md

@@ -0,0 +1,46 @@
+<h1 align="center">Flipper Zero: Application Template</h1>
+
+## How to use this template
+1. Setup the repository by clicking the `Use this template` button on the top of the repository. Fill in the data if needed.
+2. Update `README.md`'s upstream url with your repository's url.
+3. Add `LICENSE` file with your own license.
+4. Update `application.fam` with your application's information.
+
+## Build Status
+<!-- Replace the https://github.com/Alex4386/f0-template to your own repo after using template! -->
+* **Latest Release**: [Download](https://github.com/Alex4386/f0-template/releases/latest)
+* **Latest Nightly**: [Download](https://github.com/Alex4386/f0-template/actions/workflows/nightly.yml) _(GitHub Login Required)_
+
+| Nightly Build | Release Build |
+|:-------------:|:-------------:|
+| ![Nightly Build](https://github.com/Alex4386/f0-template/actions/workflows/nightly.yml/badge.svg) | ![Release Build](https://github.com/Alex4386/f0-template/actions/workflows/release.yml/badge.svg) |
+
+## Build Instruction
+1. Install `ufbt`:
+    ```bash
+    pip3 install ufbt
+    ```
+2. Clone this repository and enter the repository root.
+3. Run `ufbt update` to update the SDK for your flipper
+    - If you are using custom firmware, You should switch SDK. Here is the example for `unleashed` firmware:
+        ```bash
+        ufbt update --url=https://up.unleashedflip.com/directory.json
+        ```
+    - If you want to use different release channel, You can run update to that channel too. Here is the example for `dev` channel (`dev`, `rc`, `release` are supported):
+        ```bash
+        ufbt update --channel=dev
+        ```
+4. Run `ufbt` in the repository root:
+    ```bash
+    ufbt
+    ```
+5. Compiled binary is now available at `./dist/` directory.
+
+## Setup Visual Studio Code
+> [!WARNING]
+> This command will overwrite your `.vscode` directory and `.gitignore` on your root directory. 
+> **Make sure to backup your changes before running this command.**
+
+1. Suppose your build environment is ready.
+2. Run `ufbt vscode_dist` to generate Visual Studio Code config.
+