From d1fab3fb189cec65c7282c4dbbf099959930af27 Mon Sep 17 00:00:00 2001 From: DerSkythe Date: Mon, 27 Mar 2023 16:11:32 +0400 Subject: [PATCH 1/3] feat: add recommended plugins Changes to be committed: new file: .vscode/extensions.json --- .vscode/extensions.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000000..884c6435595 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "github.vscode-github-actions" + ] +} \ No newline at end of file From 6b182f6fb4892e8d6881dc33a5ad5aa64439ba3a Mon Sep 17 00:00:00 2001 From: DerSkythe Date: Fri, 31 Mar 2023 07:20:40 +0400 Subject: [PATCH 2/3] Fixin invalid CI --- .github/actions/make-release/action.yml | 81 ++++++++++++ .github/check-version.ps1 | 141 +++++++++++++++++++++ .github/workflows/build-with-firmwware.yml | 28 +++- .github/workflows/version-check.yml | 138 +++----------------- .vscode/settings.json | 8 ++ 5 files changed, 275 insertions(+), 121 deletions(-) create mode 100644 .github/actions/make-release/action.yml create mode 100644 .github/check-version.ps1 create mode 100644 .vscode/settings.json diff --git a/.github/actions/make-release/action.yml b/.github/actions/make-release/action.yml new file mode 100644 index 00000000000..61a51952b98 --- /dev/null +++ b/.github/actions/make-release/action.yml @@ -0,0 +1,81 @@ +--- +name: "Action release" +description: "Steps to build release" +author: "DerSkythe" + +inputs: + release_type: + description: 'release_type' + required: true + release_version: + description: 'release_version' + required: true + firmware_version: + description: 'firmware_version' + required: true + repo_self: + description: 'REPO_SELF' + required: true + gh_token: + description: 'github_gh_token' + required: true + owner: + description: 'owner' + required: true + current_tag: + description: 'current_tag' + required: true + remote_tag_info: + description: 'remote_tag_info' + required: true + +# outputs: +# make-minor-release: +# description: "make-minor-release" +# value: ${{ steps.make-minor-release.outputs }} +# make-major-release: +# description: "make-minor-release" +# value: ${{ steps.make-major-release.outputs }} + +runs: + using: "composite" + steps: + - name: Minor release + if: ${{ inputs.release_type == 2 }} + id: make-minor-release + uses: softprops/action-gh-release@v1 + with: + tag_name: 'v${{ inputs.release_version }}' + name: 'Minor update v${{ inputs.release_version }}' + token: ${{ inputs.gh_token }} + draft: true + generate_release_notes: true + #target_commitish: ${{ github.SHA }} + append_body: true + body: 'Rebuild with new version of firmware.\n\nSee: [CHANGELOG](${{ inputs.firmware_version }}/blob/dev/CHANGELOG.md)\n${{ inputs.remote_tag_info }}' + repository: '${{ inputs.repo_self }}' + + - name: Major release + if: ${{ inputs.release_type == 1 }} + id: make-major-release + uses: softprops/action-gh-release@v1 + with: + tag_name: 'v${{ inputs.release_version }}' + name: Release v${{ inputs.release_version }} + token: ${{ inputs.gh_token }} + draft: true + generate_release_notes: true + #target_commitish: ${{ github.SHA }} + append_body: true + body: 'New version is rolling out!' + repository: '${{ inputs.repo_self }}' + + - name: Update Firmware variable and create UPDATE release if necessary + if: ${{ success() }} + env: + GITHUB_TOKEN: ${{ inputs.gh_token }} + OWNER: ${{ inputs.owner }} + shell: bash + run: | + gh variable set FIRMWARE_VERSION -b '${{ inputs.firmware_version }}' -R '${{ inputs.repo_self }}' + gh variable set RELEASE_VERSION -b '${{ inputs.release_version }}' -R '${{ inputs.repo_self }}' diff --git a/.github/check-version.ps1 b/.github/check-version.ps1 new file mode 100644 index 00000000000..add49b387f0 --- /dev/null +++ b/.github/check-version.ps1 @@ -0,0 +1,141 @@ +######################################## +Set-StrictMode -Version 3.0 # +$ErrorActionPreference = "Stop" # +######################################## + +[string]$FirmwareVersion = $args[0] +[string]$ReleaseVersion = $args[1] +[string]$RepoSelf = $args[2] +[string]$RepoUnleashed = $args[3] +[bool]$ForGithubActions = $true + +################################################################################################################################ +function CleanInput +{ + param( + [string] + $DurtyString + ) + return $DurtyString -replace ('[^a-zA-Z\d_\-\,\.\t\n\r\:\;]', '') +} + +################################################################################################################################ + +$Output = @{ + RELEASE_VERSION = $ReleaseVersion + CURRENT_TAG = $FirmwareVersion + REMOTE_TAG_INFO = $FirmwareVersion + RELEASE_TYPE = 0 +} + +$Release = @(` + (CleanInput ` + (gh release list -L 1 --repo $RepoUnleashed)` + ) -split "`t") + +$FirmwareVersionNumber = 0 +$StoredFirmwareVersionNumber = 0 +$LatestFirmware = $Release[2] +if ($Release[2] -match '\-(\d+)$') +{ + $FirmwareVersionNumber = [int]($Matches[1]) +} +else +{ + Write-Error ('::error title=Invalid firmware number::Error during execution this tags {0}' -f $FirmwareVersionNumber) + exit 1 +} +if ($FirmwareVersion -match '\-(\d+)$') +{ + $StoredFirmwareVersionNumber = [int]($Matches[1]) +} +else +{ + Write-Error ('::error title=Invalid STORED firmware number::Error during execution this version {0}' -f $FirmwareVersion) + exit 1 +} +$Delta = ( [DateTime]::Now - [DateTime]::Parse($Release[3])) +Write-Host "FirmwareVersionNumber: $FirmwareVersionNumber, Delta: $Delta" +#exit 0 + +$NewVersionFw = $false +Write-Host ('Latest firmware {0}' -f $FirmwareVersionNumber) + +$Output.REMOTE_TAG_INFO = Write-Host ('[{0}]({1}/releases/tag/{2})' ` + -f $LatestFirmware, $RepoUnleashed, $LatestFirmware) +if (($FirmwareVersionNumber -gt $StoredFirmwareVersionNumber) -and ( $Delta -gt [TimeSpan]::FromMinutes(10))) +{ + $Output.REMOTE_TAG_INFO = $LatestFirmware + $NewVersionFw = $true +} +elseif ($FirmwareVersionNumber -lt $StoredFirmwareVersionNumber) +{ + Write-Error ('::error title=Invalid check of stored::Version in repo: {0}, but we think it is {1}' ` + -f $FirmwareVersionNumber, $StoredFirmwareVersionNumber) + exit 1 +} + +$PublishDates = (gh api -H "Accept: application/vnd.github+json" ` + -H "X-GitHub-Api-Version: 2022-11-28" "/repos/$( $RepoSelf )/releases?per_page=1" ` + | ConvertFrom-Json | Select-Object published_at, created_at) +$LastPublished = ($null -eq $PublishDates.published_at ? $PublishDates.created_at : $PublishDates.published_at) +$Delta = ([DateTime]::Now - $LastPublished) + +$Release = (gh api -H "Accept: application/vnd.github+json" ` + -H "X-GitHub-Api-Version: 2022-11-28" "/repos/$( $RepoSelf )/tags?per_page=1" ` + | ConvertFrom-Json).name +Write-Host ('Release {0}' -f $Release) -ForegroundColor Gray -BackgroundColor Blue +$LatestTag = $Release.Substring(1) + +$CurrentVersion = [version]::Parse($ReleaseVersion) +$ParsedRepoVersion = [version]::Parse($LatestTag) + +Write-Host ('Current tag:Repos tag {0}, {1}' -f $CurrentVersion, $ParsedRepoVersion) ` + -ForegroundColor Gray -BackgroundColor Blue +Write-Debug ('::debug Current tag:Repos tag {0}, {1}' -f $CurrentVersion, $ParsedRepoVersion) + +if (($CurrentVersion -lt $ParsedRepoVersion) -and ( $Delta -gt [TimeSpan]::FromMinutes(10))) +{ + $Tag = ('{0}.{1}.{2}' -f $ParsedRepoVersion.Major, $ParsedRepoVersion.Minor, $ParsedRepoVersion.Build) + + $Output.RELEASE_VERSION = $Tag + $Output.RELEASE_TYPE = 2 + + Write-Host ('::warning title=New release!::Release {0}' -f $Tag) +} +elseif ( $NewVersionFw ) +{ + $Tag = ('{0}.{1}.{2}' -f $CurrentVersion.Major, $CurrentVersion.Minor, ($CurrentVersion.Build + 1)) + + $Output.RELEASE_VERSION = $Tag + $Output.RELEASE_TYPE = 1 + + Write-Host ('::warning title=Firmware was changed!::New version is {0}, need to create release {1}' -f $LatestFirmware, $Tag) +} +elseif ( ($Delta -gt [TimeSpan]::FromMinutes(10)) -and ($CurrentVersion -gt $ParsedRepoVersion)) +{ + Write-Host ('::warning title=Invalid version!::Version in settings: {0}, but repo version is {1}. Going to change variable' ` + -f $CurrentVersion, $ParsedRepoVersion) + + $Output.RELEASE_VERSION = $ParsedRepoVersion + $Output.RELEASE_TYPE = 3 +} +else +{ + # none to release + Write-Host 'No new versions, sorry' +} + +$Output.CURRENT_TAG = $LatestTag + +if($ForGithubActions) { + $Plain = New-Object -TypeName "System.Text.StringBuilder"; + $Output.GetEnumerator() | ForEach-Object { + [void]$Plain.Append($_.Key) + [void]$Plain.Append('=') + [void]$Plain.AppendLine($_.Value) + } + Write-Output $Plain.ToString() +} else { + $Output +} diff --git a/.github/workflows/build-with-firmwware.yml b/.github/workflows/build-with-firmwware.yml index aaa13369c67..cd2cf5c3faf 100644 --- a/.github/workflows/build-with-firmwware.yml +++ b/.github/workflows/build-with-firmwware.yml @@ -9,7 +9,7 @@ on: required: false type: string release: - types: [unpublished] + types: [created] push: paths: - .github/workflows/build-with-firmware.yml @@ -30,6 +30,7 @@ jobs: IGNORED_PATH: "applications_user/subbrute" RELATIVE_PATH: "applications/external/subbrute" CURRENT_VERSION: ${{ vars.RELEASE_VERSION }} + RELEASE_VERSION: ${{ vars.RELEASE_VERSION }} strategy: fail-fast: false matrix: @@ -39,6 +40,9 @@ jobs: url: ${{ vars.REPO_UNLEASHED }} version: ${{ vars.FIRMWARE_VERSION }} src-included: 1 + #- firmware: official + # url: ${{ vars.REPO_OFFICIAL }} + # version: "official" steps: - name: Set version env: @@ -117,6 +121,17 @@ jobs: Write-Output ('::notice title=Git output::{0}' -f $Output) } + # - name: Restore FBT + # id: cache-restore + # if: ${{ success() }} + # uses: actions/cache/restore@v3 + # with: + # path: | + # build/** + # debug/** + # # An explicit key for restoring and saving the cache + # key: 'fbt=${{ env.FIRMWARE_VERSION }}' + # - name: Build Firmware shell: bash if: ${{ success() }} @@ -127,6 +142,17 @@ jobs: run: | ./fbt COMPACT=1 DEBUG=0 fap_dist + # - name: Save FBT + # id: cache-save + # if: ${{ success() }} + # uses: actions/cache/save@v3 + # with: + # path: | + # build/** + # debug/** + # # An explicit key for restoring and saving the cache + # key: ${{ steps.cache-restore.outputs.cache-primary-key }} + - name: Create assets if: ${{ success() }} shell: pwsh diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml index 2f98f1d0fad..8177708d174 100644 --- a/.github/workflows/version-check.yml +++ b/.github/workflows/version-check.yml @@ -20,16 +20,18 @@ jobs: runs-on: ubuntu-latest env: REPO_UNLEASHED: ${{ vars.REPO_UNLEASHED }} + CURRENT_TAG: ${{ vars.FIRMWARE_VERSION }} + REMOTE_TAG_INFO: '' RELEASE_VERSION: ${{ vars.RELEASE_VERSION }} FIRMWARE_VERSION: ${{ vars.FIRMWARE_VERSION }} REPO_SELF: ${{ vars.REPO_SELF }} CHECKOUT_DIR: "firmware" + RELEASE_TYPE: 0 steps: - name: Copy Repo Files uses: actions/checkout@v3 with: repository: "${{ env.REPO_SELF }}" - path: "${{ env.CHECKOUT_DIR }}" clean: "true" submodules: "true" token: ${{ secrets.FLIPPER_TOKEN }} @@ -38,126 +40,22 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - function CleanInput - { - param( - [string] - $DurtyString - ) - return $DurtyString -replace ('[^a-zA-Z\d_\-\,\.\t\n\r\:\;]', '') - } - - $Release = @(` - (CleanInput ` - (gh release list -L 1 --repo '${{ env.REPO_UNLEASHED }}')` - ) -split "`t") - - $FirmwareVersionNumber = 0 - $StoredFirmwareVersionNumber = 0 - if ($Release[2] -match '\-(\d+)$') - { - $FirmwareVersionNumber = [int]($Matches[1]) - } - else - { - Write-Error ('::error title=Invalid firmware number::Error during execution this tags {0}' -f $FirmwareVersionNumber) - exit 1 - } - if ('${{ env.FIRMWARE_VERSION }}' -match '\-(\d+)$') - { - $StoredFirmwareVersionNumber = [int]($Matches[1]) - } - else - { - Write-Error ('::error title=Invalid STORED firmware number::Error during execution this version {0}' -f '${{ env.FIRMWARE_VERSION }}') - exit 1 - } - - $LatestFirmware = CleanInput ((CleanInput (gh release list -L 1 --repo '${{ env.REPO_SELF }}') -replace '\t', ';') | ` - ConvertFrom-Csv -Delimiter ';' -Header name, flag, tag).tag - - $Delta = ( [DateTime]::Now - [DateTime]::Parse($Release[3]) ) - $NewVersionFw = $false - Write-Host ('Latest firmware {0}' -f $LatestFirmware) -ForegroundColor Gray -BackgroundColor Magenta - Write-Debug ('::debug LatestFirmware {0}' -f $LatestFirmware) - - Write-Output ('REMOTE_TAG_INFO=[{0}]({1}/releases/tag/{2})' -f $LatestFirmware, '${{ env.REPO_UNLEASHED }}', $LatestFirmware) >> $env:GITHUB_ENV - if (($FirmwareVersionNumber -gt $StoredFirmwareVersionNumber) -and ( $Delta -gt [TimeSpan]::FromMinutes(10))) - { - Write-Debug ('::debug LatestFirmware {0}' -f $LatestFirmware) - Write-Output ('FIRMWARE_VERSION={0}' -f $LatestFirmware) >> $env:GITHUB_ENV - $NewVersionFw = $true - } - elseif ($FirmwareVersionNumber -lt $StoredFirmwareVersionNumber) - { - Write-Error ('::error title=Invalid check of stored::Version in repo: {0}, but we think it is {1}' -f $FirmwareVersionNumber, $StoredFirmwareVersionNumber) - exit 1 - } - - $LastPublished = (gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" '/repos/${{ vars.REPO_SELF }}/releases?per_page=1' | ConvertFrom-Json).published_at - $Delta = ([DateTime]::Now - $LastPublished) - - $Release = (gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" '/repos/${{ vars.REPO_SELF }}/tags?per_page=1' | ConvertFrom-Json).name - Write-Host ('Release {0}' -f $Release) -ForegroundColor Gray -BackgroundColor Magenta - $LatestTag = $Release.Substring(1) - - $CurrentVersion = [version]::Parse('${{ env.RELEASE_VERSION }}') - $ParsedRepoVersion = [version]::Parse($LatestTag) - Write-Host ('Current tag:Repos tag {0}, {1}' -f $CurrentVersion, $ParsedRepoVersion) -ForegroundColor Gray -BackgroundColor Magenta - Write-Debug ('::debug Current tag:Repos tag {0}, {1}' -f $CurrentVersion, $ParsedRepoVersion) - if (($CurrentVersion -lt $ParsedRepoVersion) -and ( $Delta -gt [TimeSpan]::FromMinutes(10))) - { - $Tag = ('{0}.{1}.{2}' -f $ParsedRepoVersion.Major, $ParsedRepoVersion.Minor, $ParsedRepoVersion.Build) - - Write-Output ('RELEASE_VERSION={0}' -f $Tag) >> $env:GITHUB_ENV - Write-Output ('RELEASE_TYPE=2' -f $Tag) >> $env:GITHUB_ENV - - Write-Output ('::warning title=New release!::Release {0}' -f $Tag) - } - elseif ( $NewVersionFw ) - { - $Tag = ('{0}.{1}.{2}' -f $CurrentVersion.Major, $CurrentVersion.Minor, ($CurrentVersion.Build + 1)) - - Write-Output ('RELEASE_VERSION={0}' -f $Tag) >> $env:GITHUB_ENV - Write-Output ('RELEASE_TYPE=1' -f $Tag) >> $env:GITHUB_ENV - - Write-Output ('::warning title=Firmware was changed!::New version is {0}, creating release {1}' -f $LatestFirmware, $Tag) - } - elseif ( ($Delta -gt [TimeSpan]::FromMinutes(10)) -and ($CurrentVersion -gt $ParsedRepoVersion)) - { - Write-Output ('::warning title=Invalid version!::Version in settings: {0}, but repo version is {1}. Going to change variable' -f $CurrentVersion, $ParsedRepoVersion) - Write-Output ('RELEASE_VERSION={0}' -f $ParsedRepoVersion) >> $env:GITHUB_ENV - Write-Output ('RELEASE_TYPE=3' -f $Tag) >> $env:GITHUB_ENV - } - else - { - # none to release - Write-Host 'No new versions, sorry' - } - Write-Output ('CURRENT_TAG={0}' -f $LatestTag) >> $env:GITHUB_ENV - - - name: Update Firmware variable and create UPDATE release if necessary - if: ${{ success() && env.RELEASE_TYPE == 1 }} - env: - GITHUB_TOKEN: ${{ secrets.FLIPPER_TOKEN }} - OWNER: ${{ github.repository_owner }} - run: | - gh release create 'v${{ env.RELEASE_VERSION }}' --latest --draft \ - --notes 'Rebuild with new version of firmware.\n\nSee: [CHANGELOG](${{ env.FIRMWARE_VERSION }}/blob/dev/CHANGELOG.md)\n${{ env.REMOTE_TAG_INFO}}' \ - --title 'Minor update v${{ env.RELEASE_VERSION }}' --verify-tag -R '${{ env.REPO_SELF }}' - gh variable set FIRMWARE_VERSION -b '${{ env.FIRMWARE_VERSION }}' -R '${{ env.REPO_SELF }}' - gh variable set RELEASE_VERSION -b '${{ env.RELEASE_VERSION }}' -R '${{ env.REPO_SELF }}' - - name: Update release variable and create NEW release if necessary - if: ${{ success() && env.RELEASE_TYPE == 2 }} - env: - GITHUB_TOKEN: ${{ secrets.FLIPPER_TOKEN }} - OWNER: ${{ github.repository_owner }} - run: | - gh release create 'v${{ env.RELEASE_VERSION }}' --notes-start-tag 'v${{ env.CURRENT_TAG }}' --generate-notes --draft --latest \ - --notes 'New version is rolling out!' --verify-tag --title 'Release v${{ env.RELEASE_VERSION }}' -R '${{ env.REPO_SELF }}' + ./.github/check-version.ps1 '${{ env.FIRMWARE_VERSION }}' '${{ env.RELEASE_VERSION }}' '${{ env.REPO_SELF }}' '${{ env.REPO_UNLEASHED }}' | %{ Write-Output($_) >> $Env:GITHUB_ENV } + - name: Print env values + run: env + - name: Create release if necessary + if: ${{ success() && (env.RELEASE_TYPE == 2 || env.RELEASE_TYPE == 1 )}} + uses: ./.github/actions/make-release + with: + gh_token: ${{ secrets.FLIPPER_TOKEN }} + release_type: ${{ env.RELEASE_TYPE }} + release_version: ${{ env.RELEASE_VERSION }} + firmware_version: ${{ env.FIRMWARE_VERSION }} + repo_self: ${{ env.REPO_SELF }} + owner: ${{ github.repository_owner }} + current_tag: ${{ env.CURRENT_TAG }} + remote_tag_info: ${{ env.REMOTE_TAG_INFO }} - gh variable set FIRMWARE_VERSION -b '${{ env.FIRMWARE_VERSION }}' -R '${{ env.REPO_SELF }}' - gh variable set RELEASE_VERSION -b '${{ env.RELEASE_VERSION }}' -R '${{ env.REPO_SELF }}' - name: Current settings in repo invalid. Changing if: ${{ success() && env.RELEASE_TYPE > 2 }} env: diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000000..bc4a69bb7c8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "workbench.colorCustomizations": { + "list.errorForeground": "#00AA00", + "list.warningForeground": "#00d9ff", + "gitDecoration.modifiedResourceForeground": "#00ffb3", + "gitDecoration.untrackedResourceForeground": "#f7aeae" + } +} From f5fe40e36fdff95c6110a253ffaa0342fb890d26 Mon Sep 17 00:00:00 2001 From: DerSkythe Date: Fri, 31 Mar 2023 07:25:24 +0400 Subject: [PATCH 3/3] 1.0.1 --- views/shapshup_main_view.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/views/shapshup_main_view.c b/views/shapshup_main_view.c index a12c38741db..9fb2e528b89 100644 --- a/views/shapshup_main_view.c +++ b/views/shapshup_main_view.c @@ -94,9 +94,6 @@ bool shapshup_main_view_input(InputEvent* event, void* context) { instance->raw_file->total_len, instance->raw_file->min_len, instance->scale) : 0; if(event->key == InputKeyOk) { -#ifdef FURI_DEBUG - FURI_LOG_D(TAG, "InputKeyOk"); -#endif instance->callback(ShapShupCustomEventTypeLoadFile, instance->context); } else if(event->key == InputKeyLeft && instance->offset > 0) { instance->offset = instance->offset < offset_per_page ? 0 : @@ -590,4 +587,4 @@ void format_number(uint64_t n, char* out) { c = (c + 1) % 3; } *--out = 0; -} \ No newline at end of file +}