diff --git a/.github/workflow_data/commit.sh b/.github/workflow_data/commit.sh deleted file mode 100644 index ddfe7040fb..0000000000 --- a/.github/workflow_data/commit.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -export VERSION_TAG="$(python -c 'import fbt_options; print(fbt_options.DIST_SUFFIX, end="")')" -echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV diff --git a/.github/workflow_data/package.sh b/.github/workflow_data/package.sh deleted file mode 100644 index 02fa15b481..0000000000 --- a/.github/workflow_data/package.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -export ARTIFACT_DIR="${VERSION_TAG}" - -export ARTIFACT_TGZ="${VERSION_TAG}.tgz" -export ARTIFACT_ZIP="${VERSION_TAG}.zip" -export ARTIFACT_SDK="${VERSION_TAG}-sdk.zip" -cd dist/${DEFAULT_TARGET}-* -mv ${DEFAULT_TARGET}-update-* ${ARTIFACT_DIR} -tar --format=ustar -czvf ../../${ARTIFACT_TGZ} ${ARTIFACT_DIR} -cd ${ARTIFACT_DIR} -7z a ../../../${ARTIFACT_ZIP} . -cd .. -mv flipper-z-${DEFAULT_TARGET}-sdk-*.zip ../../${ARTIFACT_SDK} -cd ../.. - -echo "ARTIFACT_TGZ=${ARTIFACT_TGZ}" >> $GITHUB_ENV -echo "ARTIFACT_ZIP=${ARTIFACT_ZIP}" >> $GITHUB_ENV -echo "ARTIFACT_SDK=${ARTIFACT_SDK}" >> $GITHUB_ENV diff --git a/.github/workflow_data/version.sh b/.github/workflow_data/version.sh deleted file mode 100644 index 2e98c4b049..0000000000 --- a/.github/workflow_data/version.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -export VERSION_TAG="$(python -c ''' -import datetime as dt -import json -import os -with open(os.environ["GITHUB_EVENT_PATH"], "r") as f: - event = json.load(f) -version = int(event["pull_request"]["title"].removeprefix("V").removesuffix(" Release") -date = dt.datetime.now().strftime("%d%m%Y") -print(f"MNTM-{version:03}_{date}", end="") -''')" -echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV diff --git a/.github/workflow_data/webupdater.py b/.github/workflow_data/webupdater.py deleted file mode 100644 index b30fc17fe3..0000000000 --- a/.github/workflow_data/webupdater.py +++ /dev/null @@ -1,36 +0,0 @@ -import nextcloud_client -import requests -import json -import os - -if __name__ == "__main__": - client = nextcloud_client.Client(os.environ["NC_HOST"]) - client.login(os.environ["NC_USER"], os.environ["NC_PASS"]) - - file = os.environ["ARTIFACT_TGZ"] - path = f"MNTM-Release/{file}" - try: - client.delete(path) - except Exception: - pass - client.put_file(path, file) - - file = file.removesuffix(".tgz") + ".md" - path = path.removesuffix(".tgz") + ".md" - try: - client.delete(path) - except Exception: - pass - client.put_file(path, file) - - version = os.environ['VERSION_TAG'].split("_")[0] - files = ( - os.environ['ARTIFACT_TGZ'], - os.environ['ARTIFACT_TGZ'].removesuffix(".tgz") + ".md" - ) - for file in client.list("MNTM-Release"): - if file.name.startswith(version) and file.name not in files: - try: - client.delete(file.path) - except Exception: - pass diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d054252155..42bb8a8e21 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,11 @@ -name: 'Build' +name: "Build" on: push: branches: - dev - - main tags: - - '*' + - "*" pull_request: concurrency: @@ -14,45 +13,87 @@ concurrency: cancel-in-progress: true env: - TARGETS: f7 DEFAULT_TARGET: f7 FBT_GIT_SUBMODULE_SHALLOW: 1 jobs: - build: + main: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: [f7] steps: - - - name: 'Checkout code' + - name: "Checkout code" uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 1 ref: ${{ github.event.pull_request.head.sha }} - - name: "Read version tag" - run: bash .github/workflow_data/commit.sh + - name: "Get commit details" + id: names + run: | + BUILD_TYPE='DEBUG=0 COMPACT=1' + if [[ ${{ github.event_name }} == 'pull_request' ]]; then + TYPE="pull" + elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then + TYPE="tag" + else + TYPE="other" + fi + python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE" || cat "${{ github.event_path }}" + echo "event_type=$TYPE" >> $GITHUB_OUTPUT + echo "FBT_BUILD_TYPE=$BUILD_TYPE" >> $GITHUB_ENV + echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV + echo "TARGET_HW=$(echo "${{ matrix.target }}" | sed 's/f//')" >> $GITHUB_ENV - - name: 'Build the firmware' + - name: "Check API versions for consistency between targets" run: | set -e - for TARGET in ${TARGETS}; do - TARGET_HW="$(echo "${TARGET}" | sed 's/f//')"; \ - ./fbt TARGET_HW=$TARGET_HW DIST_SUFFIX=$VERSION_TAG updater_package - done + N_API_HEADER_SIGNATURES=`ls -1 targets/f*/api_symbols.csv | xargs -I {} sh -c "head -n2 {} | md5sum" | sort -u | wc -l` + if [ $N_API_HEADER_SIGNATURES != 1 ] ; then + echo API versions aren\'t matching for available targets. Please update! + echo API versions are: + head -n2 targets/f*/api_symbols.csv + exit 1 + fi + + - name: "Build the firmware and apps" + id: build-fw + run: | + ./fbt TARGET_HW=$TARGET_HW $FBT_BUILD_TYPE updater_package + echo "firmware_api=$(./fbt TARGET_HW=$TARGET_HW get_apiversion)" >> $GITHUB_OUTPUT - name: "Check for uncommitted changes" run: | git diff --exit-code - - name: 'Dist artifact' + - name: "Upload artifacts to GitHub" uses: actions/upload-artifact@v3 with: - name: dist path: | - dist/${{ env.DEFAULT_TARGET }}-*/ + dist/${TARGET}-*/flipper-z-${TARGET}-update-* + dist/${TARGET}-*/flipper-z-${TARGET}-sdk-* - - name: "Make tgz, zip and sdk" - run: bash .github/workflow_data/package.sh + - name: "Copy build output" + run: | + set -e + rm -rf artifacts || true + mkdir artifacts + cp dist/${TARGET}-*/flipper-z-${TARGET}-{update,sdk}-* artifacts/ + cd dist/${TARGET}-*/${TARGET}-update-*/ + artifact="$basename "$(realpath .)")" + 7z a ../../../artifacts/flipper-z-${artifact}.zip . + + - name: "Upload artifacts to update server" + if: ${{ !github.event.pull_request.head.repo.fork }} + run: | + FILES=$(for ARTIFACT in $(find artifacts -maxdepth 1 -not -type d); do echo "-F files=@${ARTIFACT}"; done) + curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \ + -F "branch=${BRANCH_NAME}" \ + -F "version_token=${COMMIT_SHA}" \ + ${FILES[@]} \ + "${{ secrets.INDEXER_URL }}"/firmware/uploadfiles # - name: Send devbuild webhook # if: "github.event_name == 'push' && github.ref_name == 'dev' && !contains(github.event.head_commit.message, '--nobuild')" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index da9ca2a87c..f2aab96c89 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: 'Lint' +name: "Lint" on: push: @@ -6,7 +6,7 @@ on: - dev - main tags: - - '*' + - "*" pull_request: env: @@ -16,12 +16,11 @@ jobs: lint: runs-on: ubuntu-latest steps: - - - name: 'Checkout code' + - name: "Checkout code" uses: actions/checkout@v3 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - - name: 'Check code formatting' + - name: "Check code formatting" run: ./fbt lint lint_py diff --git a/.github/workflows/reindex.yml b/.github/workflows/reindex.yml new file mode 100644 index 0000000000..49e284d389 --- /dev/null +++ b/.github/workflows/reindex.yml @@ -0,0 +1,27 @@ +name: "Post-release hooks" + +on: + release: + types: [prereleased, released] + +jobs: + reindex: + name: "Post-release hooks" + runs-on: ubuntu-latest + steps: + - name: "Checkout code" + uses: actions/checkout@v4 + + - name: "Trigger reindex" + run: | + curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \ + "${{ secrets.INDEXER_URL }}"/firmware/reindex; + + # - name: "Send release notification" + # if: ${{ github.event.action == 'released' }} + # run: | + # echo '${{ secrets.FIREBASE_TOKEN }}' > firebase-token.json; + # python3 -m pip install firebase-admin==6.4.0; + # python3 scripts/send_firebase_notification.py \ + # "--version=${{ github.event.release.name }}" \ + # "--token=firebase-token.json"; diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1cfc54eb87..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: 'Release' - -on: - pull_request_review: - types: [submitted] - -env: - TARGETS: f7 - DEFAULT_TARGET: f7 - -jobs: - release: - if: | - github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && - endsWith(github.event.pull_request.title, ' Release') && - github.event.review.author_association == 'MEMBER' && - startsWith(github.event.pull_request.title, 'V') && - github.event.pull_request.base.ref == 'main' && - github.event.pull_request.head.ref == 'dev' && - github.event.pull_request.state == 'open' && - github.event.pull_request.draft == false && - github.event.review.state == 'APPROVED' - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - - name: 'Checkout code' - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - - name: "Read version tag" - run: bash .github/workflow_data/version.sh - - - name: 'Build the firmware' - run: | - set -e - for TARGET in ${TARGETS}; do - TARGET_HW="$(echo "${TARGET}" | sed 's/f//')"; \ - ./fbt TARGET_HW=$TARGET_HW DIST_SUFFIX=$VERSION_TAG updater_package - done - - - name: "Check for uncommitted changes" - run: | - git diff --exit-code - - - name: "Make tgz, zip and sdk" - run: bash .github/workflow_data/package.sh - - - name: "Update release notes" - run: python .github/workflow_data/release.py - - - name: "Upload to webupdater" - env: - NC_HOST: "https://cloud.cynthialabs.net/" - NC_USERAGENT: "${{ secrets.NC_USERAGENT }}" - NC_USER: "${{ secrets.NC_USER }}" - NC_PASS: "${{ secrets.NC_PASS }}" - run: | - python -m pip install pyncclient - python .github/workflow_data/webupdater.py - - - name: "Merge pull request" - uses: "pascalgn/automerge-action@v0.15.6" - env: - MERGE_LABELS: "" - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - - name: "Make release" - uses: softprops/action-gh-release@v1 - with: - body_path: ".github/workflow_data/release.md" - draft: false - prerelease: false - files: | - ${{ env.ARTIFACT_TGZ }} - ${{ env.ARTIFACT_ZIP }} - ${{ env.ARTIFACT_SDK }} - name: "${{ env.VERSION_TAG }}" - tag_name: "${{ env.VERSION_TAG }}" - target_commitish: ${{ github.event.pull_request.base.ref }} diff --git a/.github/workflows/sonarcloud.yaml b/.github/workflows/sonarcloud.yaml deleted file mode 100644 index 766a3487da..0000000000 --- a/.github/workflows/sonarcloud.yaml +++ /dev/null @@ -1,65 +0,0 @@ -name: 'SonarCloud' - -on: - workflow_dispatch: - # pull_request: - # types: [opened, synchronize, reopened] - -env: - TARGETS: f7 - DEFAULT_TARGET: f7 - -jobs: - sonarcloud: - runs-on: ubuntu-latest - env: - SONAR_SCANNER_VERSION: 4.7.0.2747 - SONAR_SERVER_URL: "https://sonarcloud.io" - BUILD_WRAPPER_OUT_DIR: "$HOME/.sonar/build_wrapper_output" # Directory where build-wrapper output will be placed - FBT_NO_SYNC: "true" - steps: - - - name: 'Checkout code' - uses: actions/checkout@v3 - with: - submodules: 'recursive' # FBT_NO_SYNC is on, get submodules now - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - ref: ${{ github.event.pull_request.head.sha }} - - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Download and set up sonar-scanner - env: - SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip - run: | - mkdir -p $HOME/.sonar - curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH - - - name: Download and set up build-wrapper - env: - BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip - run: | - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ - echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH - - - name: Run build-wrapper - run: | - mkdir ${{ env.BUILD_WRAPPER_OUT_DIR }} - set -e - for TARGET in ${TARGETS}; do - TARGET_HW="$(echo "${TARGET}" | sed 's/f//')"; \ - build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} ./sonar-build "./fbt TARGET_HW=$TARGET_HW updater_package" - done - - - name: Run sonar-scanner - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" diff --git a/.github/workflows/submodules.yml b/.github/workflows/submodules.yml deleted file mode 100644 index 52342fd04e..0000000000 --- a/.github/workflows/submodules.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: 'Submodules' - -on: - push: - branches: - - dev - - main - tags: - - '*' - pull_request: - -jobs: - submodules: - runs-on: ubuntu-latest - steps: - - - name: 'Checkout code' - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - - name: 'Check protobuf branch' - run: | - git submodule update --init - SUB_PATH="assets/protobuf"; - SUB_BRANCH="dev"; - SUB_COMMITS_MIN=40; - cd "$SUB_PATH"; - SUBMODULE_HASH="$(git rev-parse HEAD)"; - BRANCHES=$(git branch -r --contains "$SUBMODULE_HASH"); - COMMITS_IN_BRANCH="$(git rev-list --count dev)"; - if [ $COMMITS_IN_BRANCH -lt $SUB_COMMITS_MIN ]; then - echo "name=fails::error" >> $GITHUB_OUTPUT - echo "::error::Error: Too low commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)"; - exit 1; - fi - if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then - echo "name=fails::error" >> $GITHUB_OUTPUT - echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH"; - exit 1; - fi diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml index 1de0b1de2d..4ad738611f 100644 --- a/.github/workflows/webhook.yml +++ b/.github/workflows/webhook.yml @@ -1,4 +1,4 @@ -name: 'Webhook' +name: "Webhook" on: push: @@ -32,8 +32,7 @@ jobs: webhook: runs-on: ubuntu-latest steps: - - - name: 'Checkout code' + - name: "Checkout code" uses: actions/checkout@v3 - name: Send webhook diff --git a/applications/main/momentum_app/momentum_app.c b/applications/main/momentum_app/momentum_app.c index eb4e488ef6..94ee34ee70 100644 --- a/applications/main/momentum_app/momentum_app.c +++ b/applications/main/momentum_app/momentum_app.c @@ -309,15 +309,16 @@ MomentumApp* momentum_app_alloc() { app->dolphin_angry = stats.butthurt; furi_record_close(RECORD_DOLPHIN); - if(strcmp(version_get_version(NULL), "MNTM-DEV") == 0) { - app->version_tag = furi_string_alloc_printf("%s ", version_get_version(NULL)); + app->version_tag = furi_string_alloc_printf("%s ", version_get_version(NULL)); + if(furi_string_start_with(app->version_tag, "mntm-dev")) { + furi_string_set(app->version_tag, "MNTM-DEV "); const char* sha = version_get_githash(NULL); for(size_t i = 0; i < strlen(sha); ++i) { furi_string_push_back(app->version_tag, toupper(sha[i])); } } else { - app->version_tag = furi_string_alloc_printf( - "%s %s", version_get_version(NULL), version_get_builddate(NULL)); + furi_string_replace(app->version_tag, "mntm", "MNTM"); + furi_string_cat(app->version_tag, version_get_builddate(NULL)); } return app; diff --git a/fbt_options.py b/fbt_options.py index 2753844ecf..d6b50519c2 100644 --- a/fbt_options.py +++ b/fbt_options.py @@ -18,7 +18,7 @@ # Suffix to add to files when building distribution # If OS environment has DIST_SUFFIX set, it will be used instead -DIST_SUFFIX = f"MNTM-DEV_@{subprocess.check_output(['git', 'rev-parse', '--short=7', 'HEAD']).decode().strip().upper()}" +DIST_SUFFIX = f"mntm-dev-{subprocess.check_output(['git', 'rev-parse', '--short=7', 'HEAD']).decode().strip()}" # Coprocessor firmware COPRO_OB_DATA = "scripts/ob.data" diff --git a/scripts/version.py b/scripts/version.py index c017056142..84294acc0f 100755 --- a/scripts/version.py +++ b/scripts/version.py @@ -36,7 +36,7 @@ def get_version_info(self): ) version = ( - self.suffix.split("_")[0] + self.suffix or os.environ.get("DIST_SUFFIX", None) or "unknown" )