Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up chocolatey package building #254

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ stages:
artifactName: WinVS2017x64Binaries
targetPath: WinVS2017x64Binaries
displayName: Download WinVS2017x64Binaries
- powershell: |
.\extra\chocolatey\generatePackage.ps1 $(NEKO_VERSION)
Get-ChildItem extra\chocolatey\out
displayName: Prepare Chocolatey Package
- powershell: |
$commitSha = git rev-parse --short HEAD
$commitTime = git show -s --format=%cI HEAD
Expand All @@ -102,9 +98,8 @@ stages:
$chocoVersion = If ($sourceBranch.StartsWith('refs/tags/v')) {'$(NEKO_VERSION)'} Else {"$(NEKO_VERSION)-SNAP$commitTime"}
echo "##vso[task.setvariable variable=chocoVersion]$chocoVersion"
displayName: Format package version string
- powershell: choco pack --version $env:chocoVersion -Out ..\pack
workingDirectory: extra/chocolatey/out/
displayName: choco pack
- powershell: .\extra\chocolatey\Build-Package.ps1 -Version $(NEKO_VERSION) -LongVersion $env:chocoVersion
displayName: Create chocolatey package
- task: PublishPipelineArtifact@0
inputs:
artifactName: Chocolatey
Expand Down
2 changes: 2 additions & 0 deletions extra/chocolatey/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
neko
pack
43 changes: 43 additions & 0 deletions extra/chocolatey/Build-Package.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
param ([string] $version, [string] $longVersion)
$ErrorActionPreference = "Stop"

If ( $version -eq "" ) {
Write-Error "No version parameter was passed in."
Exit 1
}
If ( $longVersion -eq "" ) {
Write-Error "No longVersion parameter was passed in."
Exit 1
}

$DIR = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

# Create chocolatey template

$TEMPLATE_DIR = "$env:ChocolateyInstall\templates\neko-template"

If ( Test-Path -Path $TEMPLATE_DIR) {
Get-ChildItem -Path $TEMPLATE_DIR -File | foreach { $_.Delete()}
} Else {
New-Item -Path $TEMPLATE_DIR -ItemType "directory" -Force > $null
}

Copy-Item -Path $DIR\* -Recurse -Include neko.nuspec,tools -Destination $TEMPLATE_DIR -Force
Copy-Item .\LICENSE $TEMPLATE_DIR\tools\LICENSE

# Create package contents from template

$file32 = ".\WinVS2017Binaries\neko-$version-win.zip"
$file64 = ".\WinVS2017x64Binaries\neko-$version-win64.zip"

$checksum32 = (Get-FileHash $file32).Hash.ToLower()
$checksum64 = (Get-FileHash $file64).Hash.ToLower()

choco new neko -t neko-template --version $longVersion --out $DIR --force Checksum32=$checksum32 Checksum64=$checksum64 ShortVersion=$version
Copy-Item -Path $file32,$file64 -Destination $DIR\neko

# Package everything

$OUTPUT = "$DIR\pack"
New-Item -Path $OUTPUT -ItemType "directory" -Force > $null
choco pack --version $longVersion $DIR\neko\neko.nuspec -Out $OUTPUT
24 changes: 0 additions & 24 deletions extra/chocolatey/chocolateyInstall.ps1.template

This file was deleted.

58 changes: 0 additions & 58 deletions extra/chocolatey/generatePackage.ps1

This file was deleted.

7 changes: 6 additions & 1 deletion extra/chocolatey/neko.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>neko</id>
<version>0.0.0</version>
<version>[[PackageVersion]]</version>
<title>Neko</title>
<authors>Haxe Foundation</authors>
<owners>Haxe Foundation</owners>
Expand All @@ -23,4 +23,9 @@
<dependency id="vcredist2017" version="14.16.27033" />
</dependencies>
</metadata>
<files>
<file src="neko-[[ShortVersion]]-win.zip" />
<file src="neko-[[ShortVersion]]-win64.zip" />
<file src="tools\**" target="tools" />
</files>
</package>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Packager (Andy Li) is a member of the Haxe Foundation.
The files included in this package are the "Windows Binaries" available at https://github.com/HaxeFoundation/neko/releases.

The files included in this package are the "Windows Binaries" available at https://github.com/HaxeFoundation/neko/releases.
31 changes: 31 additions & 0 deletions extra/chocolatey/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$ErrorActionPreference = "Stop"
# set variables
$shortVersion = '[[ShortVersion]]'

$packDir = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition | Split-Path -Parent)"

$packageArgs = @{
PackageName = 'neko'
UnzipLocation = "$packDir"
Url = "$packDir\neko-$shortVersion-win.zip"
Checksum = '[[Checksum32]]'
ChecksumType = 'sha256'
Url64bit = "$packDir\neko-$shortVersion-win64.zip"
Checksum64 = '[[Checksum64]]'
ChecksumType64 = 'sha256'
}

Install-ChocolateyZipPackage @packageArgs

$nekoDir = "$(Get-Item "$packDir/neko-$shortVersion-win*" -Exclude "*.zip")"

# Install the dll files to C:\ProgramData\chocolatey\bin
# It is because they are loaded by other neko binaries, e.g. haxelib.exe
$chocoBin = Join-Path $env:ChocolateyInstall 'bin'
$dllFiles = @('gcmt-dll.dll', 'neko.dll')
foreach ($file in $dllFiles) {
Copy-Item "$nekoDir\$file" "$chocoBin"
}

# Set NEKOPATH such that the ndll files can be loaded.
Install-ChocolateyEnvironmentVariable -VariableName NEKOPATH -VariableValue $nekoDir