-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.ps1
46 lines (36 loc) · 1.3 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
#
# build.ps1
#
# Build and deploy a new version of maxar_catalog by doing the following:
#
# 1. Update the build number maxarcat/version.txt
# 2. Build a new wheel by running python setup.py bdist_wheel
# 3. Run pip install on the new wheel
#
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
function UpdatePackageVersion($VersionFile)
{
Write-Host "Reading $VersionFile"
$Version = Get-Content -Raw $VersionFile
Write-Host "Current Version: $Version"
$Parts = $Version -split '\.'
$Parts[-1] = [String]([Int]$Parts[-1] + 1)
$NewVersion = [String]::Join('.', $Parts)
Write-Host "New Version: $NewVersion"
Write-Host "Writing new version to $VersionFile"
[System.IO.File]::WriteAllText($VersionFile, $NewVersion)
return $NewVersion
}
# Get the repo's toplevel directory, assuming this build.ps1 script is at the top level
$ThisScript = $MyInvocation.MyCommand.Source
$RootDir = Split-Path -Parent $ThisScript
$PackageVersionFile = Join-Path $RootDir 'maxarcat\version.txt'
$NewVersion = UpdatePackageVersion $PackageVersionFile
python setup.py bdist_wheel
if ($LASTEXITCODE -ne 0) {
throw "Python setup error"
}
dir dist
$WheelName = "maxarcat-$NewVersion-py3-none-any.whl"
pip install "dist/$WheelName"