
47 changed files with 328 additions and 317 deletions
@ -0,0 +1,50 @@ |
|||
name: Chocolatey push |
|||
|
|||
on: |
|||
workflow_dispatch: |
|||
|
|||
jobs: |
|||
Push: |
|||
name: Push |
|||
runs-on: windows-latest |
|||
steps: |
|||
- name: Checkout Repository |
|||
uses: actions/checkout@main |
|||
|
|||
- name: Getting hashes |
|||
run: | |
|||
. "Scripts\Chocolatey.ps1" |
|||
|
|||
- name: Pack and push to Chocolatey |
|||
run: | |
|||
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/SHA256SUM.json |
|||
$Parameters = @{ |
|||
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/refs/heads/master/SHA256SUM.json" |
|||
UseBasicParsing = $true |
|||
Verbose = $true |
|||
} |
|||
$SHA256SUM = Invoke-RestMethod @Parameters |
|||
|
|||
$Parameters = @{ |
|||
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" |
|||
} |
|||
$Latest_Release = Invoke-RestMethod @Parameters |
|||
|
|||
# Replace variables with script latest versions |
|||
# No need to replace special characters with percent-encoding ones |
|||
(Get-Content -Path "chocolatey\tools\chocolateyinstall.ps1" -Encoding utf8 -Raw) | Foreach-Object -Process { |
|||
$_ -replace "Hash_Sophia_Script_Windows_10_PowerShell_5_1", $SHA256SUM."Sophia.Script.for.Windows.10.v$($Latest_Release.Sophia_Script_Windows_10_PowerShell_5_1).zip" ` |
|||
-replace "Hash_Sophia_Script_Windows_10_PowerShell_7", $SHA256SUM."Sophia.Script.for.Windows.10.PowerShell.7.v$($Latest_Release.Sophia_Script_Windows_10_PowerShell_7).zip" ` |
|||
-replace "Hash_Sophia_Script_Windows_10_LTSC2019", $SHA256SUM."Sophia.Script.for.Windows.10.LTSC.2019.v$($Latest_Release.Sophia_Script_Windows_10_LTSC2019).zip" ` |
|||
-replace "Hash_Sophia_Script_Windows_10_LTSC2021", $SHA256SUM."Sophia.Script.for.Windows.10.LTSC.2021.v$($Latest_Release.Sophia_Script_Windows_10_LTSC2021).zip" ` |
|||
-replace "Hash_Sophia_Script_Windows_11_PowerShell_5_1", $SHA256SUM."Sophia.Script.for.Windows.11.v$($env:Latest_Release_Windows_11_PowerShell_5_1).zip" ` |
|||
-replace "Hash_Sophia_Script_Windows_11_PowerShell_7", $SHA256SUM."Sophia.Script.for.Windows.11.PowerShell.7.v$($Latest_Release.Sophia_Script_Windows_11_PowerShell_7).zip" ` |
|||
-replace "Hash_Sophia_Script_Windows_11_LTSC2024", $SHA256SUM."Sophia.Script.for.Windows.11.LTSC.2024.v$($Latest_Release.Sophia_Script_Windows_11_LTSC2024).zip" ` |
|||
-replace "Hash_Sophia_Script_Wrapper", $SHA256SUM."Sophia.Script.Wrapper.v$($Latest_Release.Sophia_Script_Wrapper).zip" |
|||
} | Set-Content -Path "chocolatey\tools\chocolateyinstall.ps1" -Encoding utf8 -Force |
|||
|
|||
choco pack chocolatey\sophia.nuspec --outputdirectory chocolatey |
|||
choco apikey --key ${{ secrets.CHOCOLATEY_SECRET }} --source https://push.chocolatey.org/ |
|||
[xml]$Version = Get-Content -Path chocolatey\sophia.nuspec |
|||
[string]$Version = $Version.package.metadata.version |
|||
choco push chocolatey\sophia.$Version.nupkg --source https://push.chocolatey.org/ --yes |
@ -0,0 +1,42 @@ |
|||
# Get a penultimate build tag |
|||
$Headers = @{ |
|||
Accept = "application/vnd.github+json" |
|||
Authorization = "Bearer $env:GITHUB_TOKEN" |
|||
} |
|||
$Parameters = @{ |
|||
Uri = "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases" |
|||
Headers = $Headers |
|||
UseBasicParsing = $true |
|||
Verbose = $true |
|||
} |
|||
$Penultimate = (Invoke-RestMethod @Parameters).tag_name | Select-Object -Index 1 |
|||
|
|||
# Parse json for the latest script versions |
|||
$Parameters = @{ |
|||
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" |
|||
UseBasicParsing = $true |
|||
Verbose = $true |
|||
} |
|||
$JSON = Invoke-RestMethod @Parameters |
|||
|
|||
# Replace variables with script latest versions |
|||
# No need to replace special characters with percent-encoding ones |
|||
(Get-Content -Path ReleaseNotesTemplate.md -Encoding utf8 -Raw) | Foreach-Object -Process { |
|||
# ${{ github.ref_name }} |
|||
$_ -replace "NewVersion", $env:GITHUB_REF_NAME ` |
|||
-replace "OldVersion", $Penultimate ` |
|||
-replace "Sophia_Script_Windows_10_PowerShell_5_1", $JSON.Sophia_Script_Windows_10_PowerShell_5_1 ` |
|||
-replace "Sophia_Script_Windows_10_PowerShell_7", $JSON.Sophia_Script_Windows_10_PowerShell_7 ` |
|||
-replace "Sophia_Script_Windows_10_LTSC2019", $JSON.Sophia_Script_Windows_10_LTSC2019 ` |
|||
-replace "Sophia_Script_Windows_10_LTSC2021", $JSON.Sophia_Script_Windows_10_LTSC2021 ` |
|||
-replace "Sophia_Script_Windows_11_PowerShell_5_1", $JSON.Sophia_Script_Windows_11_PowerShell_5_1 ` |
|||
-replace "Sophia_Script_Windows_11_PowerShell_7", $JSON.Sophia_Script_Windows_11_PowerShell_7 ` |
|||
-replace "Sophia_Script_Windows_11_LTSC2024", $JSON.Sophia_Script_Windows_11_LTSC2024 ` |
|||
-replace "Sophia_Script_Wrapper", $JSON.Sophia_Script_Wrapper |
|||
} | Set-Content -Path ReleaseNotesTemplate.md -Encoding utf8 -Force |
|||
|
|||
# https://trstringer.com/github-actions-multiline-strings/ |
|||
Add-Content -Path $env:GITHUB_OUTPUT -Value "ReleaseBody=ReleaseNotesTemplate.md" |
|||
|
|||
$ReleaseName = Get-Date -f "dd.MM.yyyy" |
|||
echo "RELEASE_NAME=$ReleaseName" >> $env:GITHUB_ENV |
Loading…
Reference in new issue