diff --git a/release.ps1 b/release.ps1 deleted file mode 100644 index 46afaa7..0000000 --- a/release.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -if ($args.Length -gt 0) { - $ver = $args[0] -} -else { - $ver = Read-Host 'version' -} - -Remove-Item -Path .\release -Recurse - -mkdir .\release\CmlLib.Core.$ver -mkdir .\release\SampleCoreLauncher$ver -mkdir .\release\SampleWinformLauncher$ver - -Copy-Item .\CmlLib\bin\Release\* -Destination .\release\CmlLib.Core.$ver -Recurse -Get-ChildItem .\release\CmlLib.Core.$ver -Recurse -File | Where-Object { ($_.Extension -ne ".dll") } | Remove-Item -Copy-Item .\CmlLibWinFormSample\bin\Release\* -Destination .\release\SampleWinformLauncher$ver -Include *.exe, *.dll, *.pdb, *.config -Copy-Item .\CmlLibCoreSample\bin\Release\net5.0\* -Destination .\release\SampleCoreLauncher$ver -Include *.exe, *.dll, *.pdb, *.config - -Compress-Archive -Path .\release\CmlLib.Core.$ver -DestinationPath .\release\CmlLib.Core.$ver.zip -Compress-Archive -Path .\release\SampleCoreLauncher$ver -DestinationPath .\release\SampleCoreLauncher$ver.zip -Compress-Archive -Path .\release\SampleWinformLauncher$ver -DestinationPath .\release\SampleWinformLauncher$ver.zip - -Remove-Item -Path .\release\CmlLib.Core.$ver -Recurse -Remove-Item -Path .\release\SampleCoreLauncher$ver -Recurse -Remove-Item -Path .\release\SampleWinformLauncher$ver -Recurse \ No newline at end of file diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..4e4245c --- /dev/null +++ b/release.sh @@ -0,0 +1,49 @@ +#!/bin/sh +export CMLLIB_RELEASE_VERSION_NAME + +if [ "$1" != "" ]; then + versionName=$1 +elif [ "$CMLLIB_RELEASE_VERSION_NAME" != "" ]; then + versionName=$CMLLIB_RELEASE_VERSION_NAME; +else + echo "Error: Specify version name" + exit +fi + +baseDir=$(dirname "$0") + +csprojCmlLib="${baseDir}/CmlLib/CmlLib.csproj" +csprojCmlLibCoreSample="${baseDir}/CmlLibCoreSample/CmlLibCoreSample.csproj" +csprojCmlLibWinFormSample="${baseDir}/CmlLibWinFormSample/CmlLibWinFormSample.csproj" + +[ ! -f $csprojCmlLib ] && { echo "Cannot find CmlLib.csproj file"; exit; } +[ ! -f $csprojCmlLibCoreSample ] && { echo "Cannot find CmlLibCoreSample.csproj file"; exit; } +[ ! -f $csprojCmlLibWinFormSample ] && { echo "Cannot find CmlLibWinFormSample.csproj file"; exit; } + +outDir="${baseDir}/release" +publishDir="${outDir}/CmlLib.Core.${versionName}" +sampleCoreLauncherDir="${outDir}/SampleCoreLauncher" +sampleWinFormLauncherDir="${outDir}/SampleWinFormLauncher" + +if [ -d $outDir ]; then + rm -r $outDir || { echo "Failed to remove output directory: ${outDir}"; exit; } +fi + +echo +echo "Packing nupkg file..." +dotnet pack "$csprojCmlLib" -o "$outDir" -c Release || exit; + +echo +echo "Publishing CmlLibCoreSample project..." +dotnet publish "$csprojCmlLibCoreSample" -o "$sampleCoreLauncherDir" -c Release --no-self-contained || exit; +tar -zcvf "${sampleCoreLauncherDir}.tar.gz" "$sampleCoreLauncherDir" +rm -rf "${sampleCoreLauncherDir}" + +echo +echo "Publishing CmlLibWinFormSample project..." +dotnet publish "$csprojCmlLibWinFormSample" -o "$sampleWinFormLauncherDir" -c Release --no-self-contained || exit; +tar -zcvf "${sampleWinFormSample}.tar.gz" "$sampleWinFormLauncherDir" +rm -rf "${sampleWinFormLauncherDir}" + +echo +echo "Done" \ No newline at end of file