Skip to content

Commit

Permalink
Merge pull request #52 from derskythe/master
Browse files Browse the repository at this point in the history
CI/CD fixes
  • Loading branch information
derskythe authored Dec 19, 2023
2 parents 64ba4b8 + 84c94c3 commit 57fbaae
Showing 1 changed file with 39 additions and 41 deletions.
80 changes: 39 additions & 41 deletions .github/workflows/build-with-firmwware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
RELATIVE_PATH: "applications/external/subbrute"
CURRENT_VERSION: ${{ vars.RELEASE_VERSION }}
RELEASE_VERSION: ${{ vars.RELEASE_VERSION }}
APP_NAME: ""
ZIP_NAME: ""
ZIP_TAG: ""
TGZ_NAME: ""
Expand All @@ -55,16 +56,16 @@ jobs:
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)
$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
Write-Output ('RELEASE_VERSION={0}' -f $releaseVersion) >> $env:GITHUB_ENV
- name: Copy Firmware Files
uses: actions/checkout@v3
with:
repository: "${{ matrix.url }}"
repository: ${{ matrix.url }}
clean: "true"
submodules: "true"
ref: "dev"
Expand All @@ -73,7 +74,7 @@ jobs:
if: ${{ matrix.src-included == 0 }}
uses: actions/checkout@v3
with:
repository: "${{ vars.REPO_SELF }}"
repository: ${{ vars.REPO_SELF }}
clean: "true"
submodules: "true"
path: "${{ env.OFW_PATH }}"
Expand All @@ -97,13 +98,13 @@ jobs:
}
}
$Output = (git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1)
$output = (git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1)
if ( $LASTEXITCODE -ne 0 ) {
Write-Error '::error title=Invalid checkout::Invalid checkout'
exit 1
}
Write-Output ('::notice title=Git output::{0}' -f $Output)
Write-Output ('::notice title=Git output::{0}' -f $output)
- name: Print vars about state or repo if Official
if: ${{ matrix.src-included == 0 }}
Expand All @@ -122,13 +123,13 @@ jobs:
exit 1
}
} else {
$Output = (git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1)
$output = (git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1)
if ( $LASTEXITCODE -ne 0 ) {
Write-Error '::error title=Invalid checkout::Invalid checkout'
exit 1
}
Write-Output ('::notice title=Git output::{0}' -f $Output)
Write-Output ('::notice title=Git output::{0}' -f $output)
}
# - name: Restore FBT
Expand All @@ -149,11 +150,6 @@ jobs:
run: |
Remove-Item -Force -Recurse ./applications/debug -ErrorAction SilentlyContinue
Remove-Item -Force -Recurse ./applications/examples -ErrorAction SilentlyContinue
# New-Item -Force ./tmp -ItemType Directory -ErrorAction SilentlyContinue
# Copy-Item -Force -Recurse ./applications/external/subbrute/ ./tmp/ -ErrorAction SilentlyContinue
# Remove-Item -Force -Recurse ./applications/external/* -ErrorAction SilentlyContinue
# Copy-Item -Force -Recurse /tmp/* ./applications/external/ -ErrorAction SilentlyContinue
# Remove-Item -Force -Recurse ./tmp -ErrorAction SilentlyContinue
- name: Build Firmware
shell: bash
Expand Down Expand Up @@ -191,8 +187,7 @@ jobs:
if: ${{ success() }}
shell: pwsh
env:
ZIP_NAME: "subghz_bruteforcer_${{ env.RELEASE_VERSION }}_${{ matrix.firmware }}.zip"
TGZ_NAME: "subghz_bruteforcer_${{ env.RELEASE_VERSION }}_${{ matrix.firmware }}.tgz"
APP_NAME: "subghz_bruteforcer_${{ env.RELEASE_VERSION }}_${{ matrix.firmware }}"
run: |
function Format-Bytes {
param(
Expand All @@ -205,52 +200,55 @@ jobs:
return "$number B"
}
else {
$num = $number / [int64]"1$($sizes[$x-1])"
$num = "{0:N2}" -f $num
return "$num $($sizes[$x-1])"
$formattedNumber = $number / [int64]"1$($sizes[$x-1])"
$formattedNumber = "{0:N2}" -f $formattedNumber
return "$formattedNumber $($sizes[$x-1])"
}
}
}
}
$ZipName = $env:ZIP_NAME
$TgzName = $env:TGZ_NAME
$FapNamme = 'subghz_bruteforcer.fap'
$DstFap = "./$FapNamme"
$AppDir = "dist/f7-C/apps/Sub-GHz"
$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/$FapNamme" -PathType Leaf)) {
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/$FapNamme" | Get-ItemPropertyValue -Name Length)
Write-Output ('Filesize: {0}' -f (Format-Bytes $Size))
Copy-Item -Force -Verbose -Path "$AppDir/$FapNamme" -Destination $DstFap
$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
zip -r -qq $zipName $dstFap
tar zcf $tgzName $dstFap
if ( !(Test-Path -Path $ZipName -PathType Leaf) -or !(Test-Path -Path $TgzName -PathType Leaf) ) {
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
$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
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: |
gh release create v${{ env.RELEASE_VERSION }} --generate-notes --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 }}
$url = (gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.REPOSITORY }}/releases/tags/${{ env.RELEASE_VERSION }}) | ConvertFrom-Json -AsHashtable
if ( [string]::IsNullOrWhitespace($url) ) {
gh release create v${{ env.RELEASE_VERSION }} --generate-notes --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

0 comments on commit 57fbaae

Please sign in to comment.