diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f346d1d..424aea2c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,32 @@ -image: electronuserland/builder:wine +stages: + - build + - deploy build: + stage: build + image: electronuserland/builder:wine script: - npm install - npm run release + - chmod +x ./app/make-nupkg.sh + - ./app/make-nupkg.sh artifacts: paths: - release-builds/*.exe - release-builds/*.deb - release-builds/*.AppImage - only: - - tags \ No newline at end of file + - release-builds/choco/openflexure-ev.nuspec + - release-builds/choco/tools/chocolateyInstall.ps1 + +deploy: + stage: deploy + image: patrickhuber/choco-linux + dependencies: + - build + script: + - cd ./release-builds/choco + - ls -R + - choco pack + artifacts: + paths: + - release-builds/choco/*.nupkg diff --git a/app/make-nupkg.ps1 b/app/make-nupkg.ps1 new file mode 100644 index 00000000..77053b7d --- /dev/null +++ b/app/make-nupkg.ps1 @@ -0,0 +1,66 @@ +$silentArgs = '/S' +$packageName = 'openflexure-ev' +$fileType = 'exe' + +$packagepath = Join-Path -Path $PSScriptRoot -ChildPath '..\' +$packageJson = Join-Path -Path $packagepath -ChildPath '\package.json' +$outpath = Join-Path -Path $packagepath -ChildPath 'release-builds\choco' + +echo $packagepath +echo $outpath + +If(!(test-path $outpath)) +{ + New-Item -ItemType Directory -Force -Path $outpath +} + +# Get version from package.json +$FullVersion = (Get-Content $packageJson) -join "`n" | ConvertFrom-Json | Select -ExpandProperty "version" +$MajVer, $MinVer = $FullVersion.Split("-") # Split version number from beta string +$MinVer = $MinVer.Replace(".", "") # Convert symver into nuspec ver +$version = $MajVer + "-" + $MinVer + +$InstURL = "$Env:CI_JOB_URL/artifacts/browse/release-builds/openflexure-ev-win.exe" +echo $InstURL + +$NuSpec = @" + + + + $packageName + OpenFlexure eV + $Version + OpenFlexure + Bath Open Instrumentation Group + OpenFlexure Microscope client + An electron-based user client for the OpenFlexure Microscope Server + https://www.openflexure.org/ + https://www.openflexure.org/projects/microscope/ + https://gitlab.com/openflexure/openflexure-microscope-jsclient/issues + https://gitlab.com/openflexure/openflexure-microscope-jsclient/ + + https://gitlab.com/openflexure/openflexure-microscope-jsclient/ + + openflexure microscope ev + https://gitlab.com/openflexure/openflexure-microscope-jsclient/raw/master/LICENSE + false + https://gitlab.com/openflexure/openflexure-microscope-jsclient/raw/master/app/icons/png/512x512.png + + + + + +"@ + +echo $NuSpec | Out-File -force -FilePath "$outpath\openflexure-ev.nuspec" + +$InstPS1 = "Install-ChocolateyPackage '$packageName' '$fileType' '$silentArgs' '$InstURL'" + +$toolspath = "$outpath\tools" +If(!(test-path $toolspath)) +{ + New-Item -ItemType Directory -Force -Path $toolspath +} +echo $InstPS1 | Out-File -force -FilePath "$toolspath\chocolateyInstall.ps1" + +choco pack --outputdirectory $outpath "$outpath\openflexure-ev.nuspec" \ No newline at end of file diff --git a/app/make-nupkg.sh b/app/make-nupkg.sh new file mode 100644 index 00000000..fda63832 --- /dev/null +++ b/app/make-nupkg.sh @@ -0,0 +1,71 @@ +silentArgs='/S' +packageName='openflexure-ev' +fileType='exe' + +scriptPath=`dirname $0` +packagePath="$(dirname "$scriptPath")" +packageJson="$packagePath/package.json" +outpath="$packagePath/release-builds/choco" +toolspath="$outpath/tools" +mkdir -p $toolspath + +echo $scriptPath +echo $packageJson +echo $outpath + +# Get package version from package.json +packageVersion=$(cat $packageJson \ + | grep version \ + | head -1 \ + | awk -F: '{ print $2 }' \ + | sed 's/[",]//g' \ + | tr -d '[[:space:]]') + +# Convert into a nupkg-safe version string +majVer="$(echo $packageVersion | cut -d'-' -f1)" +minVer="$(echo $packageVersion | cut -d'-' -f2)" +minVer="${minVer//.}" +version="$majVer-$minVer" + +echo $version + +# Build installer URL +instURL="$CI_JOB_URL/artifacts/raw/release-builds/openflexure-ev-win.exe" +echo $instURL + +# Build nuspec +cat > "$outpath/openflexure-ev.nuspec" <<- EOL + + + + $packageName + OpenFlexure eV + $version + OpenFlexure + Bath Open Instrumentation Group + OpenFlexure Microscope client + An electron-based user client for the OpenFlexure Microscope Server + https://www.openflexure.org/ + https://www.openflexure.org/projects/microscope/ + https://gitlab.com/openflexure/openflexure-microscope-jsclient/issues + https://gitlab.com/openflexure/openflexure-microscope-jsclient/ + + https://gitlab.com/openflexure/openflexure-microscope-jsclient/ + + openflexure microscope ev + https://gitlab.com/openflexure/openflexure-microscope-jsclient/raw/master/LICENSE + false + https://gitlab.com/openflexure/openflexure-microscope-jsclient/raw/master/app/icons/png/512x512.png + + + + + +EOL + +# Build installer PS1 content +instPS1="Install-ChocolateyPackage $packageName $fileType $silentArgs $instURL" +echo $instPS1 > "$toolspath/chocolateyInstall.ps1" + +# Build nupkg +# choco pack --allow-unofficial --outputdirectory $outpath "$outpath/openflexure-ev.nuspec" \ No newline at end of file