File: build.ps1

package info (click to toggle)
sigil 2.4.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 35,928 kB
  • sloc: cpp: 78,479; python: 61,153; ansic: 31,743; javascript: 188; sh: 37; makefile: 21
file content (47 lines) | stat: -rw-r--r-- 1,593 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Param
(
    [parameter(Mandatory = $true)]
    [string] $Version
)

function Write-MetaData {
    param (
        [parameter(Mandatory = $true)]
        [string]
        $FileName,
        [parameter(Mandatory = $true)]
        [string]
        $Version,
        [parameter(Mandatory = $true)]
        [string]
        $HashAmd64
    )
    $content = Get-Content $FileName -Raw
    $content = $content.Replace('<VERSION>', $Version)
    $content = $content.Replace('<HASH-AMD64>', $HashAmd64)
    $date = Get-Date -Format "yyyy-MM-dd"
    $content = $content.Replace('<DATE>', $date)
    $content | Out-File -Encoding 'UTF8' "./$Version/$FileName"
}

New-Item -Path $PWD -Name $Version -ItemType "directory"

# Get hash for installers
Invoke-WebRequest "https://github.com/Sigil-Ebook/Sigil/releases/download/$Version/Sigil-$Version-Windows-x64-Setup.exe" -OutFile 'INSTALLER-AMD64.exe'
$HashAmd64 = (Get-FileHash -Path 'INSTALLER-AMD64.exe' -Algorithm SHA256).Hash

# Update the metadata for the files
Get-ChildItem '*.yaml' | ForEach-Object -Process {
    Write-MetaData -FileName $_.Name -Version $Version -HashAmd64 $HashAmd64
}
if (-not $env:WINGET_TOKEN) {
    Write-Error "You must set the WINGET_TOKEN environment variable to create a pull request."
    Exit 1
}
# Get the latest wingetcreate exe
Invoke-WebRequest 'https://aka.ms/wingetcreate/preview' -OutFile wingetcreate.exe

$prtitle = "New Version: Sigil-Ebook.Sigil version $Version"

# Create the PR
./wingetcreate.exe submit --prtitle $prtitle --token $env:WINGET_TOKEN $Version