Skip to content

Commit 2255695

Browse files
authored
Merge pull request #35 from DarkFlippers/master
Sync from master
2 parents 97dd093 + e4264e1 commit 2255695

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4953
-4447
lines changed

.github/check-version.ps1

Lines changed: 141 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,141 @@
1-
########################################
2-
Set-StrictMode -Version 3.0 #
3-
$ErrorActionPreference = "Stop" #
4-
########################################
5-
6-
[string]$FirmwareVersion = $args[0]
7-
[string]$ReleaseVersion = $args[1]
8-
[string]$RepoSelf = $args[2]
9-
[string]$RepoUnleashed = $args[3]
10-
[bool]$ForGithubActions = $true
11-
12-
################################################################################################################################
13-
function CleanInput
14-
{
15-
param(
16-
[string]
17-
$DurtyString
18-
)
19-
return $DurtyString -replace ('[^a-zA-Z\d_\-\,\.\t\n\r\:\;]', '')
20-
}
21-
22-
################################################################################################################################
23-
24-
$Output = @{
25-
RELEASE_VERSION = $ReleaseVersion
26-
CURRENT_TAG = $FirmwareVersion
27-
REMOTE_TAG_INFO = $FirmwareVersion
28-
RELEASE_TYPE = 0
29-
}
30-
31-
$Release = @(`
32-
(CleanInput `
33-
(gh release list -L 1 --repo $RepoUnleashed)`
34-
) -split "`t")
35-
36-
$FirmwareVersionNumber = 0
37-
$StoredFirmwareVersionNumber = 0
38-
$LatestFirmware = $Release[2]
39-
if ($Release[2] -match '\-(\d+)$')
40-
{
41-
$FirmwareVersionNumber = [int]($Matches[1])
42-
}
43-
else
44-
{
45-
Write-Error ('::error title=Invalid firmware number::Error during execution this tags {0}' -f $FirmwareVersionNumber)
46-
exit 1
47-
}
48-
if ($FirmwareVersion -match '\-(\d+)$')
49-
{
50-
$StoredFirmwareVersionNumber = [int]($Matches[1])
51-
}
52-
else
53-
{
54-
Write-Error ('::error title=Invalid STORED firmware number::Error during execution this version {0}' -f $FirmwareVersion)
55-
exit 1
56-
}
57-
$Delta = ( [DateTime]::Now - [DateTime]::Parse($Release[3]))
58-
Write-Host "FirmwareVersionNumber: $FirmwareVersionNumber, Delta: $Delta"
59-
#exit 0
60-
61-
$NewVersionFw = $false
62-
Write-Host ('Latest firmware {0}' -f $FirmwareVersionNumber)
63-
64-
$Output.REMOTE_TAG_INFO = Write-Host ('[{0}]({1}/releases/tag/{2})' `
65-
-f $LatestFirmware, $RepoUnleashed, $LatestFirmware)
66-
if (($FirmwareVersionNumber -gt $StoredFirmwareVersionNumber) -and ( $Delta -gt [TimeSpan]::FromMinutes(10)))
67-
{
68-
$Output.REMOTE_TAG_INFO = $LatestFirmware
69-
$NewVersionFw = $true
70-
}
71-
elseif ($FirmwareVersionNumber -lt $StoredFirmwareVersionNumber)
72-
{
73-
Write-Error ('::error title=Invalid check of stored::Version in repo: {0}, but we think it is {1}' `
74-
-f $FirmwareVersionNumber, $StoredFirmwareVersionNumber)
75-
exit 1
76-
}
77-
78-
$PublishDates = (gh api -H "Accept: application/vnd.github+json" `
79-
-H "X-GitHub-Api-Version: 2022-11-28" "/repos/$( $RepoSelf )/releases?per_page=1" `
80-
| ConvertFrom-Json | Select-Object published_at, created_at)
81-
$LastPublished = ($null -eq $PublishDates.published_at ? $PublishDates.created_at : $PublishDates.published_at)
82-
$Delta = ([DateTime]::Now - $LastPublished)
83-
84-
$Release = (gh api -H "Accept: application/vnd.github+json" `
85-
-H "X-GitHub-Api-Version: 2022-11-28" "/repos/$( $RepoSelf )/tags?per_page=1" `
86-
| ConvertFrom-Json).name
87-
Write-Host ('Release {0}' -f $Release) -ForegroundColor Gray -BackgroundColor Blue
88-
$LatestTag = $Release.Substring(1)
89-
90-
$CurrentVersion = [version]::Parse($ReleaseVersion)
91-
$ParsedRepoVersion = [version]::Parse($LatestTag)
92-
93-
Write-Host ('Current tag:Repos tag {0}, {1}' -f $CurrentVersion, $ParsedRepoVersion) `
94-
-ForegroundColor Gray -BackgroundColor Blue
95-
Write-Debug ('::debug Current tag:Repos tag {0}, {1}' -f $CurrentVersion, $ParsedRepoVersion)
96-
97-
if (($CurrentVersion -lt $ParsedRepoVersion) -and ( $Delta -gt [TimeSpan]::FromMinutes(10)))
98-
{
99-
$Tag = ('{0}.{1}.{2}' -f $ParsedRepoVersion.Major, $ParsedRepoVersion.Minor, $ParsedRepoVersion.Build)
100-
101-
$Output.RELEASE_VERSION = $Tag
102-
$Output.RELEASE_TYPE = 2
103-
104-
Write-Host ('::warning title=New release!::Release {0}' -f $Tag)
105-
}
106-
elseif ( $NewVersionFw )
107-
{
108-
$Tag = ('{0}.{1}.{2}' -f $CurrentVersion.Major, $CurrentVersion.Minor, ($CurrentVersion.Build + 1))
109-
110-
$Output.RELEASE_VERSION = $Tag
111-
$Output.RELEASE_TYPE = 1
112-
113-
Write-Host ('::warning title=Firmware was changed!::New version is {0}, need to create release {1}' -f $LatestFirmware, $Tag)
114-
}
115-
elseif ( ($Delta -gt [TimeSpan]::FromMinutes(10)) -and ($CurrentVersion -gt $ParsedRepoVersion))
116-
{
117-
Write-Host ('::warning title=Invalid version!::Version in settings: {0}, but repo version is {1}. Going to change variable' `
118-
-f $CurrentVersion, $ParsedRepoVersion)
119-
120-
$Output.RELEASE_VERSION = $ParsedRepoVersion
121-
$Output.RELEASE_TYPE = 3
122-
}
123-
else
124-
{
125-
# none to release
126-
Write-Host 'No new versions, sorry'
127-
}
128-
129-
$Output.CURRENT_TAG = $LatestTag
130-
131-
if($ForGithubActions) {
132-
$Plain = New-Object -TypeName "System.Text.StringBuilder";
133-
$Output.GetEnumerator() | ForEach-Object {
134-
[void]$Plain.Append($_.Key)
135-
[void]$Plain.Append('=')
136-
[void]$Plain.AppendLine($_.Value)
137-
}
138-
Write-Output $Plain.ToString()
139-
} else {
140-
$Output
141-
}
1+
########################################
2+
Set-StrictMode -Version 3.0 #
3+
$ErrorActionPreference = "Stop" #
4+
########################################
5+
6+
[string]$FirmwareVersion = $args[0]
7+
[string]$ReleaseVersion = $args[1]
8+
[string]$RepoSelf = $args[2]
9+
[string]$RepoUnleashed = $args[3]
10+
[bool]$ForGithubActions = $true
11+
12+
################################################################################################################################
13+
function CleanInput
14+
{
15+
param(
16+
[string]
17+
$DurtyString
18+
)
19+
return $DurtyString -replace ('[^a-zA-Z\d_\-\,\.\t\n\r\:\;]', '')
20+
}
21+
22+
################################################################################################################################
23+
24+
$Output = @{
25+
RELEASE_VERSION = $ReleaseVersion
26+
CURRENT_TAG = $FirmwareVersion
27+
REMOTE_TAG_INFO = $FirmwareVersion
28+
RELEASE_TYPE = 0
29+
}
30+
31+
$Release = @(`
32+
(CleanInput `
33+
(gh release list -L 1 --repo $RepoUnleashed)`
34+
) -split "`t")
35+
36+
$FirmwareVersionNumber = 0
37+
$StoredFirmwareVersionNumber = 0
38+
$LatestFirmware = $Release[2]
39+
if ($Release[2] -match '\-(\d+)$')
40+
{
41+
$FirmwareVersionNumber = [int]($Matches[1])
42+
}
43+
else
44+
{
45+
Write-Error ('::error title=Invalid firmware number::Error during execution this tags {0}' -f $FirmwareVersionNumber)
46+
exit 1
47+
}
48+
if ($FirmwareVersion -match '\-(\d+)$')
49+
{
50+
$StoredFirmwareVersionNumber = [int]($Matches[1])
51+
}
52+
else
53+
{
54+
Write-Error ('::error title=Invalid STORED firmware number::Error during execution this version {0}' -f $FirmwareVersion)
55+
exit 1
56+
}
57+
$Delta = ( [DateTime]::Now - [DateTime]::Parse($Release[3]))
58+
Write-Host "FirmwareVersionNumber: $FirmwareVersionNumber, Delta: $Delta"
59+
#exit 0
60+
61+
$NewVersionFw = $false
62+
Write-Host ('Latest firmware {0}' -f $FirmwareVersionNumber)
63+
64+
$Output.REMOTE_TAG_INFO = Write-Host ('[{0}]({1}/releases/tag/{2})' `
65+
-f $LatestFirmware, $RepoUnleashed, $LatestFirmware)
66+
if (($FirmwareVersionNumber -gt $StoredFirmwareVersionNumber) -and ( $Delta -gt [TimeSpan]::FromMinutes(10)))
67+
{
68+
$Output.REMOTE_TAG_INFO = $LatestFirmware
69+
$NewVersionFw = $true
70+
}
71+
elseif ($FirmwareVersionNumber -lt $StoredFirmwareVersionNumber)
72+
{
73+
Write-Error ('::error title=Invalid check of stored::Version in repo: {0}, but we think it is {1}' `
74+
-f $FirmwareVersionNumber, $StoredFirmwareVersionNumber)
75+
exit 1
76+
}
77+
78+
$PublishDates = (gh api -H "Accept: application/vnd.github+json" `
79+
-H "X-GitHub-Api-Version: 2022-11-28" "/repos/$( $RepoSelf )/releases?per_page=1" `
80+
| ConvertFrom-Json | Select-Object published_at, created_at)
81+
$LastPublished = ($null -eq $PublishDates.published_at ? $PublishDates.created_at : $PublishDates.published_at)
82+
$Delta = ([DateTime]::Now - $LastPublished)
83+
84+
$Release = (gh api -H "Accept: application/vnd.github+json" `
85+
-H "X-GitHub-Api-Version: 2022-11-28" "/repos/$( $RepoSelf )/tags?per_page=1" `
86+
| ConvertFrom-Json).name
87+
Write-Host ('Release {0}' -f $Release) -ForegroundColor Gray -BackgroundColor Blue
88+
$LatestTag = $Release.Substring(1)
89+
90+
$CurrentVersion = [version]::Parse($ReleaseVersion)
91+
$ParsedRepoVersion = [version]::Parse($LatestTag)
92+
93+
Write-Host ('Current tag:Repos tag {0}, {1}' -f $CurrentVersion, $ParsedRepoVersion) `
94+
-ForegroundColor Gray -BackgroundColor Blue
95+
Write-Debug ('::debug Current tag:Repos tag {0}, {1}' -f $CurrentVersion, $ParsedRepoVersion)
96+
97+
if (($CurrentVersion -lt $ParsedRepoVersion) -and ( $Delta -gt [TimeSpan]::FromMinutes(10)))
98+
{
99+
$Tag = ('{0}.{1}.{2}' -f $ParsedRepoVersion.Major, $ParsedRepoVersion.Minor, $ParsedRepoVersion.Build)
100+
101+
$Output.RELEASE_VERSION = $Tag
102+
$Output.RELEASE_TYPE = 2
103+
104+
Write-Host ('::warning title=New release!::Release {0}' -f $Tag)
105+
}
106+
elseif ( $NewVersionFw )
107+
{
108+
$Tag = ('{0}.{1}.{2}' -f $CurrentVersion.Major, $CurrentVersion.Minor, ($CurrentVersion.Build + 1))
109+
110+
$Output.RELEASE_VERSION = $Tag
111+
$Output.RELEASE_TYPE = 1
112+
113+
Write-Host ('::warning title=Firmware was changed!::New version is {0}, need to create release {1}' -f $LatestFirmware, $Tag)
114+
}
115+
elseif ( ($Delta -gt [TimeSpan]::FromMinutes(10)) -and ($CurrentVersion -gt $ParsedRepoVersion))
116+
{
117+
Write-Host ('::warning title=Invalid version!::Version in settings: {0}, but repo version is {1}. Going to change variable' `
118+
-f $CurrentVersion, $ParsedRepoVersion)
119+
120+
$Output.RELEASE_VERSION = $ParsedRepoVersion
121+
$Output.RELEASE_TYPE = 3
122+
}
123+
else
124+
{
125+
# none to release
126+
Write-Host 'No new versions, sorry'
127+
}
128+
129+
$Output.CURRENT_TAG = $LatestTag
130+
131+
if($ForGithubActions) {
132+
$Plain = New-Object -TypeName "System.Text.StringBuilder";
133+
$Output.GetEnumerator() | ForEach-Object {
134+
[void]$Plain.Append($_.Key)
135+
[void]$Plain.Append('=')
136+
[void]$Plain.AppendLine($_.Value)
137+
}
138+
Write-Output $Plain.ToString()
139+
} else {
140+
$Output
141+
}

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
required: false
1010
type: string
1111
release:
12-
types: [created,prereleased]
12+
types: [ created,prereleased ]
1313
push:
1414
paths:
1515
- .github/workflows/build-with-firmware.yml
@@ -20,14 +20,13 @@ permissions:
2020

