-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzip.ps1
64 lines (53 loc) · 2.25 KB
/
zip.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
$version=Get-Date -Format 'yyyy.MM.dd (hh:mm:ss)'
$versionZ=Get-Date -Format 'yyyy.MM.dd'
$versionD=Get-Date -Format 'yyyy.MM.dd.hh.mm.ss'
$version_=Get-Date -Format 'yyyy_MM_dd'
# $version_D=Get-Date -Format 'yyyy.MM.dd.hh.mm.ss'
$Path = 'mcversion.txt'
$mcversion = Get-Content -Path $Path
function Out-FileUtf8NoBom {
[CmdletBinding()]
param(
[Parameter(Mandatory, Position=0)] [string] $LiteralPath,
[switch] $Append,
[switch] $NoClobber,
[AllowNull()] [int] $Width,
[Parameter(ValueFromPipeline)] $InputObject
)
#requires -version 3
# Make sure that the .NET framework sees the same working dir. as PS
# and resolve the input path to a full path.
[System.IO.Directory]::SetCurrentDirectory($PWD) # Caveat: .NET Core doesn't support [Environment]::CurrentDirectory
$LiteralPath = [IO.Path]::GetFullPath($LiteralPath)
# If -NoClobber was specified, throw an exception if the target file already
# exists.
if ($NoClobber -and (Test-Path $LiteralPath)) {
Throw [IO.IOException]"The file '$LiteralPath' already exists."
}
# Create a StreamWriter object.
# Note that we take advantage of the fact that the StreamWriter class by default:
# - uses UTF-8 encoding
# - without a BOM.
$sw = New-Object IO.StreamWriter $LiteralPath, $Append
$htOutStringArgs = @{}
if ($Width) {
$htOutStringArgs += @{ Width = $Width }
}
# Note: By not using begin / process / end blocks, we're effectively running
# in the end block, which means that all pipeline input has already
# been collected in automatic variable $Input.
# We must use this approach, because using | Out-String individually
# in each iteration of a process block would format each input object
# with an indvidual header.
try {
$Input | Out-String -Stream @htOutStringArgs | % { $sw.WriteLine($_) }
} finally {
$sw.Dispose()
}
}
Add-Content -Path $env:GITHUB_ENV -Value "version=${version}"
Add-Content -Path $env:GITHUB_ENV -Value "versionD=${versionD}"
Add-Content -Path $env:GITHUB_ENV -Value "versionDetail=[Minecraft ${mcversion}] ${version}"
echo "Compressing the file..."
New-Item "../build" -ItemType Directory
Compress-Archive -Path "." -DestinationPath "../build/(MC${mcversion})_wifi_MiniGames_${version_}.zip"