forked from ravendb/book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.ps1
61 lines (45 loc) · 1.95 KB
/
release.ps1
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
.\build.ps1 pdf $true
.\build.ps1 epub $false
c:\tools\kindlegen\kindlegen.exe ".\Output\Inside RavenDB 3.0.epub"
$token = Get-Content "$pwd\..\Credentials\github.txt"
$release = "v0.3.5"
$json = Invoke-WebRequest -ErrorAction Stop `
-Uri "https://api.github.com/repos/ayende/book/releases" `
-ContentType "application/json" `
-Method "POST" `
-Headers @{"Authorization" = "token $token"; "Accept" = "application/vnd.github.v3+json"} `
-Body "{
`"tag_name`": `"$release`",
`"target_commitish`": `"master`",
`"name`": `"$release`",
`"body`": `"Preview of the book`",
`"draft`": false,
`"prerelease`": true
}"
if($json -eq $null) {
return
}
$resp = ConvertFrom-Json $json
$id = $resp.id
echo "New release id: $id"
$pdf = [System.IO.File]::ReadAllBytes("$pwd\Output\Inside RavenDB 3.0.pdf")
Echo "Uploading .pdf"
Invoke-WebRequest -Uri "https://uploads.github.com/repos/ayende/book/releases/$id/assets?name=Inside RavenDB 3.0.pdf" `
-Headers @{"Authorization" = "token $token"; "Accept" = "application/vnd.github.v3+json"} `
-ContentType "application/pdf" `
-Method "POST" `
-Body $pdf
Echo "Uploading .epub"
$epub = [System.IO.File]::ReadAllBytes("$pwd\Output\Inside RavenDB 3.0.epub")
Invoke-WebRequest -Uri "https://uploads.github.com/repos/ayende/book/releases/$id/assets?name=Inside RavenDB 3.0.epub" `
-Headers @{"Authorization" = "token $token"; "Accept" = "application/vnd.github.v3+json"} `
-ContentType "application/epub+zip" `
-Method "POST" `
-Body $epub
$mobi = [System.IO.File]::ReadAllBytes("$pwd\Output\Inside RavenDB 3.0.mobi")
Echo "Uploading .mobi"
Invoke-WebRequest -Uri "https://uploads.github.com/repos/ayende/book/releases/$id/assets?name=Inside RavenDB 3.0.mobi" `
-Headers @{"Authorization" = "token $token"; "Accept" = "application/vnd.github.v3+json"} `
-ContentType "application/octet-stream" `
-Method "POST" `
-Body $mobi