2121
jobs:
2222
build-and-upload:
23-
# runs-on: [self-hosted, linux]
2423
runs-on: ubuntu-latest
2524
concurrency:
2625
group: firmware-build-${{ vars.FIRMWARE_VERSION }}-${{ vars.RELEASE_VERSION }}
2726
cancel-in-progress: false
2827
env:
2928
REPO_SELF: ${{ vars.REPO_SELF }}
30-
IGNORED_PATH: "applications_user/subbrute"
29+
OFW_PATH: "applications_user/subbrute"
3130
RELATIVE_PATH: "applications/external/subbrute"
3231
CURRENT_VERSION: ${{ vars.RELEASE_VERSION }}
3332
RELEASE_VERSION: ${{ vars.RELEASE_VERSION }}
@@ -38,15 +37,16 @@ jobs:
3837
strategy:
3938
fail-fast: false
4039
matrix:
41-
firmware: [unlshd]
40+
firmware: [ unlshd ]
4241
include:
4342
- firmware: unlshd
4443
url: ${{ vars.REPO_UNLEASHED }}
4544
version: ${{ vars.FIRMWARE_VERSION }}
46-
src-included: 1
47-
#- firmware: official
48-
# url: ${{ vars.REPO_OFFICIAL }}
49-
# version: "official"
45+
src-included: 0
46+
- firmware: official
47+
url: ${{ vars.REPO_OFFICIAL }}
48+
version: "official"
49+
src-included: 0
5050
steps:
5151
- name: Set version
5252
env:
@@ -72,7 +72,7 @@ jobs:
7272
repository: "${{ vars.REPO_SELF }}"
7373
clean: "true"
7474
submodules: "true"
75-
path: "${{ env.IGNORED_PATH }}"
75+
path: "${{ env.OFW_PATH }}"
7676

