From 8482b75140a0a31b9399d5f30e4407e500481af4 Mon Sep 17 00:00:00 2001 From: Tim Flynn Date: Fri, 15 Mar 2019 13:28:16 -0400 Subject: [PATCH] Use a powershell script for release packaging (#24) --- build/ci/linux.yml | 4 ---- build/ci/package.yml | 13 +++++++++++++ build/ci/release.yml | 15 --------------- build/ci/windows.yml | 9 ++++----- build/win/release.bat | 37 ------------------------------------- build/win/release.ps1 | 29 +++++++++++++++++++++++++++++ build/win/test.ps1 | 6 +++--- 7 files changed, 49 insertions(+), 64 deletions(-) delete mode 100644 build/ci/release.yml delete mode 100644 build/win/release.bat create mode 100644 build/win/release.ps1 diff --git a/build/ci/linux.yml b/build/ci/linux.yml index af9df22b4..78e41d3f0 100644 --- a/build/ci/linux.yml +++ b/build/ci/linux.yml @@ -47,7 +47,3 @@ jobs: - template: package.yml parameters: contents: 'build/nix/release-*/etc/libfly-*.tar.bz2' - - - template: release.yml - parameters: - contents: 'libfly-*.tar.bz2' diff --git a/build/ci/package.yml b/build/ci/package.yml index ed315d8bc..ed7150897 100644 --- a/build/ci/package.yml +++ b/build/ci/package.yml @@ -1,5 +1,6 @@ parameters: contents: '' + release: '' steps: - task: CopyFiles@2 @@ -14,3 +15,15 @@ steps: pathtoPublish: $(Build.ArtifactStagingDirectory) artifactName: libfly displayName: 'Publish' + +- task: GitHubRelease@0 + condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/') + inputs: + action: 'edit' + tag: $(Build.SourceBranchName) + tagSource: 'Git tag' + gitHubConnection: libfly + repositoryName: trflynn89/libfly + assets: $(Build.ArtifactStagingDirectory)/* + assetUploadMode: 'replace' + displayName: Release diff --git a/build/ci/release.yml b/build/ci/release.yml deleted file mode 100644 index 5642459fc..000000000 --- a/build/ci/release.yml +++ /dev/null @@ -1,15 +0,0 @@ -parameters: - contents: '' - -steps: -- task: GitHubRelease@0 - condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/') - inputs: - action: 'edit' - tag: $(Build.SourceBranchName) - tagSource: 'Git tag' - gitHubConnection: libfly - repositoryName: trflynn89/libfly - assets: $(Build.ArtifactStagingDirectory)/${{ parameters.contents }} - assetUploadMode: 'replace' - displayName: Release diff --git a/build/ci/windows.yml b/build/ci/windows.yml index 34ec131ee..9903947b2 100644 --- a/build/ci/windows.yml +++ b/build/ci/windows.yml @@ -26,13 +26,12 @@ jobs: displayName: 'Test' - ${{ if eq(parameters.configuration, 'Release') }}: - - script: build\win\release.bat + - task: PowerShell@2 + inputs: + filePath: build\win\release.ps1 + arguments: -arch ${{ parameters.arch }} displayName: 'Package' - template: package.yml parameters: contents: 'build\win\libfly-*.zip' - - - template: release.yml - parameters: - contents: 'libfly-*.zip' diff --git a/build/win/release.bat b/build/win/release.bat deleted file mode 100644 index 357393644..000000000 --- a/build/win/release.bat +++ /dev/null @@ -1,37 +0,0 @@ -@echo off - -:: Set the build directory -set root_dir=%~dp0 -if not exist "%root_dir%" echo error: "%root_dir%": not found & goto :eof - -:: Create release zips -call:create_release x86 -call:create_release x64 -exit /B 0 - -:: Create a release zip (expects x86 or x64 as input) -:create_release - echo Creating %1 release - - set /p fly_version= < %root_dir%..\..\VERSION.md - set fly_src_dir=%root_dir%..\..\fly - set fly_rel_dir=%root_dir%libfly-win-%fly_version%.%1 - set fly_rel_zip=%fly_rel_dir%.zip - set fly_exclude=%root_dir%exclude.txt - - echo .mk > %fly_exclude% - echo .cpp >> %fly_exclude% - - del /Q %fly_rel_zip% 2> NUL - rmdir /S /Q %fly_rel_dir% 2> NUL - mkdir %fly_rel_dir%\fly - - copy /V /Y %root_dir%Debug-%1\libfly\libflyd.%1.lib %fly_rel_dir% - copy /V /Y %root_dir%Release-%1\libfly\libfly.%1.lib %fly_rel_dir% - xcopy /S /V /Y /Q /EXCLUDE:%fly_exclude% %fly_src_dir% %fly_rel_dir%\fly - - powershell -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::CreateFromDirectory('%fly_rel_dir%', '%fly_rel_zip%'); }" - rmdir /S /Q %fly_rel_dir% - del /F /Q %fly_exclude% - - exit /B /0 diff --git a/build/win/release.ps1 b/build/win/release.ps1 new file mode 100644 index 000000000..84a7cd489 --- /dev/null +++ b/build/win/release.ps1 @@ -0,0 +1,29 @@ +param ( + [Parameter(Mandatory=$true)][string]$arch +) + +# Create a release package for an architecture. +function Create-Libfly-Package($arch) +{ + Write-Output "Creating $arch package" + + $version = Get-Content -Path ($PSScriptRoot + "\..\..\VERSION.md") + + $package_src_path = $PSScriptRoot + "\..\..\fly" + $package_lib_path = $PSScriptRoot + "\Release-" + $arch + "\libfly" + $package_tmp_path = $PSScriptRoot + "\libfly-win-" + $version + "." + $arch + $package_zip_path = $package_tmp_path + ".zip" + + Remove-Item -Path $package_tmp_path -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path $package_zip_path -ErrorAction SilentlyContinue + New-Item -Path $package_tmp_path -ItemType Directory + + Copy-Item -Path ($package_lib_path + "\libfly." + $arch + ".lib") -Destination $package_tmp_path + Copy-Item -Path $package_src_path -Destination $package_tmp_path -Recurse -Exclude @("*.mk", "*.cpp") + + Compress-Archive -Path ($package_tmp_path + "\*") -Destination $package_zip_path -CompressionLevel Optimal + Remove-Item -Path $package_tmp_path -Recurse -ErrorAction SilentlyContinue +} + +# Create the package +Create-Libfly-Package $arch diff --git a/build/win/test.ps1 b/build/win/test.ps1 index c54a41428..c91a733c1 100644 --- a/build/win/test.ps1 +++ b/build/win/test.ps1 @@ -1,13 +1,13 @@ param ( [Parameter(Mandatory=$true)][string]$arch - ) +) -# Run all unit tests for an architecture and upload results to appveyor. +# Run all unit tests for an architecture. function Run-Libfly-Test($arch) { Write-Output "Running $arch tests" - $full_path = $PSScriptRoot + "\\Debug-" + $arch + $full_path = $PSScriptRoot + "\Debug-" + $arch $tests_passed = 0 $tests_failed = 0