-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackingCpanPackage.ps1
47 lines (46 loc) · 2.05 KB
/
PackingCpanPackage.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
function GetVersionFromMETA {
param (
[Parameter(ValueFromPipelineByPropertyName=$true)]
[String]
$File = $(throw "Parameter missing: - File.")
)
$NeedGet = $false
if( Test-Path $File){
(Get-Content $File ) | Foreach-Object {
if ($_ -match "/CellsApi.pm") {
$NeedGet = $true
}if($NeedGet -and $_ -match "version" ){
if( $_ -match "\d+.\d+.\d+"){
$NeedGet = $false
return $matches[0]
}
if( $_ -match "\d+.\d+"){
$NeedGet = $false
return $matches[0]
}
}
}
}
return `Get-Date -Format yy.M`
}
$APIVersion = "{0}" -f (GetVersionFromMETA "./META.json")
New-Item -Path "temp" -ItemType Directory
$packageFolder = "AsposeCellsCloud-CellsApi-{0}" -f $APIVersion
New-Item -Path "temp/$packageFolder/" -ItemType Directory
Copy-Item -Path "docs" -Destination "temp/$packageFolder/docs" -Recurse
Copy-Item -Path "lib" -Destination "temp/$packageFolder/lib" -Recurse
Copy-Item -Path "Build.PL" -Destination "temp/$packageFolder/Build.PL"
Copy-Item -Path "Makefile.PL" -Destination "temp/$packageFolder/Makefile.PL"
Copy-Item -Path "MANIFEST" -Destination "temp/$packageFolder/MANIFEST"
Copy-Item -Path "META.json" -Destination "temp/$packageFolder/META.json"
Copy-Item -Path "META.yml" -Destination "temp/$packageFolder/META.yml"
Copy-Item -Path "README.md" -Destination "temp/$packageFolder/README.md"
$null = Set-Location .\temp
tar -czvf "$packageFolder.tar.gz" $packageFolder
Move-Item "$packageFolder.tar.gz" ../packages/
Set-Location ../
Remove-Item -Path "temp" -Recurse
# Compress-7Zip -ArchiveFileName "$packageFolder.tar" -Path "temp" -Format Tar
# Compress-7Zip -ArchiveFileName "packages/$packageFolder.tar.gz" -Path "$packageFolder.tar" -Format GZip
# Remove-Item -Path "temp" -Recurse
# Remove-Item -Path "$packageFolder.tar"