7777
- name: Print vars about state or repo if Unleashed
7878
if: ${{ matrix.src-included == 1 }}
@@ -81,7 +81,7 @@ jobs:
8181
git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1
8282
git submodule set-branch --branch master '${{ env.RELATIVE_PATH }}'
8383
git submodule sync '${{ env.RELATIVE_PATH }}'
84-
cd '${{ env.RELATIVE_PATH }}'
84+
cd '${{ env.OFW_PATH }}'
8585
if ( '${{ env.CURRENT_VERSION }}' -ne '${{ env.RELEASE_VERSION }}' ) {
8686
Write-Output '::warning title=Different version::Current version is ${{ env.CURRENT_VERSION }} but we trying to build ${{ env.RELEASE_VERSION }}'
8787
git checkout tags/v${{ env.RELEASE_VERSION }} -b tmp-build
@@ -105,7 +105,7 @@ jobs:
105105
shell: pwsh
106106
run: |
107107
git log --pretty=format:'%s by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local --abbrev-commit --max-count=1
108-
cd '${{ env.IGNORED_PATH }}'
108+
cd '${{ env.OFW_PATH }}'
109109
110110
if ( '${{ env.CURRENT_VERSION }}' -ne '${{ env.RELEASE_VERSION }}' ) {
111111
Write-Output '::warning title=Different version::Current version is ${{ env.CURRENT_VERSION }} but we trying to build ${{ env.RELEASE_VERSION }}'
@@ -137,17 +137,17 @@ jobs:
137137
# key: 'fbt=${{ env.FIRMWARE_VERSION }}'
138138
#
139139
- name: Remove other apps
140-
shell: bash
140+
shell: pwsh
141141
if: ${{ success() }}
142-
# rm to remove problem FAP which includes non existent files
142+
# rm to remove problem FAP which includes non-existent files
143143
run: |
144-
rm -Rf ./applications/debug ./applications/examples
145-
mkdir ./tmp
146-
mv ./applications/external/application.fam ./tmp/
147-
mv -f ./applications/external/subbrute/ ./tmp/
148-
rm -Rf ./applications/external/*
149-
mv -f ./tmp/* ./applications/external/
150-
rm -Rf ./tmp/
144+
Remove-Item -Force -Recurse ./applications/debug -ErrorAction SilentlyContinue
145+
Remove-Item -Force -Recurse ./applications/examples -ErrorAction SilentlyContinue
146+
# New-Item -Force ./tmp -ItemType Directory -ErrorAction SilentlyContinue
147+
# Copy-Item -Force -Recurse ./applications/external/subbrute/ ./tmp/ -ErrorAction SilentlyContinue
148+
# Remove-Item -Force -Recurse ./applications/external/* -ErrorAction SilentlyContinue
149+
# Copy-Item -Force -Recurse /tmp/* ./applications/external/ -ErrorAction SilentlyContinue
150+
# Remove-Item -Force -Recurse ./tmp -ErrorAction SilentlyContinue
151151

152152
- name: Build Firmware
153153
shell: bash
@@ -166,7 +166,7 @@ jobs:
166166
FBT_NO_SYNC: 0
167167
DIST_SUFFIX: ${{ matrix.version }}
168168
WORKFLOW_BRANCH_OR_TAG: release-cfw
169-
# rm to remove problem FAP which includes non existent files
169+
# rm to remove problem FAP which includes non-existent files
170170
run: |
171171
./fbt COMPACT=1 DEBUG=0 FBT_NO_SYNC=0 fap_dist
172172

0 commit comments

Comments
 (0)