-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
BUILD.ps1
64 lines (61 loc) · 3.15 KB
/
BUILD.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
62
63
64
##$repoName = "Manga-Manager"
##$ownerName = "MangaManagerOrg"
### Get the latest release
##$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/$ownerName/$repoName/releases/latest"
### Get the branch or tag name of the commit where the latest release is tied to
##$latestReleaseBranchOrTagName = $latestRelease.target_commitish
### Get the short hash of the commit where the latest release is tied to
##$latestReleaseCommitHash = git rev-parse --short $latestReleaseBranchOrTagName
### Get the short hash of the latest commit in the develop branch
##$latestDevelopHash = git rev-parse --short develop
##
##$content = Get-Content .\MangaManager\src\__version__.py
##if ($content -match '(?<=__version__ = ")[^:"]+') {
## $newContent = $content -replace '__version__ = ".*"', "__version__ = `"$versionNumber:nightly--$latestReleaseCommitHash->$latestDevelopHash`""
## $newContent | Set-Content .\MangaManager\src\__version__.py
##}
##Write-Output $newContent
#$repoName = "Manga-Manager"
#$ownerName = "MangaManagerOrg"
## Get the latest release
#$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/$ownerName/$repoName/releases/latest"
## Get the branch or tag name of the commit where the latest release is tied to
#$latestReleaseBranchOrTagName = $latestRelease.target_commitish
## Get the short hash of the commit where the latest release is tied to
#$latestReleaseCommitHash = git rev-parse --short $latestReleaseBranchOrTagName
## Get the short hash of the latest commit in the develop branch
#$latestDevelopHash = git rev-parse --short develop
#
#$content = Get-Content .\MangaManager\src\__version__.py
#$versionRegex = '(?<=__version__ = ")[^:"]+'
#if ($content -match $versionRegex) {
# $versionNumber = $matches[0]
# $newContent = $content -replace '__version__ = ".*"', "__version__ = `"$versionNumber:nightly--$latestReleaseCommitHash->$latestDevelopHash`""
# $newContent | Set-Content .\MangaManager\src\__version__.py
#}
#Write-Output $newContent
$repoName = "Manga-Manager"
$ownerName = "MangaManagerOrg"
# Get the latest release
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/$ownerName/$repoName/releases/latest"
# Get the branch or tag name of the commit where the latest release is tied to
$latestReleaseBranchOrTagName = $latestRelease.target_commitish
# Get the short hash of the commit where the latest release is tied to
$latestReleaseCommitHash = git rev-parse --short $latestReleaseBranchOrTagName
# Get the short hash of the latest commit in the develop branch
$latestDevelopHash = git rev-parse --short develop
$content = Get-Content .\MangaManager\src\__version__.py
$versionFile = ".\MangaManager\src\__version__.py"
# Read the current contents of the version file
$content = Get-Content $versionFile
# Update the commit hashes in the version file
$content | ForEach-Object {
if ($_ -match "^__version__ = '.*:stable$'") {
$_ -replace "(?<=[^-])-?[0-9a-f]{7,}?(?=-|->)", $latestReleaseCommitHash
} elseif ($_ -match "^__version__ = '.*:nightly$'") {
$_ -replace "(?<=[^-])-?[0-9a-f]{7,}?(?=-|->)", $latestDevelopHash
} else {
$_
}
} | Set-Content $versionFile
Write-Output $content