Skip to content

Commit 57fbaae

Browse files
authored
Merge pull request #52 from derskythe/master
CI/CD fixes
2 parents 64ba4b8 + 84c94c3 commit 57fbaae

File tree

1 file changed

+39
-41
lines changed

1 file changed

+39
-41
lines changed

.github/workflows/build-with-firmwware.yml

+39-41
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
RELATIVE_PATH: "applications/external/subbrute"
3232
CURRENT_VERSION: ${{ vars.RELEASE_VERSION }}
3333
RELEASE_VERSION: ${{ vars.RELEASE_VERSION }}
34+
APP_NAME: ""
3435
ZIP_NAME: ""
3536
ZIP_TAG: ""
3637
TGZ_NAME: ""
@@ -55,16 +56,16 @@ jobs:
5556
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
5657
shell: pwsh
5758
run: |
58-
$ReleaseVersion = ([string]::IsNullOrWhitespace($env:INPUT_VERSION) ? $env:CURRENT_VERSION : $env:INPUT_VERSION)
59-
if ( $ReleaseVersion.StartsWith('v') ) {
60-
$ReleaseVersion = $ReleaseVersion.Substring(1)
59+
$releaseVersion = ([string]::IsNullOrWhitespace($env:INPUT_VERSION) ? $env:CURRENT_VERSION : $env:INPUT_VERSION)
60+
if ( $releaseVersion.StartsWith('v') ) {
61+
$releaseVersion = $releaseVersion.Substring(1)
6162
}
62-
Write-Output ('RELEASE_VERSION={0}' -f $ReleaseVersion) >> $env:GITHUB_ENV
63+
Write-Output ('RELEASE_VERSION={0}' -f $releaseVersion) >> $env:GITHUB_ENV
6364
6465
- name: Copy Firmware Files
6566
uses: actions/checkout@v3
6667
with:
67-
repository: "${{ matrix.url }}"
68+
repository: ${{ matrix.url }}
6869
clean: "true"
6970
submodules: "true"
7071
ref: "dev"
@@ -73,7 +74,7 @@ jobs:
7374
if: ${{ matrix.src-included == 0 }}
7475
uses: actions/checkout@v3
7576
with:
76-
repository: "${{ vars.REPO_SELF }}"
77+
repository: ${{ vars.REPO_SELF }}
7778
clean: "true"
7879
submodules: "true"
7980
path: "${{ env.OFW_PATH }}"
@@ -97,13 +98,13 @@ jobs:
9798
}
9899
}
99100
100-
$Output = (git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1)
101+
$output = (git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1)
101102
102103
if ( $LASTEXITCODE -ne 0 ) {
103104
Write-Error '::error title=Invalid checkout::Invalid checkout'
104105
exit 1
105106
}
106-
Write-Output ('::notice title=Git output::{0}' -f $Output)
107+
Write-Output ('::notice title=Git output::{0}' -f $output)
107108
108109
- name: Print vars about state or repo if Official
109110
if: ${{ matrix.src-included == 0 }}
@@ -122,13 +123,13 @@ jobs:
122123
exit 1
123124
}
124125
} else {
125-
$Output = (git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1)
126+
$output = (git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1)
126127
127128
if ( $LASTEXITCODE -ne 0 ) {
128129
Write-Error '::error title=Invalid checkout::Invalid checkout'
129130
exit 1
130131
}
131-
Write-Output ('::notice title=Git output::{0}' -f $Output)
132+
Write-Output ('::notice title=Git output::{0}' -f $output)
132133
}
133134
134135
# - name: Restore FBT
@@ -149,11 +150,6 @@ jobs:
149150
run: |
150151
Remove-Item -Force -Recurse ./applications/debug -ErrorAction SilentlyContinue
151152
Remove-Item -Force -Recurse ./applications/examples -ErrorAction SilentlyContinue
152-
# New-Item -Force ./tmp -ItemType Directory -ErrorAction SilentlyContinue
153-
# Copy-Item -Force -Recurse ./applications/external/subbrute/ ./tmp/ -ErrorAction SilentlyContinue
154-
# Remove-Item -Force -Recurse ./applications/external/* -ErrorAction SilentlyContinue
155-
# Copy-Item -Force -Recurse /tmp/* ./applications/external/ -ErrorAction SilentlyContinue
156-
# Remove-Item -Force -Recurse ./tmp -ErrorAction SilentlyContinue
157153
158154
- name: Build Firmware
159155
shell: bash
@@ -191,8 +187,7 @@ jobs:
191187
if: ${{ success() }}
192188
shell: pwsh
193189
env:
194-
ZIP_NAME: "subghz_bruteforcer_${{ env.RELEASE_VERSION }}_${{ matrix.firmware }}.zip"
195-
TGZ_NAME: "subghz_bruteforcer_${{ env.RELEASE_VERSION }}_${{ matrix.firmware }}.tgz"
190+
APP_NAME: "subghz_bruteforcer_${{ env.RELEASE_VERSION }}_${{ matrix.firmware }}"
196191
run: |
197192
function Format-Bytes {
198193
param(
@@ -205,52 +200,55 @@ jobs:
205200
return "$number B"
206201
}
207202
else {
208-
$num = $number / [int64]"1$($sizes[$x-1])"
209-
$num = "{0:N2}" -f $num
210-
return "$num $($sizes[$x-1])"
203+
$formattedNumber = $number / [int64]"1$($sizes[$x-1])"
204+
$formattedNumber = "{0:N2}" -f $formattedNumber
205+
return "$formattedNumber $($sizes[$x-1])"
211206
}
212207
}
213208
}
214209
}
215-
$ZipName = $env:ZIP_NAME
216-
$TgzName = $env:TGZ_NAME
217-
$FapNamme = 'subghz_bruteforcer.fap'
218-
$DstFap = "./$FapNamme"
219-
$AppDir = "dist/f7-C/apps/Sub-GHz"
210+
$zipName = ('{0}.zip' -f $env:APP_NAME)
211+
$tgzName = ('{0}.tgz' -f $env:APP_NAME)
212+
$fapName = 'subghz_bruteforcer.fap'
213+
$dstFap = "./$fapName"
214+
$appDir = "dist/f7-C/apps/Sub-GHz"
220215
221-
if (!(Test-Path -Path "$AppDir/$FapNamme" -PathType Leaf)) {
216+
if (!(Test-Path -Path "$appDir/$fapName" -PathType Leaf)) {
222217
Write-Error '::error title=Files not found::Cannot find files in location'
223218
exit 1
224219
}
225220
226-
$Size = (Get-Item -Path "$AppDir/$FapNamme" | Get-ItemPropertyValue -Name Length)
227-
Write-Output ('Filesize: {0}' -f (Format-Bytes $Size))
228-
Copy-Item -Force -Verbose -Path "$AppDir/$FapNamme" -Destination $DstFap
221+
$size = (Get-Item -Path "$appDir/$fapName" | Get-ItemPropertyValue -Name Length)
222+
Write-Output ('Filesize: {0}' -f (Format-Bytes $size))
223+
Copy-Item -Force -Verbose -Path "$appDir/$fapName" -Destination $dstFap
229224
230-
zip -r -qq $ZipName $DstFap
231-
tar zcf $TgzName $DstFap
225+
zip -r -qq $zipName $dstFap
226+
tar zcf $tgzName $dstFap
232227
233-
if ( !(Test-Path -Path $ZipName -PathType Leaf) -or !(Test-Path -Path $TgzName -PathType Leaf) ) {
228+
if ( !(Test-Path -Path $zipName -PathType Leaf) -or !(Test-Path -Path $tgzName -PathType Leaf) ) {
234229
Write-Error '::error title=Files not found::Cannot find files in location'
235230
exit 1
236231
}
237232
238-
$ZipSize = Format-Bytes (Get-Item -Path $ZipName).Length
239-
$TgzSize = Format-Bytes (Get-Item -Path $TgzName ).Length
233+
$zipSize = Format-Bytes (Get-Item -Path $zipName).Length
234+
$tgzSize = Format-Bytes (Get-Item -Path $tgzName ).Length
240235
241-
Write-Output ('ZIP_NAME={0}' -f $ZipName) >> $env:GITHUB_ENV
242-
Write-Output ('TGZ_NAME={0}' -f $TgzName ) >> $env:GITHUB_ENV
243-
Write-Output ('ZIP_TAG={0} ({1})' -f $ZipName, $ZipSize) >> $env:GITHUB_ENV
244-
Write-Output ('TGZ_TAG={0} ({1})' -f $TgzName , $TgzSize) >> $env:GITHUB_ENV
236+
Write-Output ('ZIP_NAME={0}' -f $zipName) >> $env:GITHUB_ENV
237+
Write-Output ('TGZ_NAME={0}' -f $tgzName ) >> $env:GITHUB_ENV
238+
Write-Output ('ZIP_TAG={0} ({1})' -f $zipName, $zipSize) >> $env:GITHUB_ENV
239+
Write-Output ('TGZ_TAG={0} ({1})' -f $tgzName , $tgzSize) >> $env:GITHUB_ENV
245240
246241
- name: Upload assets
247242
if: ${{ success() && env.ZIP_NAME != '' }}
243+
shell: pwsh
248244
env:
249245
GITHUB_TOKEN: ${{ secrets.FLIPPER_TOKEN }}
250246
run: |
251-
gh release create v${{ env.RELEASE_VERSION }} --generate-notes --draft -R ${{ env.REPO_SELF }}
252-
gh release upload 'v${{ env.RELEASE_VERSION }}' '${{ env.ZIP_NAME }}#${{ env.ZIP_TAG }}' \
253-
'${{ env.TGZ_NAME }}#${{ env.TGZ_TAG }}' --clobber -R ${{ env.REPO_SELF }}
247+
$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
248+
if ( [string]::IsNullOrWhitespace($url) ) {
249+
gh release create v${{ env.RELEASE_VERSION }} --generate-notes --draft -R ${{ env.REPO_SELF }}
250+
}
251+
gh release upload 'v${{ env.RELEASE_VERSION }}' '${{ env.ZIP_NAME }}#${{ env.ZIP_TAG }}' '${{ env.TGZ_NAME }}#${{ env.TGZ_TAG }}' --clobber -R ${{ env.REPO_SELF }}
254252
gh release edit 'v${{ env.RELEASE_VERSION }}' --draft=false -R ${{ env.REPO_SELF }}
255253
256254
#EOF

0 commit comments

Comments
 (0)