-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrc.ps1
55 lines (42 loc) · 1.38 KB
/
src.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
<#
.SYNOPSIS
Script for bundling current repo into .zip file, excluding .gitignore files
.EXAMPLE
./script.ps1 -p "publish" -continious-tag "continious" -b "Directory.Build.props"
.LINK
https://github.com/Gigas002/dotnet_gh_deploy
https://git-scm.com/docs/git-archive
#>
[CmdletBinding(PositionalBinding = $false)]
param (
# publish path
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("p", "publish-path")]
[string] $publishPath = "artifacts/publish",
# continious tag
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("continious-tag")]
[string] $continiousTag = "continious",
# Directory.Build.props path
[Parameter ()]
[ValidateNotNullOrEmpty ()]
[Alias("b", "build-props-path")]
[string] $buildPropsPath = "Directory.Build.props"
)
#region Constants
Set-Variable ArchiveName -Option ReadOnly -Value "src"
#endregion
Write-Host "Started compressing the repo into .zip..." -ForegroundColor Yellow
$versionPrefix, $versionSuffix, $_, $_ = ./read_version.ps1 -b $buildPropsPath
if ("$versionSuffix") {
$version = "$continiousTag"
}
else {
$version = "v$versionPrefix"
}
New-Item -Path "$publishPath" -Type Directory -Force
$output = "$publishPath/$ArchiveName-$version.zip"
git archive HEAD -o "$output" --worktree-attributes -v
Write-Host "Finished compressing the repo into $output.zip" -ForegroundColor Green