From 2e7f5cfd3551bf6892d38ca7f03d2551ec499678 Mon Sep 17 00:00:00 2001 From: Grigory Date: Mon, 13 Nov 2023 00:55:01 +0500 Subject: [PATCH 1/5] refactor: rewrite release script --- release.ps1 | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++ task.ps1 | Bin 6284 -> 0 bytes 2 files changed, 152 insertions(+) create mode 100644 release.ps1 delete mode 100644 task.ps1 diff --git a/release.ps1 b/release.ps1 new file mode 100644 index 0000000000..314c8bd4a7 --- /dev/null +++ b/release.ps1 @@ -0,0 +1,152 @@ +#Requires -Version 5.1 +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$ErrorActionPreference = 'Stop' + +#region Functions +function Format-Code { + [CmdletBinding()] + param() + begin { + Write-Verbose -Message 'Formatting the code...' -Verbose + } + process { + prettier --write 'Extensions\*.js' 'jsHelper\*.js' 'CustomApps\*\*{.js,.css}' + gofmt -w -s -l . + } + end { + Write-Host -Object 'Success ✔' -ForegroundColor 'Green' + } +} + +function New-ReleaseArchive { + [CmdletBinding()] + param ( + [Parameter(Mandatory)] + [version]$Version, + + [Parameter(Mandatory)] + [ValidateSet('amd64', '386', 'arm64')] + [string]$Architecture, + + [Parameter(Mandatory)] + [ValidateSet('darwin', 'linux', 'windows')] + [string]$TargetOS + ) + process { + $env:GOARCH = $Architecture + $env:GOOS = $TargetOS + + if ($TargetOS -eq 'windows') { + $binaryFormat = '.exe' + $archiveFormat = '.zip' + $archiveCompresson = '-mx9' + if ($Architecture -eq '386') { + $visualArchitecture = 'x32' + } + else { + $visualArchitecture = 'x64' + } + } + else { + $archiveFormat = '.tar' + $finalArchiveFormat = '.tar.gz' + $finalArchiveCompresson = '-mx9' + $visualArchitecture = $Architecture + } + + $targetVariant = "$TargetOS-$visualArchitecture" + $compiledBinaryPath = "bin\$targetVariant\spicetify$binaryFormat" + $fileList = @(".\bin\$targetVariant\*", 'CustomApps', 'Extensions', 'Themes', 'jsHelper', 'globals.d.ts', 'css-map.json') + $archivePath = "bin\spicetify-$targetVariant$archiveFormat" + $finalArchivePath = "bin\spicetify-$targetVariant$finalArchiveFormat" + + Write-Verbose -Message "Building a binary for $targetVariant..." -Verbose + go build -ldflags "-X main.version=$Version" -o $compiledBinaryPath + + Write-Verbose -Message "Creating an archive for $targetVariant..." -Verbose + 7z a -bb0 $archiveCompresson $archivePath $fileList >$null 2>&1 + if ($TargetOS -ne 'windows') { + 7z a -bb0 -sdel $finalArchiveCompresson $finalArchivePath $archivePath >$null 2>&1 + } + } + end { + Write-Host -Object 'Success ✔' -ForegroundColor 'Green' + } +} + +function New-ReleaseArchives { + [CmdletBinding()] + param ( + [Parameter(Mandatory)] + [ValidateScript({ $PSItem -ge 0 })] + [int]$Major, + + [Parameter(Mandatory)] + [ValidateScript({ $PSItem -ge 0 })] + [int]$Minor, + + [Parameter(Mandatory)] + [ValidateScript({ $PSItem -ge 0 })] + [int]$Patch + ) + begin { + $variants = @( + @{ + os = 'linux' + architectures = @('amd64') + }, + @{ + os = 'darwin' + architectures = @('amd64', 'arm64') + }, + @{ + os = 'windows' + architectures = @('amd64', '386') + } + ) + + $version = "$Major.$Minor.$Patch" + + if (Test-Path -Path 'bin') { + Remove-Item -Path 'bin' -Recurse -Force + } + + Write-Verbose -Message 'Creating release archives...' -Verbose + } + process { + foreach ($variant in $variants) { + foreach ($architecture in $variant.architectures) { + New-ReleaseArchive -Version $version -Architecture $architecture -TargetOS $variant.os + } + } + } + end { + Write-Host -Object 'Release archives has been created ✔' -ForegroundColor 'Green' + } +} + +function Remove-TempFolders { + [CmdletBinding()] + param() + begin { + Write-Verbose -Message 'Cleaning Up...' -Verbose + } + process { + Get-ChildItem -Path 'bin' -Directory | Remove-Item -Recurse -Force + } + end { + Write-Host -Object 'Success ✔' -ForegroundColor 'Green' + } +} +#endregion Functions + +#region Main +$curentVersion = (Invoke-RestMethod -Uri 'https://api.github.com/repos/spicetify/spicetify-cli/releases/latest').tag_name +Write-Host -Object "Current version: $curentVersion" -ForegroundColor 'White' +Write-Host -Object 'Unless the CSS Map has had major changes, please bump patch.' -ForegroundColor 'Yellow' + +Format-Code +New-ReleaseArchives + +Remove-TempFolders +#endregion Main diff --git a/task.ps1 b/task.ps1 deleted file mode 100644 index af0a21b2668ba79bbaeaed0ea53eddc16721c835..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6284 zcmeI0TW=dh6vxjq5^sEfm1{wbvQA4;fk;7W3vH>0ifBua8iag{?UJ}=?U1x3-;;+v z_hSIR|BN@D_0Fbo9BvV^);l{h=YE+v=a1j(*0BT2>^tl6pV%hPS2nU=?798KTx#3= zx9wa0e`aUTCN^bHYEKyT?6$Rd55e*cqs)y*)@Mh}2JD>Ln7IvG=htF9v?i-V<_BPF z^VNaUKC2nn#*8P7CvInlnJIgB?L~Ah1$K{h54*>1@gfe_nQsB>xvjy?uRM3aF3BY6 z)b8>x%Bej7LM!juJ4l;3?j-qr$Bm?|0V^$u#}Tl}42vWeY9N zlzNVWsO*Am1ox6o@QHoF$ZPhM+m$e<-x$cuK__;#u#)e1I@7$TAel3EZUHm0F8@;~ zWN6Uaw$69v?AWj$>?u?w&vm=WR~;T(_RQ^H`x|J9ws`yNX-SJy^gSp@)o@?3N3P5I zf?d7NYG~$aK|2lnHlNF-n9t3rHSmif{@fFMyygCr(<%FX3LWpU`Q9Q%VGk*kJ*$ni zhr~nI$8%gqSi!Xw;u zc=23>oFA90p~#olKc4MQou?~vh<=kOZ#&wxQ>0Pe+J~xin3CBPAN#Yog3>I-PEm)uqHf5O&yJrvW7If~ANpcG-O1lo$+cBh5m3wZV*g~3CZvEQH zePBn7y$+NmUbs9IVl49V&>o%ep}aW)@6pUdL#WX9p`MjhbEsI3E=%-@y@XanM|1C1CPN+Hbm*_-ZGGf+e=Wz8g z-X{-||IT5a@pYfMJ#Z=i`jtN4&yl*tdxF1qd8Q|D9YzzRQUr}z5e}UNg8iHrk#+X? zCH4{D?~|iL8^tu6f&cIyz~imCI(pibw^4qZ%@W2ZU_L%55I z!y?YN*)ZIFwpa`y*6sgjR32R?%5|@(&Um5LVtTHM#}ICHD*v6B+;*|lCCU%Uh3Ab+ zACWnhWg@c(8H>#(S?P$Uj5VIo&zHrEe56p+ZKX->9&*;mp2btRxc~CSXH`~T{k*t> zE^lx`FMkufVV`1^vL96OT0Vic7rZ^>0CDdkLmj&DyEqB{AsK1Uq;r6*Gw_E%P5uyx3eY@7$ETPree{M-%Fr z7CTO3SB0rZJmf~Cx-8{)$VfdE^<E{`H{h z1#6#PqpEsU$*RkPg7*QLrk+j;jV)+O|v@FqHYLOme}br%w(P`^UG??ac% uy}P_+A>a8;T%T0kRsM9$?a@4V|RJ^Tp`KDuTA From 01d663bd826b212513213f398a24193d2abd2dbb Mon Sep 17 00:00:00 2001 From: Grigory Date: Mon, 13 Nov 2023 01:11:17 +0500 Subject: [PATCH 2/5] rename `TargetOS` var to `OS` --- release.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/release.ps1 b/release.ps1 index 314c8bd4a7..584b30a6fc 100644 --- a/release.ps1 +++ b/release.ps1 @@ -30,13 +30,13 @@ function New-ReleaseArchive { [Parameter(Mandatory)] [ValidateSet('darwin', 'linux', 'windows')] - [string]$TargetOS + [string]$OS ) process { $env:GOARCH = $Architecture - $env:GOOS = $TargetOS + $env:GOOS = $OS - if ($TargetOS -eq 'windows') { + if ($OS -eq 'windows') { $binaryFormat = '.exe' $archiveFormat = '.zip' $archiveCompresson = '-mx9' @@ -54,7 +54,7 @@ function New-ReleaseArchive { $visualArchitecture = $Architecture } - $targetVariant = "$TargetOS-$visualArchitecture" + $targetVariant = "$OS-$visualArchitecture" $compiledBinaryPath = "bin\$targetVariant\spicetify$binaryFormat" $fileList = @(".\bin\$targetVariant\*", 'CustomApps', 'Extensions', 'Themes', 'jsHelper', 'globals.d.ts', 'css-map.json') $archivePath = "bin\spicetify-$targetVariant$archiveFormat" @@ -65,7 +65,7 @@ function New-ReleaseArchive { Write-Verbose -Message "Creating an archive for $targetVariant..." -Verbose 7z a -bb0 $archiveCompresson $archivePath $fileList >$null 2>&1 - if ($TargetOS -ne 'windows') { + if ($OS -ne 'windows') { 7z a -bb0 -sdel $finalArchiveCompresson $finalArchivePath $archivePath >$null 2>&1 } } @@ -116,7 +116,7 @@ function New-ReleaseArchives { process { foreach ($variant in $variants) { foreach ($architecture in $variant.architectures) { - New-ReleaseArchive -Version $version -Architecture $architecture -TargetOS $variant.os + New-ReleaseArchive -Version $version -Architecture $architecture -OS $variant.os } } } From 25344e3c72b695d69cf5253aedae9660bf2a41fa Mon Sep 17 00:00:00 2001 From: Grigory Date: Mon, 13 Nov 2023 01:14:06 +0500 Subject: [PATCH 3/5] nonsense style changes --- release.ps1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/release.ps1 b/release.ps1 index 584b30a6fc..8b8b5e14d3 100644 --- a/release.ps1 +++ b/release.ps1 @@ -90,6 +90,8 @@ function New-ReleaseArchives { [int]$Patch ) begin { + $version = "$Major.$Minor.$Patch" + $variants = @( @{ os = 'linux' @@ -105,15 +107,12 @@ function New-ReleaseArchives { } ) - $version = "$Major.$Minor.$Patch" - if (Test-Path -Path 'bin') { Remove-Item -Path 'bin' -Recurse -Force } - - Write-Verbose -Message 'Creating release archives...' -Verbose } process { + Write-Verbose -Message 'Creating release archives...' -Verbose foreach ($variant in $variants) { foreach ($architecture in $variant.architectures) { New-ReleaseArchive -Version $version -Architecture $architecture -OS $variant.os From e43259a31a1f53193b74f1d0842bcda12adda1c2 Mon Sep 17 00:00:00 2001 From: Grigory Date: Mon, 13 Nov 2023 01:16:01 +0500 Subject: [PATCH 4/5] even more nonsense --- release.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release.ps1 b/release.ps1 index 8b8b5e14d3..d3be486f57 100644 --- a/release.ps1 +++ b/release.ps1 @@ -5,7 +5,7 @@ $ErrorActionPreference = 'Stop' #region Functions function Format-Code { [CmdletBinding()] - param() + param () begin { Write-Verbose -Message 'Formatting the code...' -Verbose } @@ -126,7 +126,7 @@ function New-ReleaseArchives { function Remove-TempFolders { [CmdletBinding()] - param() + param () begin { Write-Verbose -Message 'Cleaning Up...' -Verbose } From cb07a4f5a0bc1acbbbdecc7f6c578acb19a5518e Mon Sep 17 00:00:00 2001 From: Grigory Date: Mon, 13 Nov 2023 01:25:33 +0500 Subject: [PATCH 5/5] Delete release.ps1 --- release.ps1 | 151 ---------------------------------------------------- 1 file changed, 151 deletions(-) delete mode 100644 release.ps1 diff --git a/release.ps1 b/release.ps1 deleted file mode 100644 index d3be486f57..0000000000 --- a/release.ps1 +++ /dev/null @@ -1,151 +0,0 @@ -#Requires -Version 5.1 -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -$ErrorActionPreference = 'Stop' - -#region Functions -function Format-Code { - [CmdletBinding()] - param () - begin { - Write-Verbose -Message 'Formatting the code...' -Verbose - } - process { - prettier --write 'Extensions\*.js' 'jsHelper\*.js' 'CustomApps\*\*{.js,.css}' - gofmt -w -s -l . - } - end { - Write-Host -Object 'Success ✔' -ForegroundColor 'Green' - } -} - -function New-ReleaseArchive { - [CmdletBinding()] - param ( - [Parameter(Mandatory)] - [version]$Version, - - [Parameter(Mandatory)] - [ValidateSet('amd64', '386', 'arm64')] - [string]$Architecture, - - [Parameter(Mandatory)] - [ValidateSet('darwin', 'linux', 'windows')] - [string]$OS - ) - process { - $env:GOARCH = $Architecture - $env:GOOS = $OS - - if ($OS -eq 'windows') { - $binaryFormat = '.exe' - $archiveFormat = '.zip' - $archiveCompresson = '-mx9' - if ($Architecture -eq '386') { - $visualArchitecture = 'x32' - } - else { - $visualArchitecture = 'x64' - } - } - else { - $archiveFormat = '.tar' - $finalArchiveFormat = '.tar.gz' - $finalArchiveCompresson = '-mx9' - $visualArchitecture = $Architecture - } - - $targetVariant = "$OS-$visualArchitecture" - $compiledBinaryPath = "bin\$targetVariant\spicetify$binaryFormat" - $fileList = @(".\bin\$targetVariant\*", 'CustomApps', 'Extensions', 'Themes', 'jsHelper', 'globals.d.ts', 'css-map.json') - $archivePath = "bin\spicetify-$targetVariant$archiveFormat" - $finalArchivePath = "bin\spicetify-$targetVariant$finalArchiveFormat" - - Write-Verbose -Message "Building a binary for $targetVariant..." -Verbose - go build -ldflags "-X main.version=$Version" -o $compiledBinaryPath - - Write-Verbose -Message "Creating an archive for $targetVariant..." -Verbose - 7z a -bb0 $archiveCompresson $archivePath $fileList >$null 2>&1 - if ($OS -ne 'windows') { - 7z a -bb0 -sdel $finalArchiveCompresson $finalArchivePath $archivePath >$null 2>&1 - } - } - end { - Write-Host -Object 'Success ✔' -ForegroundColor 'Green' - } -} - -function New-ReleaseArchives { - [CmdletBinding()] - param ( - [Parameter(Mandatory)] - [ValidateScript({ $PSItem -ge 0 })] - [int]$Major, - - [Parameter(Mandatory)] - [ValidateScript({ $PSItem -ge 0 })] - [int]$Minor, - - [Parameter(Mandatory)] - [ValidateScript({ $PSItem -ge 0 })] - [int]$Patch - ) - begin { - $version = "$Major.$Minor.$Patch" - - $variants = @( - @{ - os = 'linux' - architectures = @('amd64') - }, - @{ - os = 'darwin' - architectures = @('amd64', 'arm64') - }, - @{ - os = 'windows' - architectures = @('amd64', '386') - } - ) - - if (Test-Path -Path 'bin') { - Remove-Item -Path 'bin' -Recurse -Force - } - } - process { - Write-Verbose -Message 'Creating release archives...' -Verbose - foreach ($variant in $variants) { - foreach ($architecture in $variant.architectures) { - New-ReleaseArchive -Version $version -Architecture $architecture -OS $variant.os - } - } - } - end { - Write-Host -Object 'Release archives has been created ✔' -ForegroundColor 'Green' - } -} - -function Remove-TempFolders { - [CmdletBinding()] - param () - begin { - Write-Verbose -Message 'Cleaning Up...' -Verbose - } - process { - Get-ChildItem -Path 'bin' -Directory | Remove-Item -Recurse -Force - } - end { - Write-Host -Object 'Success ✔' -ForegroundColor 'Green' - } -} -#endregion Functions - -#region Main -$curentVersion = (Invoke-RestMethod -Uri 'https://api.github.com/repos/spicetify/spicetify-cli/releases/latest').tag_name -Write-Host -Object "Current version: $curentVersion" -ForegroundColor 'White' -Write-Host -Object 'Unless the CSS Map has had major changes, please bump patch.' -ForegroundColor 'Yellow' - -Format-Code -New-ReleaseArchives - -Remove-TempFolders -#endregion Main