| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- name: "Build for Firmware"
- run-name: "Build ${{ inputs.DEPLOY_TARGET }} by @${{ github.ACTOR }}"
- on:
- workflow_dispatch:
- inputs:
- version:
- description: "Enter version to build or left empty for current version"
- required: false
- type: string
- release:
- types: [created, prereleased]
- push:
- paths:
- - .github/workflows/build-with-firmware.yml
- permissions:
- contents: write
- packages: write
- concurrency:
- group: firmware-build-${{ vars.FIRMWARE_VERSION }}-${{ vars.RELEASE_VERSION }}
- cancel-in-progress: false
- jobs:
- build-and-upload:
- runs-on: ubuntu-latest
- env:
- REPO_SELF: ${{ vars.REPO_SELF }}
- OFW_PATH: "applications_user/subbrute"
- RELATIVE_PATH: "applications/external/subbrute"
- CURRENT_VERSION: ${{ vars.RELEASE_VERSION }}
- RELEASE_VERSION: ${{ vars.RELEASE_VERSION }}
- APP_NAME: ""
- ZIP_NAME: ""
- ZIP_TAG: ""
- TGZ_NAME: ""
- TGZ_TAG: ""
- strategy:
- fail-fast: false
- matrix:
- firmware: [unlshd, official]
- include:
- - firmware: unlshd
- url: ${{ vars.REPO_UNLEASHED }}
- version: ${{ vars.FIRMWARE_VERSION }}
- src-included: 0
- - firmware: official
- url: ${{ vars.REPO_OFFICIAL }}
- version: "official"
- src-included: 0
- steps:
- - name: Set version
- env:
- INPUT_VERSION: ${{ inputs.version }}
- CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
- shell: pwsh
- run: |
- $releaseVersion = ([string]::IsNullOrWhitespace($env:INPUT_VERSION) ? $env:CURRENT_VERSION : $env:INPUT_VERSION)
- if ( $releaseVersion.StartsWith('v') ) {
- $releaseVersion = $releaseVersion.Substring(1)
- }
- Write-Output ('RELEASE_VERSION={0}' -f $releaseVersion) >> $env:GITHUB_ENV
- - name: Copy Firmware Files
- uses: actions/checkout@v3
- with:
- repository: ${{ matrix.url }}
- clean: "true"
- submodules: "true"
- ref: "dev"
- - name: Copy Repo Files
- if: ${{ matrix.src-included == 0 }}
- uses: actions/checkout@v3
- with:
- repository: ${{ vars.REPO_SELF }}
- clean: "true"
- submodules: "true"
- path: "${{ env.OFW_PATH }}"
- # - 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: Remove other apps
- shell: pwsh
- if: ${{ success() }}
- # rm to remove problem FAP which includes non-existent files
- run: |
- Remove-Item -Force -Recurse ./applications/debug -ErrorAction SilentlyContinue
- Remove-Item -Force -Recurse ./applications/examples -ErrorAction SilentlyContinue
- - name: Build Firmware
- shell: bash
- if: ${{ success() }}
- env:
- FBT_NO_SYNC: 0
- DIST_SUFFIX: ${{ matrix.version }}
- WORKFLOW_BRANCH_OR_TAG: release-cfw
- run: |
- ./fbt COMPACT=1 DEBUG=0 FBT_NO_SYNC=0
- - name: Build FAPs
- shell: bash
- if: ${{ success() }}
- env:
- FBT_NO_SYNC: 0
- DIST_SUFFIX: ${{ matrix.version }}
- WORKFLOW_BRANCH_OR_TAG: release-cfw
- # rm to remove problem FAP which includes non-existent files
- run: |
- ./fbt COMPACT=1 DEBUG=0 FBT_NO_SYNC=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
- env:
- APP_NAME: "subghz_bruteforcer_${{ env.RELEASE_VERSION }}_${{ matrix.firmware }}"
- run: |
- function Format-Bytes {
- param(
- [int]$number
- )
- $sizes = 'KB', 'MB', 'GB', 'TB', 'PB'
- for ($x = 0; $x -lt $sizes.count; $x++) {
- if ($number -lt [int64]"1$($sizes[$x])") {
- if ($x -eq 0) {
- return "$number B"
- }
- else {
- $formattedNumber = $number / [int64]"1$($sizes[$x-1])"
- $formattedNumber = "{0:N2}" -f $formattedNumber
- return "$formattedNumber $($sizes[$x-1])"
- }
- }
- }
- }
- $zipName = ('{0}.zip' -f $env:APP_NAME)
- $tgzName = ('{0}.tgz' -f $env:APP_NAME)
- $fapName = 'subghz_bruteforcer.fap'
- $dstFap = "./$fapName"
- $appDir = "dist/f7-C/apps/Sub-GHz"
- if (!(Test-Path -Path "$appDir/$fapName" -PathType Leaf)) {
- Write-Error '::error title=Files not found::Cannot find files in location'
- exit 1
- }
- $size = (Get-Item -Path "$appDir/$fapName" | Get-ItemPropertyValue -Name Length)
- Write-Output ('Filesize: {0}' -f (Format-Bytes $size))
- Copy-Item -Force -Verbose -Path "$appDir/$fapName" -Destination $dstFap
- zip -r -qq $zipName $dstFap
- tar zcf $tgzName $dstFap
- if ( !(Test-Path -Path $zipName -PathType Leaf) -or !(Test-Path -Path $tgzName -PathType Leaf) ) {
- Write-Error '::error title=Files not found::Cannot find files in location'
- exit 1
- }
- $zipSize = Format-Bytes (Get-Item -Path $zipName).Length
- $tgzSize = Format-Bytes (Get-Item -Path $tgzName ).Length
- Write-Output ('ZIP_NAME={0}' -f $zipName) >> $env:GITHUB_ENV
- Write-Output ('TGZ_NAME={0}' -f $tgzName ) >> $env:GITHUB_ENV
- Write-Output ('ZIP_TAG={0} ({1})' -f $zipName, $zipSize) >> $env:GITHUB_ENV
- Write-Output ('TGZ_TAG={0} ({1})' -f $tgzName , $tgzSize) >> $env:GITHUB_ENV
- - name: Upload assets
- if: ${{ success() && env.ZIP_NAME != '' }}
- shell: pwsh
- env:
- GITHUB_TOKEN: ${{ secrets.FLIPPER_TOKEN }}
- run: |
- $url = (gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.REPOSITORY }}/releases/tags/v${{ env.RELEASE_VERSION }} >$null 2>&1) | ConvertFrom-Json -AsHashtable -ErrorAction SilentlyContinue
- if ( [string]::IsNullOrWhitespace($url.name) ) {
- $sha = (git rev-parse --verify HEAD)
- gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.REPOSITORY }}/releases -f tag_name='v${{ env.RELEASE_VERSION }}' -f target_commitish="$sha" -f name='v${{ env.RELEASE_VERSION }}' -F draft=true -F prerelease=false -F generate_release_notes=true
- #gh release create v${{ env.RELEASE_VERSION }} --generate-notes -f target_commitish='master' --draft -R ${{ env.REPO_SELF }}
- }
- gh release upload 'v${{ env.RELEASE_VERSION }}' '${{ env.ZIP_NAME }}#${{ env.ZIP_TAG }}' '${{ env.TGZ_NAME }}#${{ env.TGZ_TAG }}' --clobber -R ${{ env.REPO_SELF }}
- gh release edit 'v${{ env.RELEASE_VERSION }}' --draft=false -R ${{ env.REPO_SELF }}
- #EOF
|